Commit 1f5a8ef70f8912a00912b318abcf3396e7d72f61

Authored by Kalutka Zhenya
1 parent c768fcba

Updated logic for 'Set entity from widget' in static widget

... ... @@ -42,6 +42,7 @@ import {
42 42 WidgetActionDialogData
43 43 } from '@home/components/widget/action/widget-action-dialog.component';
44 44 import { deepClone } from '@core/utils';
  45 +import { WidgetConfigComponentData } from '@home/models/widget-component.models';
45 46
46 47 @Component({
47 48 selector: 'tb-manage-widget-actions',
... ... @@ -59,6 +60,8 @@ export class ManageWidgetActionsComponent extends PageComponent implements OnIni
59 60
60 61 @Input() disabled: boolean;
61 62
  63 + @Input() modelValue: WidgetConfigComponentData;
  64 +
62 65 @Input() callbacks: WidgetActionCallbacks;
63 66
64 67 innerValue: WidgetActionsData;
... ... @@ -180,7 +183,8 @@ export class ManageWidgetActionsComponent extends PageComponent implements OnIni
180 183 isAdd,
181 184 callbacks: this.callbacks,
182 185 actionsData,
183   - action: deepClone(action)
  186 + action: deepClone(action),
  187 + modelValue: this.modelValue
184 188 }
185 189 }).afterClosed().subscribe(
186 190 (res) => {
... ...
... ... @@ -120,7 +120,7 @@
120 120 widgetActionFormGroup.get('type').value === widgetActionType.updateDashboardState ||
121 121 widgetActionFormGroup.get('type').value === widgetActionType.openDashboard ?
122 122 widgetActionFormGroup.get('type').value : ''">
123   - <mat-checkbox formControlName="setEntityId">
  123 + <mat-checkbox *ngIf="data.modelValue.widgetType !== widgetType.static" formControlName="setEntityId">
124 124 {{ 'widget-action.set-entity-from-widget' | translate }}
125 125 </mat-checkbox>
126 126 <mat-form-field *ngIf="actionTypeFormGroup.get('setEntityId').value"
... ...
... ... @@ -28,6 +28,10 @@ import {
28 28 ValidatorFn,
29 29 Validators
30 30 } from '@angular/forms';
  31 +import {
  32 + WidgetConfigComponentData,
  33 + WidgetInfo
  34 +} from '@home/models/widget-component.models';
31 35 import { Observable, of } from 'rxjs';
32 36 import { Router } from '@angular/router';
33 37 import { DialogComponent } from '@app/shared/components/dialog.component';
... ... @@ -46,12 +50,14 @@ import { DashboardUtilsService } from '@core/services/dashboard-utils.service';
46 50 import { CustomActionEditorCompleter } from '@home/components/widget/action/custom-action.models';
47 51 import { isDefinedAndNotNull } from '@core/utils';
48 52 import { MobileActionEditorComponent } from '@home/components/widget/action/mobile-action-editor.component';
  53 +import { widgetType } from '@shared/models/widget.models';
49 54
50 55 export interface WidgetActionDialogData {
51 56 isAdd: boolean;
52 57 callbacks: WidgetActionCallbacks;
53 58 actionsData: WidgetActionsData;
54 59 action?: WidgetActionDescriptorInfo;
  60 + modelValue: WidgetConfigComponentData;
55 61 }
56 62
57 63 @Component({
... ... @@ -67,8 +73,10 @@ export class WidgetActionDialogComponent extends DialogComponent<WidgetActionDia
67 73
68 74 @ViewChild('mobileActionEditor', {static: false}) mobileActionEditor: MobileActionEditorComponent;
69 75
  76 +
70 77 widgetActionFormGroup: FormGroup;
71 78 actionTypeFormGroup: FormGroup;
  79 + widgetInfo: WidgetInfo;
72 80
73 81 isAdd: boolean;
74 82 action: WidgetActionDescriptorInfo;
... ... @@ -84,6 +92,7 @@ export class WidgetActionDialogComponent extends DialogComponent<WidgetActionDia
84 92 customActionEditorCompleter = CustomActionEditorCompleter;
85 93
86 94 submitted = false;
  95 + widgetType = widgetType;
87 96
88 97 constructor(protected store: Store<AppState>,
89 98 protected router: Router,
... ... @@ -139,9 +148,10 @@ export class WidgetActionDialogComponent extends DialogComponent<WidgetActionDia
139 148 this.fb.control(action ? action.targetDashboardStateId : null,
140 149 type === WidgetActionType.openDashboardState ? [Validators.required] : [])
141 150 );
  151 +
142 152 this.actionTypeFormGroup.addControl(
143 153 'setEntityId',
144   - this.fb.control(action ? action.setEntityId : true, [])
  154 + this.fb.control(action ? action.setEntityId : this.data.modelValue.widgetType === widgetType.static ? false : true , [])
145 155 );
146 156 this.actionTypeFormGroup.addControl(
147 157 'stateEntityParamName',
... ...
... ... @@ -443,6 +443,7 @@
443 443 <mat-tab label="{{ 'widget-config.actions' | translate }}" [formGroup]="actionsSettings">
444 444 <tb-manage-widget-actions
445 445 [callbacks]="widgetConfigCallbacks"
  446 + [modelValue] = "modelValue"
446 447 formControlName="actionsData">
447 448 </tb-manage-widget-actions>
448 449 </mat-tab>
... ...