UI: Added icon for rule chain selector
This commit is contained in:
parent
dd900dafba
commit
06849452f4
@ -30,7 +30,7 @@
|
|||||||
fxLayout="column">
|
fxLayout="column">
|
||||||
<mat-toolbar color="primary" class="tb-dark">
|
<mat-toolbar color="primary" class="tb-dark">
|
||||||
<tb-rule-chain-select
|
<tb-rule-chain-select
|
||||||
fxFlex
|
fxFlex fxLayout="row" fxLayoutAlign="start center"
|
||||||
*ngIf="!isImport"
|
*ngIf="!isImport"
|
||||||
[ruleChainType]="ruleChainType"
|
[ruleChainType]="ruleChainType"
|
||||||
[disabled]="isDirtyValue"
|
[disabled]="isDirtyValue"
|
||||||
|
|||||||
@ -19,9 +19,14 @@
|
|||||||
class="tb-rule-chain-select"
|
class="tb-rule-chain-select"
|
||||||
[required]="required"
|
[required]="required"
|
||||||
[disabled]="disabled"
|
[disabled]="disabled"
|
||||||
[(ngModel)]="ruleChainId"
|
[(ngModel)]="ruleChain"
|
||||||
|
[compareWith]="compareWith"
|
||||||
(ngModelChange)="ruleChainIdChanged()">
|
(ngModelChange)="ruleChainIdChanged()">
|
||||||
<mat-option *ngFor="let ruleChain of ruleChains$ | async" [value]="ruleChain.id.id">
|
<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}}
|
{{ruleChain.name}}
|
||||||
</mat-option>
|
</mat-option>
|
||||||
</mat-select>
|
</mat-select>
|
||||||
|
|||||||
@ -22,5 +22,18 @@
|
|||||||
height: 48px;
|
height: 48px;
|
||||||
min-height: 100%;
|
min-height: 100%;
|
||||||
pointer-events: all;
|
pointer-events: all;
|
||||||
|
|
||||||
|
&-trigger {
|
||||||
|
&-text {
|
||||||
|
max-width: 190px;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
&-icon {
|
||||||
|
display: flex;
|
||||||
|
width: 36px;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -57,7 +57,9 @@ export class RuleChainSelectComponent implements ControlValueAccessor, OnInit {
|
|||||||
|
|
||||||
ruleChains$: Observable<Array<RuleChain>>;
|
ruleChains$: Observable<Array<RuleChain>>;
|
||||||
|
|
||||||
ruleChainId: string | null;
|
ruleChain: RuleChain;
|
||||||
|
|
||||||
|
selected: any;
|
||||||
|
|
||||||
private propagateChange = (v: any) => { };
|
private propagateChange = (v: any) => { };
|
||||||
|
|
||||||
@ -76,6 +78,10 @@ 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 {
|
registerOnChange(fn: any): void {
|
||||||
this.propagateChange = fn;
|
this.propagateChange = fn;
|
||||||
}
|
}
|
||||||
@ -90,16 +96,21 @@ export class RuleChainSelectComponent implements ControlValueAccessor, OnInit {
|
|||||||
|
|
||||||
writeValue(value: string | null): void {
|
writeValue(value: string | null): void {
|
||||||
if (isDefinedAndNotNull(value)) {
|
if (isDefinedAndNotNull(value)) {
|
||||||
this.ruleChainId = value;
|
this.ruleChainService.getRuleChain(value)
|
||||||
|
.subscribe(ruleChain => this.ruleChain = ruleChain);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getname() {
|
||||||
|
return this.ruleChain?.name;
|
||||||
|
}
|
||||||
|
|
||||||
ruleChainIdChanged() {
|
ruleChainIdChanged() {
|
||||||
this.updateView();
|
this.updateView();
|
||||||
}
|
}
|
||||||
|
|
||||||
private updateView() {
|
private updateView() {
|
||||||
this.propagateChange(this.ruleChainId);
|
this.propagateChange(this.ruleChain.id.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
private getRuleChains(pageLink: PageLink): Observable<PageData<RuleChain>> {
|
private getRuleChains(pageLink: PageLink): Observable<PageData<RuleChain>> {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user