From 25641d33e1996bcf81f9ebf35790f31dab1b37c8 Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Mon, 19 Apr 2021 14:00:38 +0200 Subject: [PATCH] Ask the right app when getting appObjectManager, appname might not always be the current app (e.g. running app content under admin tab) --- api/js/egw_action/egw_action.d.ts | 3 ++- api/js/egw_action/egw_action.js | 5 +++-- api/js/etemplate/et2_widget_grid.js | 3 ++- api/js/etemplate/et2_widget_grid.ts | 3 ++- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/api/js/egw_action/egw_action.d.ts b/api/js/egw_action/egw_action.d.ts index 017c80d9b1..84d79098a3 100644 --- a/api/js/egw_action/egw_action.d.ts +++ b/api/js/egw_action/egw_action.d.ts @@ -44,9 +44,10 @@ declare function egw_getObjectManager(_id: any, _create?: boolean, _search_depth * Returns the object manager for the current application * * @param {boolean} _create + * @param {string} _appName * @return {egwActionObjectManager} */ -declare function egw_getAppObjectManager(_create?: boolean): typeof egwActionObjectManager; +declare function egw_getAppObjectManager(_create?: boolean, _appName?: string): typeof egwActionObjectManager; /** * Returns the action manager for the current application * diff --git a/api/js/egw_action/egw_action.js b/api/js/egw_action/egw_action.js index 0d81b14c52..667b2563d0 100644 --- a/api/js/egw_action/egw_action.js +++ b/api/js/egw_action/egw_action.js @@ -103,10 +103,11 @@ function egw_getObjectManager(_id, _create, _search_depth) { * Returns the object manager for the current application * * @param {boolean} _create + * @param {string} _appName //appname might not always be the current app, e.g. running app content under admin tab * @return {egwActionObjectManager} */ -function egw_getAppObjectManager(_create) { - return egw_getObjectManager(egw_getAppName(), _create,1); +function egw_getAppObjectManager(_create, _appName) { + return egw_getObjectManager(_appName ?? egw_getAppName(), _create,1); } /** diff --git a/api/js/etemplate/et2_widget_grid.js b/api/js/etemplate/et2_widget_grid.js index d2018d8ea9..cd4b4c0f14 100644 --- a/api/js/etemplate/et2_widget_grid.js +++ b/api/js/etemplate/et2_widget_grid.js @@ -734,8 +734,9 @@ var et2_grid = /** @class */ (function (_super) { */ et2_grid.prototype._link_actions = function (actions) { // Get the top level element for the tree + // get appObjectManager for the actual app, it might not always be the current app(e.g. running app content under admin tab) // @ts-ignore - var objectManager = window.egw_getAppObjectManager(true); + var objectManager = window.egw_getAppObjectManager(true, this.getInstanceManager().app); objectManager = objectManager.getObjectById(this.getInstanceManager().uniqueId, 2) || objectManager; var widget_object = objectManager.getObjectById(this.id); if (widget_object == null) { diff --git a/api/js/etemplate/et2_widget_grid.ts b/api/js/etemplate/et2_widget_grid.ts index 258dc4c5dd..657f831a62 100644 --- a/api/js/etemplate/et2_widget_grid.ts +++ b/api/js/etemplate/et2_widget_grid.ts @@ -998,8 +998,9 @@ export class et2_grid extends et2_DOMWidget implements et2_IDetachedDOM, et2_IAl _link_actions(actions : object[]) { // Get the top level element for the tree + // get appObjectManager for the actual app, it might not always be the current app(e.g. running app content under admin tab) // @ts-ignore - let objectManager = window.egw_getAppObjectManager(true); + let objectManager = window.egw_getAppObjectManager(true, this.getInstanceManager().app); objectManager = objectManager.getObjectById(this.getInstanceManager().uniqueId,2) || objectManager; let widget_object = objectManager.getObjectById(this.id); if (widget_object == null) {