Commit 596b8cc6471efdea99cd767ff1c804ad9f6ae038

Authored by Kalutka Zhenya
1 parent bcfa6e7f

Refactoring and updated fix

@@ -42,7 +42,7 @@ import { @@ -42,7 +42,7 @@ import {
42 WidgetActionDialogData 42 WidgetActionDialogData
43 } from '@home/components/widget/action/widget-action-dialog.component'; 43 } from '@home/components/widget/action/widget-action-dialog.component';
44 import { deepClone } from '@core/utils'; 44 import { deepClone } from '@core/utils';
45 -import { WidgetConfigComponentData } from '@home/models/widget-component.models'; 45 +import { widgetType } from '@shared/models/widget.models';
46 46
47 @Component({ 47 @Component({
48 selector: 'tb-manage-widget-actions', 48 selector: 'tb-manage-widget-actions',
@@ -60,7 +60,7 @@ export class ManageWidgetActionsComponent extends PageComponent implements OnIni @@ -60,7 +60,7 @@ export class ManageWidgetActionsComponent extends PageComponent implements OnIni
60 60
61 @Input() disabled: boolean; 61 @Input() disabled: boolean;
62 62
63 - @Input() modelValue: WidgetConfigComponentData; 63 + @Input() widgetType: widgetType;
64 64
65 @Input() callbacks: WidgetActionCallbacks; 65 @Input() callbacks: WidgetActionCallbacks;
66 66
@@ -184,7 +184,7 @@ export class ManageWidgetActionsComponent extends PageComponent implements OnIni @@ -184,7 +184,7 @@ export class ManageWidgetActionsComponent extends PageComponent implements OnIni
184 callbacks: this.callbacks, 184 callbacks: this.callbacks,
185 actionsData, 185 actionsData,
186 action: deepClone(action), 186 action: deepClone(action),
187 - modelValue: this.modelValue 187 + widgetType: this.widgetType
188 } 188 }
189 }).afterClosed().subscribe( 189 }).afterClosed().subscribe(
190 (res) => { 190 (res) => {
@@ -120,7 +120,7 @@ @@ -120,7 +120,7 @@
120 widgetActionFormGroup.get('type').value === widgetActionType.updateDashboardState || 120 widgetActionFormGroup.get('type').value === widgetActionType.updateDashboardState ||
121 widgetActionFormGroup.get('type').value === widgetActionType.openDashboard ? 121 widgetActionFormGroup.get('type').value === widgetActionType.openDashboard ?
122 widgetActionFormGroup.get('type').value : ''"> 122 widgetActionFormGroup.get('type').value : ''">
123 - <mat-checkbox *ngIf="data.modelValue.widgetType !== widgetType.static" formControlName="setEntityId"> 123 + <mat-checkbox *ngIf="data.widgetType !== widgetType.static" formControlName="setEntityId">
124 {{ 'widget-action.set-entity-from-widget' | translate }} 124 {{ 'widget-action.set-entity-from-widget' | translate }}
125 </mat-checkbox> 125 </mat-checkbox>
126 <mat-form-field *ngIf="actionTypeFormGroup.get('setEntityId').value" 126 <mat-form-field *ngIf="actionTypeFormGroup.get('setEntityId').value"
@@ -28,9 +28,6 @@ import { @@ -28,9 +28,6 @@ import {
28 ValidatorFn, 28 ValidatorFn,
29 Validators 29 Validators
30 } from '@angular/forms'; 30 } from '@angular/forms';
31 -import {  
32 - WidgetConfigComponentData  
33 -} from '@home/models/widget-component.models';  
34 import { Observable, of } from 'rxjs'; 31 import { Observable, of } from 'rxjs';
35 import { Router } from '@angular/router'; 32 import { Router } from '@angular/router';
36 import { DialogComponent } from '@app/shared/components/dialog.component'; 33 import { DialogComponent } from '@app/shared/components/dialog.component';
@@ -56,7 +53,7 @@ export interface WidgetActionDialogData { @@ -56,7 +53,7 @@ export interface WidgetActionDialogData {
56 callbacks: WidgetActionCallbacks; 53 callbacks: WidgetActionCallbacks;
57 actionsData: WidgetActionsData; 54 actionsData: WidgetActionsData;
58 action?: WidgetActionDescriptorInfo; 55 action?: WidgetActionDescriptorInfo;
59 - modelValue: WidgetConfigComponentData; 56 + widgetType: widgetType;
60 } 57 }
61 58
62 @Component({ 59 @Component({
@@ -147,7 +144,7 @@ export class WidgetActionDialogComponent extends DialogComponent<WidgetActionDia @@ -147,7 +144,7 @@ export class WidgetActionDialogComponent extends DialogComponent<WidgetActionDia
147 ); 144 );
148 this.actionTypeFormGroup.addControl( 145 this.actionTypeFormGroup.addControl(
149 'setEntityId', 146 'setEntityId',
150 - this.fb.control(action ? action.setEntityId : this.data.modelValue.widgetType === widgetType.static ? false : true , []) 147 + this.fb.control(this.data.widgetType === widgetType.static ? false : action ? action.setEntityId : true, [])
151 ); 148 );
152 this.actionTypeFormGroup.addControl( 149 this.actionTypeFormGroup.addControl(
153 'stateEntityParamName', 150 'stateEntityParamName',
@@ -443,7 +443,7 @@ @@ -443,7 +443,7 @@
443 <mat-tab label="{{ 'widget-config.actions' | translate }}" [formGroup]="actionsSettings"> 443 <mat-tab label="{{ 'widget-config.actions' | translate }}" [formGroup]="actionsSettings">
444 <tb-manage-widget-actions 444 <tb-manage-widget-actions
445 [callbacks]="widgetConfigCallbacks" 445 [callbacks]="widgetConfigCallbacks"
446 - [modelValue] = "modelValue" 446 + [widgetType] = "modelValue.widgetType"
447 formControlName="actionsData"> 447 formControlName="actionsData">
448 </tb-manage-widget-actions> 448 </tb-manage-widget-actions>
449 </mat-tab> 449 </mat-tab>
@@ -1015,7 +1015,7 @@ export class WidgetComponent extends PageComponent implements OnInit, AfterViewI @@ -1015,7 +1015,7 @@ export class WidgetComponent extends PageComponent implements OnInit, AfterViewI
1015 const type = descriptor.type; 1015 const type = descriptor.type;
1016 const targetEntityParamName = descriptor.stateEntityParamName; 1016 const targetEntityParamName = descriptor.stateEntityParamName;
1017 let targetEntityId: EntityId; 1017 let targetEntityId: EntityId;
1018 - if (descriptor.setEntityId && validateEntityId(entityId)) { 1018 + if (this.widgetInfo.type !== 'static' && descriptor.setEntityId && validateEntityId(entityId)) {
1019 targetEntityId = entityId; 1019 targetEntityId = entityId;
1020 } 1020 }
1021 switch (type) { 1021 switch (type) {