Browse Source

UI: Refactoring

pull/8812/head
Artem Dzhereleiko 3 years ago
parent
commit
e442ce6e1b
  1. 29
      ui-ngx/src/app/shared/components/rule-chain/rule-chain-select.component.html
  2. 19
      ui-ngx/src/app/shared/components/rule-chain/rule-chain-select.component.scss
  3. 15
      ui-ngx/src/app/shared/components/rule-chain/rule-chain-select.component.ts

29
ui-ngx/src/app/shared/components/rule-chain/rule-chain-select.component.html

@ -15,18 +15,17 @@
limitations under the License.
-->
<mat-select fxFlex
class="tb-rule-chain-select"
[required]="required"
[disabled]="disabled"
[(ngModel)]="ruleChain"
[compareWith]="compareWith"
(ngModelChange)="ruleChainIdChanged()">
<mat-select-trigger fxFlex fxLayout="row">
<mat-icon class="tb-rule-chain-select-trigger-icon">settings_ethernet</mat-icon>
<span class="tb-rule-chain-select-trigger-text">{{ruleChain?.name}}</span>
</mat-select-trigger>
<mat-option *ngFor="let ruleChain of ruleChains$ | async" [value]="ruleChain">
{{ruleChain.name}}
</mat-option>
</mat-select>
<mat-form-field subscriptSizing="dynamic">
<mat-icon matPrefix>settings_ethernet</mat-icon>
<mat-select fxFlex
class="tb-rule-chain-select"
hideSingleSelectionIndicator="false"
[required]="required"
[disabled]="disabled"
[(ngModel)]="ruleChainId"
(ngModelChange)="ruleChainIdChanged()">
<mat-option *ngFor="let ruleChain of ruleChains$ | async" [value]="ruleChain.id.id">
{{ruleChain.name}}
</mat-option>
</mat-select>
</mat-form-field>

19
ui-ngx/src/app/shared/components/rule-chain/rule-chain-select.component.scss

@ -19,21 +19,14 @@
padding: 0 6px;
.tb-rule-chain-select {
display: flex;
height: 48px;
min-height: 100%;
pointer-events: all;
}
}
&-trigger {
&-text {
max-width: 190px;
text-overflow: ellipsis;
overflow: hidden;
}
&-icon {
display: flex;
width: 36px;
justify-content: center;
}
}
:host ::ng-deep {
.mat-mdc-form-field-infix {
min-height: 48px;
padding: 12px 0 !important;
}
}

15
ui-ngx/src/app/shared/components/rule-chain/rule-chain-select.component.ts

@ -57,7 +57,7 @@ export class RuleChainSelectComponent implements ControlValueAccessor, OnInit {
ruleChains$: Observable<Array<RuleChain>>;
ruleChain: RuleChain;
ruleChainId: string | null;
private propagateChange = (v: any) => { };
@ -76,10 +76,6 @@ export class RuleChainSelectComponent implements ControlValueAccessor, OnInit {
);
}
public compareWith(object1: any, object2: any) {
return object1 && object2 && object1.id.id === object2.id.id;
}
registerOnChange(fn: any): void {
this.propagateChange = fn;
}
@ -94,21 +90,16 @@ export class RuleChainSelectComponent implements ControlValueAccessor, OnInit {
writeValue(value: string | null): void {
if (isDefinedAndNotNull(value)) {
this.ruleChainService.getRuleChain(value)
.subscribe(ruleChain => this.ruleChain = ruleChain);
this.ruleChainId = value;
}
}
getname() {
return this.ruleChain?.name;
}
ruleChainIdChanged() {
this.updateView();
}
private updateView() {
this.propagateChange(this.ruleChain.id.id);
this.propagateChange(this.ruleChainId);
}
private getRuleChains(pageLink: PageLink): Observable<PageData<RuleChain>> {

Loading…
Cancel
Save