Commit 5e990da0ba785cf7716d3acb2e61495127852e88
Committed by
Andrew Shvayka
1 parent
ada0af2a
UI: Refactoring alarm-rule inherit
Showing
4 changed files
with
20 additions
and
22 deletions
@@ -47,7 +47,7 @@ | @@ -47,7 +47,7 @@ | ||
47 | </div> | 47 | </div> |
48 | <div fxFlex fxLayout="column" [fxShow]="dynamicMode"> | 48 | <div fxFlex fxLayout="column" [fxShow]="dynamicMode"> |
49 | <div formGroupName="dynamicValue" fxLayout="row" fxLayoutAlign="start center" fxLayoutGap="8px"> | 49 | <div formGroupName="dynamicValue" fxLayout="row" fxLayoutAlign="start center" fxLayoutGap="8px"> |
50 | - <div fxFlex fxLayout="column"> | 50 | + <div fxFlex="35" fxLayout="column"> |
51 | <mat-form-field floatLabel="always" hideRequiredMarker class="mat-block"> | 51 | <mat-form-field floatLabel="always" hideRequiredMarker class="mat-block"> |
52 | <mat-label></mat-label> | 52 | <mat-label></mat-label> |
53 | <mat-select formControlName="sourceType" placeholder="{{'filter.dynamic-source-type' | translate}}"> | 53 | <mat-select formControlName="sourceType" placeholder="{{'filter.dynamic-source-type' | translate}}"> |
@@ -61,15 +61,6 @@ | @@ -61,15 +61,6 @@ | ||
61 | </mat-form-field> | 61 | </mat-form-field> |
62 | <div class="tb-hint" translate>filter.dynamic-source-type</div> | 62 | <div class="tb-hint" translate>filter.dynamic-source-type</div> |
63 | </div> | 63 | </div> |
64 | - <div *ngIf="!allow" | ||
65 | - [ngClass]="{invisible: !inheritMode}" | ||
66 | - fxLayout="column" | ||
67 | - fxLayoutAlign="center center"> | ||
68 | - <mat-checkbox formControlName="inherit" | ||
69 | - style="min-width: 35px;" | ||
70 | - ></mat-checkbox> | ||
71 | - <div class="tb-hint">Inherit from owner</div> | ||
72 | - </div> | ||
73 | <div fxFlex fxLayout="column"> | 64 | <div fxFlex fxLayout="column"> |
74 | <mat-form-field floatLabel="always" hideRequiredMarker class="mat-block"> | 65 | <mat-form-field floatLabel="always" hideRequiredMarker class="mat-block"> |
75 | <mat-label></mat-label> | 66 | <mat-label></mat-label> |
@@ -77,6 +68,14 @@ | @@ -77,6 +68,14 @@ | ||
77 | </mat-form-field> | 68 | </mat-form-field> |
78 | <div class="tb-hint" translate>filter.source-attribute</div> | 69 | <div class="tb-hint" translate>filter.source-attribute</div> |
79 | </div> | 70 | </div> |
71 | + <div *ngIf="!allow && inheritMode" | ||
72 | + fxLayout="column" | ||
73 | + style="padding-top: 6px"> | ||
74 | + <mat-checkbox formControlName="inherit"> | ||
75 | + {{ 'filter.inherit-owner' | translate}} | ||
76 | + </mat-checkbox> | ||
77 | + <div class="tb-hint" translate>filter.source-attribute-not-set</div> | ||
78 | + </div> | ||
80 | </div> | 79 | </div> |
81 | </div> | 80 | </div> |
82 | <button mat-icon-button | 81 | <button mat-icon-button |
@@ -44,7 +44,8 @@ import { | @@ -44,7 +44,8 @@ import { | ||
44 | }) | 44 | }) |
45 | export class FilterPredicateValueComponent implements ControlValueAccessor, OnInit { | 45 | export class FilterPredicateValueComponent implements ControlValueAccessor, OnInit { |
46 | 46 | ||
47 | - private readonly inheritFromSources: DynamicValueSourceType[] = [DynamicValueSourceType.CURRENT_CUSTOMER, | 47 | + private readonly inheritModeForSources: DynamicValueSourceType[] = [ |
48 | + DynamicValueSourceType.CURRENT_CUSTOMER, | ||
48 | DynamicValueSourceType.CURRENT_DEVICE]; | 49 | DynamicValueSourceType.CURRENT_DEVICE]; |
49 | 50 | ||
50 | @Input() disabled: boolean; | 51 | @Input() disabled: boolean; |
@@ -120,7 +121,7 @@ export class FilterPredicateValueComponent implements ControlValueAccessor, OnIn | @@ -120,7 +121,7 @@ export class FilterPredicateValueComponent implements ControlValueAccessor, OnIn | ||
120 | if (!sourceType) { | 121 | if (!sourceType) { |
121 | this.filterPredicateValueFormGroup.get('dynamicValue').get('sourceAttribute').patchValue(null, {emitEvent: false}); | 122 | this.filterPredicateValueFormGroup.get('dynamicValue').get('sourceAttribute').patchValue(null, {emitEvent: false}); |
122 | } | 123 | } |
123 | - this.updateInheritValue(sourceType); | 124 | + this.updateShowInheritMode(sourceType); |
124 | } | 125 | } |
125 | ); | 126 | ); |
126 | this.filterPredicateValueFormGroup.valueChanges.subscribe(() => { | 127 | this.filterPredicateValueFormGroup.valueChanges.subscribe(() => { |
@@ -148,11 +149,11 @@ export class FilterPredicateValueComponent implements ControlValueAccessor, OnIn | @@ -148,11 +149,11 @@ export class FilterPredicateValueComponent implements ControlValueAccessor, OnIn | ||
148 | this.filterPredicateValueFormGroup.get('defaultValue').patchValue(predicateValue.defaultValue, {emitEvent: false}); | 149 | this.filterPredicateValueFormGroup.get('defaultValue').patchValue(predicateValue.defaultValue, {emitEvent: false}); |
149 | this.filterPredicateValueFormGroup.get('dynamicValue.sourceType').patchValue(predicateValue.dynamicValue ? | 150 | this.filterPredicateValueFormGroup.get('dynamicValue.sourceType').patchValue(predicateValue.dynamicValue ? |
150 | predicateValue.dynamicValue.sourceType : null, {emitEvent: false}); | 151 | predicateValue.dynamicValue.sourceType : null, {emitEvent: false}); |
151 | - this.filterPredicateValueFormGroup.get('dynamicValue.inherit').patchValue(predicateValue.dynamicValue ? | ||
152 | - predicateValue.dynamicValue.inherit : false, {emitEvent: false}); | ||
153 | this.filterPredicateValueFormGroup.get('dynamicValue.sourceAttribute').patchValue(predicateValue.dynamicValue ? | 152 | this.filterPredicateValueFormGroup.get('dynamicValue.sourceAttribute').patchValue(predicateValue.dynamicValue ? |
154 | predicateValue.dynamicValue.sourceAttribute : null, {emitEvent: false}); | 153 | predicateValue.dynamicValue.sourceAttribute : null, {emitEvent: false}); |
155 | - this.updateInheritValue(predicateValue?.dynamicValue?.sourceType); | 154 | + this.filterPredicateValueFormGroup.get('dynamicValue.inherit').patchValue(predicateValue.dynamicValue ? |
155 | + predicateValue.dynamicValue.inherit : false, {emitEvent: false}); | ||
156 | + this.updateShowInheritMode(predicateValue?.dynamicValue?.sourceType); | ||
156 | } | 157 | } |
157 | 158 | ||
158 | private updateModel() { | 159 | private updateModel() { |
@@ -168,8 +169,8 @@ export class FilterPredicateValueComponent implements ControlValueAccessor, OnIn | @@ -168,8 +169,8 @@ export class FilterPredicateValueComponent implements ControlValueAccessor, OnIn | ||
168 | this.propagateChange(predicateValue); | 169 | this.propagateChange(predicateValue); |
169 | } | 170 | } |
170 | 171 | ||
171 | - private updateInheritValue(sourceType: DynamicValueSourceType) { | ||
172 | - if (this.inheritFromSources.includes(sourceType)) { | 172 | + private updateShowInheritMode(sourceType: DynamicValueSourceType) { |
173 | + if (this.inheritModeForSources.includes(sourceType)) { | ||
173 | this.inheritMode = true; | 174 | this.inheritMode = true; |
174 | } else { | 175 | } else { |
175 | this.filterPredicateValueFormGroup.get('dynamicValue.inherit').patchValue(false, {emitEvent: false}); | 176 | this.filterPredicateValueFormGroup.get('dynamicValue.inherit').patchValue(false, {emitEvent: false}); |
@@ -1591,7 +1591,9 @@ | @@ -1591,7 +1591,9 @@ | ||
1591 | "no-dynamic-value": "No dynamic value", | 1591 | "no-dynamic-value": "No dynamic value", |
1592 | "source-attribute": "Source attribute", | 1592 | "source-attribute": "Source attribute", |
1593 | "switch-to-dynamic-value": "Switch to dynamic value", | 1593 | "switch-to-dynamic-value": "Switch to dynamic value", |
1594 | - "switch-to-default-value": "Switch to default value" | 1594 | + "switch-to-default-value": "Switch to default value", |
1595 | + "inherit-owner": "Inherit from owner", | ||
1596 | + "source-attribute-not-set": "If source attribute isn't set" | ||
1595 | }, | 1597 | }, |
1596 | "fullscreen": { | 1598 | "fullscreen": { |
1597 | "expand": "Expand to fullscreen", | 1599 | "expand": "Expand to fullscreen", |