Browse Source

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

pull/4592/head
Kalutka Zhenya 5 years ago
parent
commit
1f5a8ef70f
  1. 6
      ui-ngx/src/app/modules/home/components/widget/action/manage-widget-actions.component.ts
  2. 2
      ui-ngx/src/app/modules/home/components/widget/action/widget-action-dialog.component.html
  3. 12
      ui-ngx/src/app/modules/home/components/widget/action/widget-action-dialog.component.ts
  4. 1
      ui-ngx/src/app/modules/home/components/widget/widget-config.component.html

6
ui-ngx/src/app/modules/home/components/widget/action/manage-widget-actions.component.ts

@ -42,6 +42,7 @@ import {
WidgetActionDialogData WidgetActionDialogData
} from '@home/components/widget/action/widget-action-dialog.component'; } from '@home/components/widget/action/widget-action-dialog.component';
import { deepClone } from '@core/utils'; import { deepClone } from '@core/utils';
import { WidgetConfigComponentData } from '@home/models/widget-component.models';
@Component({ @Component({
selector: 'tb-manage-widget-actions', selector: 'tb-manage-widget-actions',
@ -59,6 +60,8 @@ export class ManageWidgetActionsComponent extends PageComponent implements OnIni
@Input() disabled: boolean; @Input() disabled: boolean;
@Input() modelValue: WidgetConfigComponentData;
@Input() callbacks: WidgetActionCallbacks; @Input() callbacks: WidgetActionCallbacks;
innerValue: WidgetActionsData; innerValue: WidgetActionsData;
@ -180,7 +183,8 @@ export class ManageWidgetActionsComponent extends PageComponent implements OnIni
isAdd, isAdd,
callbacks: this.callbacks, callbacks: this.callbacks,
actionsData, actionsData,
action: deepClone(action) action: deepClone(action),
modelValue: this.modelValue
} }
}).afterClosed().subscribe( }).afterClosed().subscribe(
(res) => { (res) => {

2
ui-ngx/src/app/modules/home/components/widget/action/widget-action-dialog.component.html

@ -120,7 +120,7 @@
widgetActionFormGroup.get('type').value === widgetActionType.updateDashboardState || widgetActionFormGroup.get('type').value === widgetActionType.updateDashboardState ||
widgetActionFormGroup.get('type').value === widgetActionType.openDashboard ? widgetActionFormGroup.get('type').value === widgetActionType.openDashboard ?
widgetActionFormGroup.get('type').value : ''"> widgetActionFormGroup.get('type').value : ''">
<mat-checkbox formControlName="setEntityId"> <mat-checkbox *ngIf="data.modelValue.widgetType !== widgetType.static" formControlName="setEntityId">
{{ 'widget-action.set-entity-from-widget' | translate }} {{ 'widget-action.set-entity-from-widget' | translate }}
</mat-checkbox> </mat-checkbox>
<mat-form-field *ngIf="actionTypeFormGroup.get('setEntityId').value" <mat-form-field *ngIf="actionTypeFormGroup.get('setEntityId').value"

12
ui-ngx/src/app/modules/home/components/widget/action/widget-action-dialog.component.ts

@ -28,6 +28,10 @@ import {
ValidatorFn, ValidatorFn,
Validators Validators
} from '@angular/forms'; } from '@angular/forms';
import {
WidgetConfigComponentData,
WidgetInfo
} from '@home/models/widget-component.models';
import { Observable, of } from 'rxjs'; import { Observable, of } from 'rxjs';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { DialogComponent } from '@app/shared/components/dialog.component'; import { DialogComponent } from '@app/shared/components/dialog.component';
@ -46,12 +50,14 @@ import { DashboardUtilsService } from '@core/services/dashboard-utils.service';
import { CustomActionEditorCompleter } from '@home/components/widget/action/custom-action.models'; import { CustomActionEditorCompleter } from '@home/components/widget/action/custom-action.models';
import { isDefinedAndNotNull } from '@core/utils'; import { isDefinedAndNotNull } from '@core/utils';
import { MobileActionEditorComponent } from '@home/components/widget/action/mobile-action-editor.component'; import { MobileActionEditorComponent } from '@home/components/widget/action/mobile-action-editor.component';
import { widgetType } from '@shared/models/widget.models';
export interface WidgetActionDialogData { export interface WidgetActionDialogData {
isAdd: boolean; isAdd: boolean;
callbacks: WidgetActionCallbacks; callbacks: WidgetActionCallbacks;
actionsData: WidgetActionsData; actionsData: WidgetActionsData;
action?: WidgetActionDescriptorInfo; action?: WidgetActionDescriptorInfo;
modelValue: WidgetConfigComponentData;
} }
@Component({ @Component({
@ -67,8 +73,10 @@ export class WidgetActionDialogComponent extends DialogComponent<WidgetActionDia
@ViewChild('mobileActionEditor', {static: false}) mobileActionEditor: MobileActionEditorComponent; @ViewChild('mobileActionEditor', {static: false}) mobileActionEditor: MobileActionEditorComponent;
widgetActionFormGroup: FormGroup; widgetActionFormGroup: FormGroup;
actionTypeFormGroup: FormGroup; actionTypeFormGroup: FormGroup;
widgetInfo: WidgetInfo;
isAdd: boolean; isAdd: boolean;
action: WidgetActionDescriptorInfo; action: WidgetActionDescriptorInfo;
@ -84,6 +92,7 @@ export class WidgetActionDialogComponent extends DialogComponent<WidgetActionDia
customActionEditorCompleter = CustomActionEditorCompleter; customActionEditorCompleter = CustomActionEditorCompleter;
submitted = false; submitted = false;
widgetType = widgetType;
constructor(protected store: Store<AppState>, constructor(protected store: Store<AppState>,
protected router: Router, protected router: Router,
@ -139,9 +148,10 @@ export class WidgetActionDialogComponent extends DialogComponent<WidgetActionDia
this.fb.control(action ? action.targetDashboardStateId : null, this.fb.control(action ? action.targetDashboardStateId : null,
type === WidgetActionType.openDashboardState ? [Validators.required] : []) type === WidgetActionType.openDashboardState ? [Validators.required] : [])
); );
this.actionTypeFormGroup.addControl( this.actionTypeFormGroup.addControl(
'setEntityId', 'setEntityId',
this.fb.control(action ? action.setEntityId : true, []) this.fb.control(action ? action.setEntityId : this.data.modelValue.widgetType === widgetType.static ? false : true , [])
); );
this.actionTypeFormGroup.addControl( this.actionTypeFormGroup.addControl(
'stateEntityParamName', 'stateEntityParamName',

1
ui-ngx/src/app/modules/home/components/widget/widget-config.component.html

@ -443,6 +443,7 @@
<mat-tab label="{{ 'widget-config.actions' | translate }}" [formGroup]="actionsSettings"> <mat-tab label="{{ 'widget-config.actions' | translate }}" [formGroup]="actionsSettings">
<tb-manage-widget-actions <tb-manage-widget-actions
[callbacks]="widgetConfigCallbacks" [callbacks]="widgetConfigCallbacks"
[modelValue] = "modelValue"
formControlName="actionsData"> formControlName="actionsData">
</tb-manage-widget-actions> </tb-manage-widget-actions>
</mat-tab> </mat-tab>

Loading…
Cancel
Save