Commit 7515ce7a3da63a07f8fb19df03eb0e8498795437

Authored by Vladyslav_Prykhodko
1 parent e4bfbacd

UI: Added new function openDashboardStateInSeparateDialog to widget context

@@ -84,6 +84,8 @@ export interface WidgetActionsApi { @@ -84,6 +84,8 @@ export interface WidgetActionsApi {
84 entityId?: EntityId, entityName?: string, additionalParams?: any, entityLabel?: string) => void; 84 entityId?: EntityId, entityName?: string, additionalParams?: any, entityLabel?: string) => void;
85 elementClick: ($event: Event) => void; 85 elementClick: ($event: Event) => void;
86 getActiveEntityInfo: () => SubscriptionEntityInfo; 86 getActiveEntityInfo: () => SubscriptionEntityInfo;
  87 + openDashboardStateInSeparateDialog: (targetDashboardStateId: string, params?: StateParams, dialogTitle?: string,
  88 + hideDashboardToolbar?: boolean, dialogWidth?: number, dialogHeight?: number) => void;
87 } 89 }
88 90
89 export interface AliasInfo { 91 export interface AliasInfo {
@@ -284,7 +284,8 @@ export class WidgetComponent extends PageComponent implements OnInit, AfterViewI @@ -284,7 +284,8 @@ export class WidgetComponent extends PageComponent implements OnInit, AfterViewI
284 getActionDescriptors: this.getActionDescriptors.bind(this), 284 getActionDescriptors: this.getActionDescriptors.bind(this),
285 handleWidgetAction: this.handleWidgetAction.bind(this), 285 handleWidgetAction: this.handleWidgetAction.bind(this),
286 elementClick: this.elementClick.bind(this), 286 elementClick: this.elementClick.bind(this),
287 - getActiveEntityInfo: this.getActiveEntityInfo.bind(this) 287 + getActiveEntityInfo: this.getActiveEntityInfo.bind(this),
  288 + openDashboardStateInSeparateDialog: this.openDashboardStateInSeparateDialog.bind(this)
288 }; 289 };
289 290
290 this.widgetContext.customHeaderActions = []; 291 this.widgetContext.customHeaderActions = [];
@@ -1025,7 +1026,8 @@ export class WidgetComponent extends PageComponent implements OnInit, AfterViewI @@ -1025,7 +1026,8 @@ export class WidgetComponent extends PageComponent implements OnInit, AfterViewI
1025 this.updateEntityParams(params, targetEntityParamName, targetEntityId, entityName, entityLabel); 1026 this.updateEntityParams(params, targetEntityParamName, targetEntityId, entityName, entityLabel);
1026 if (type === WidgetActionType.openDashboardState) { 1027 if (type === WidgetActionType.openDashboardState) {
1027 if (descriptor.openInSeparateDialog) { 1028 if (descriptor.openInSeparateDialog) {
1028 - this.openDashboardStateInDialog(descriptor, entityId, entityName, additionalParams, entityLabel); 1029 + this.openDashboardStateInSeparateDialog(descriptor.targetDashboardStateId, params, descriptor.dialogTitle,
  1030 + descriptor.dialogHideDashboardToolbar, descriptor.dialogWidth, descriptor.dialogHeight);
1029 } else { 1031 } else {
1030 this.widgetContext.stateController.openState(targetDashboardStateId, params, descriptor.openRightLayout); 1032 this.widgetContext.stateController.openState(targetDashboardStateId, params, descriptor.openRightLayout);
1031 } 1033 }
@@ -1276,22 +1278,15 @@ export class WidgetComponent extends PageComponent implements OnInit, AfterViewI @@ -1276,22 +1278,15 @@ export class WidgetComponent extends PageComponent implements OnInit, AfterViewI
1276 } 1278 }
1277 } 1279 }
1278 1280
1279 - private openDashboardStateInDialog(descriptor: WidgetActionDescriptor,  
1280 - entityId?: EntityId, entityName?: string, additionalParams?: any, entityLabel?: string) { 1281 + private openDashboardStateInSeparateDialog(targetDashboardStateId: string, params?: StateParams, dialogTitle?: string,
  1282 + hideDashboardToolbar = true, dialogWidth?: number, dialogHeight?: number) {
1281 const dashboard = deepClone(this.widgetContext.stateController.dashboardCtrl.dashboardCtx.getDashboard()); 1283 const dashboard = deepClone(this.widgetContext.stateController.dashboardCtrl.dashboardCtx.getDashboard());
1282 const stateObject: StateObject = {}; 1284 const stateObject: StateObject = {};
1283 - stateObject.params = {};  
1284 - const targetEntityParamName = descriptor.stateEntityParamName;  
1285 - const targetDashboardStateId = descriptor.targetDashboardStateId;  
1286 - let targetEntityId: EntityId;  
1287 - if (descriptor.setEntityId) {  
1288 - targetEntityId = entityId;  
1289 - }  
1290 - this.updateEntityParams(stateObject.params, targetEntityParamName, targetEntityId, entityName, entityLabel); 1285 + stateObject.params = params;
1291 if (targetDashboardStateId) { 1286 if (targetDashboardStateId) {
1292 stateObject.id = targetDashboardStateId; 1287 stateObject.id = targetDashboardStateId;
1293 } 1288 }
1294 - let title = descriptor.dialogTitle; 1289 + let title = dialogTitle;
1295 if (!title) { 1290 if (!title) {
1296 if (targetDashboardStateId && dashboard.configuration.states) { 1291 if (targetDashboardStateId && dashboard.configuration.states) {
1297 const dashboardState = dashboard.configuration.states[targetDashboardStateId]; 1292 const dashboardState = dashboard.configuration.states[targetDashboardStateId];
@@ -1304,7 +1299,6 @@ export class WidgetComponent extends PageComponent implements OnInit, AfterViewI @@ -1304,7 +1299,6 @@ export class WidgetComponent extends PageComponent implements OnInit, AfterViewI
1304 title = dashboard.title; 1299 title = dashboard.title;
1305 } 1300 }
1306 title = this.utils.customTranslation(title, title); 1301 title = this.utils.customTranslation(title, title);
1307 - const params = stateObject.params;  
1308 const paramsEntityName = params && params.entityName ? params.entityName : ''; 1302 const paramsEntityName = params && params.entityName ? params.entityName : '';
1309 const paramsEntityLabel = params && params.entityLabel ? params.entityLabel : ''; 1303 const paramsEntityLabel = params && params.entityLabel ? params.entityLabel : '';
1310 title = insertVariable(title, 'entityName', paramsEntityName); 1304 title = insertVariable(title, 'entityName', paramsEntityName);
@@ -1324,9 +1318,9 @@ export class WidgetComponent extends PageComponent implements OnInit, AfterViewI @@ -1324,9 +1318,9 @@ export class WidgetComponent extends PageComponent implements OnInit, AfterViewI
1324 dashboard, 1318 dashboard,
1325 state: objToBase64([ stateObject ]), 1319 state: objToBase64([ stateObject ]),
1326 title, 1320 title,
1327 - hideToolbar: descriptor.dialogHideDashboardToolbar,  
1328 - width: descriptor.dialogWidth,  
1329 - height: descriptor.dialogHeight 1321 + hideToolbar: hideDashboardToolbar,
  1322 + width: dialogWidth,
  1323 + height: dialogHeight
1330 } 1324 }
1331 }); 1325 });
1332 } 1326 }