Merge pull request #5015 from vvlladd28/improvement/widget-context/open-dashboard-state-in-dialog
[3.3.0] UI: Added new function openDashboardStateInSeparateDialog to widget context
This commit is contained in:
commit
5867fa8c92
@ -84,6 +84,8 @@ export interface WidgetActionsApi {
|
|||||||
entityId?: EntityId, entityName?: string, additionalParams?: any, entityLabel?: string) => void;
|
entityId?: EntityId, entityName?: string, additionalParams?: any, entityLabel?: string) => void;
|
||||||
elementClick: ($event: Event) => void;
|
elementClick: ($event: Event) => void;
|
||||||
getActiveEntityInfo: () => SubscriptionEntityInfo;
|
getActiveEntityInfo: () => SubscriptionEntityInfo;
|
||||||
|
openDashboardStateInSeparateDialog: (targetDashboardStateId: string, params?: StateParams, dialogTitle?: string,
|
||||||
|
hideDashboardToolbar?: boolean, dialogWidth?: number, dialogHeight?: number) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AliasInfo {
|
export interface AliasInfo {
|
||||||
|
|||||||
@ -284,7 +284,8 @@ export class WidgetComponent extends PageComponent implements OnInit, AfterViewI
|
|||||||
getActionDescriptors: this.getActionDescriptors.bind(this),
|
getActionDescriptors: this.getActionDescriptors.bind(this),
|
||||||
handleWidgetAction: this.handleWidgetAction.bind(this),
|
handleWidgetAction: this.handleWidgetAction.bind(this),
|
||||||
elementClick: this.elementClick.bind(this),
|
elementClick: this.elementClick.bind(this),
|
||||||
getActiveEntityInfo: this.getActiveEntityInfo.bind(this)
|
getActiveEntityInfo: this.getActiveEntityInfo.bind(this),
|
||||||
|
openDashboardStateInSeparateDialog: this.openDashboardStateInSeparateDialog.bind(this)
|
||||||
};
|
};
|
||||||
|
|
||||||
this.widgetContext.customHeaderActions = [];
|
this.widgetContext.customHeaderActions = [];
|
||||||
@ -1025,7 +1026,8 @@ export class WidgetComponent extends PageComponent implements OnInit, AfterViewI
|
|||||||
this.updateEntityParams(params, targetEntityParamName, targetEntityId, entityName, entityLabel);
|
this.updateEntityParams(params, targetEntityParamName, targetEntityId, entityName, entityLabel);
|
||||||
if (type === WidgetActionType.openDashboardState) {
|
if (type === WidgetActionType.openDashboardState) {
|
||||||
if (descriptor.openInSeparateDialog) {
|
if (descriptor.openInSeparateDialog) {
|
||||||
this.openDashboardStateInDialog(descriptor, entityId, entityName, additionalParams, entityLabel);
|
this.openDashboardStateInSeparateDialog(descriptor.targetDashboardStateId, params, descriptor.dialogTitle,
|
||||||
|
descriptor.dialogHideDashboardToolbar, descriptor.dialogWidth, descriptor.dialogHeight);
|
||||||
} else {
|
} else {
|
||||||
this.widgetContext.stateController.openState(targetDashboardStateId, params, descriptor.openRightLayout);
|
this.widgetContext.stateController.openState(targetDashboardStateId, params, descriptor.openRightLayout);
|
||||||
}
|
}
|
||||||
@ -1276,22 +1278,15 @@ export class WidgetComponent extends PageComponent implements OnInit, AfterViewI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private openDashboardStateInDialog(descriptor: WidgetActionDescriptor,
|
private openDashboardStateInSeparateDialog(targetDashboardStateId: string, params?: StateParams, dialogTitle?: string,
|
||||||
entityId?: EntityId, entityName?: string, additionalParams?: any, entityLabel?: string) {
|
hideDashboardToolbar = true, dialogWidth?: number, dialogHeight?: number) {
|
||||||
const dashboard = deepClone(this.widgetContext.stateController.dashboardCtrl.dashboardCtx.getDashboard());
|
const dashboard = deepClone(this.widgetContext.stateController.dashboardCtrl.dashboardCtx.getDashboard());
|
||||||
const stateObject: StateObject = {};
|
const stateObject: StateObject = {};
|
||||||
stateObject.params = {};
|
stateObject.params = params;
|
||||||
const targetEntityParamName = descriptor.stateEntityParamName;
|
|
||||||
const targetDashboardStateId = descriptor.targetDashboardStateId;
|
|
||||||
let targetEntityId: EntityId;
|
|
||||||
if (descriptor.setEntityId) {
|
|
||||||
targetEntityId = entityId;
|
|
||||||
}
|
|
||||||
this.updateEntityParams(stateObject.params, targetEntityParamName, targetEntityId, entityName, entityLabel);
|
|
||||||
if (targetDashboardStateId) {
|
if (targetDashboardStateId) {
|
||||||
stateObject.id = targetDashboardStateId;
|
stateObject.id = targetDashboardStateId;
|
||||||
}
|
}
|
||||||
let title = descriptor.dialogTitle;
|
let title = dialogTitle;
|
||||||
if (!title) {
|
if (!title) {
|
||||||
if (targetDashboardStateId && dashboard.configuration.states) {
|
if (targetDashboardStateId && dashboard.configuration.states) {
|
||||||
const dashboardState = dashboard.configuration.states[targetDashboardStateId];
|
const dashboardState = dashboard.configuration.states[targetDashboardStateId];
|
||||||
@ -1304,7 +1299,6 @@ export class WidgetComponent extends PageComponent implements OnInit, AfterViewI
|
|||||||
title = dashboard.title;
|
title = dashboard.title;
|
||||||
}
|
}
|
||||||
title = this.utils.customTranslation(title, title);
|
title = this.utils.customTranslation(title, title);
|
||||||
const params = stateObject.params;
|
|
||||||
const paramsEntityName = params && params.entityName ? params.entityName : '';
|
const paramsEntityName = params && params.entityName ? params.entityName : '';
|
||||||
const paramsEntityLabel = params && params.entityLabel ? params.entityLabel : '';
|
const paramsEntityLabel = params && params.entityLabel ? params.entityLabel : '';
|
||||||
title = insertVariable(title, 'entityName', paramsEntityName);
|
title = insertVariable(title, 'entityName', paramsEntityName);
|
||||||
@ -1324,9 +1318,9 @@ export class WidgetComponent extends PageComponent implements OnInit, AfterViewI
|
|||||||
dashboard,
|
dashboard,
|
||||||
state: objToBase64([ stateObject ]),
|
state: objToBase64([ stateObject ]),
|
||||||
title,
|
title,
|
||||||
hideToolbar: descriptor.dialogHideDashboardToolbar,
|
hideToolbar: hideDashboardToolbar,
|
||||||
width: descriptor.dialogWidth,
|
width: dialogWidth,
|
||||||
height: descriptor.dialogHeight
|
height: dialogHeight
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user