diff --git a/api/js/etemplate/et2_widget_dialog.js b/api/js/etemplate/et2_widget_dialog.js index e8f735bae7..ca777c3723 100644 --- a/api/js/etemplate/et2_widget_dialog.js +++ b/api/js/etemplate/et2_widget_dialog.js @@ -769,7 +769,7 @@ var et2_dialog = /** @class */ (function (_super) { name: "width", type: "string", description: "Define width of dialog, the default is auto", - "default": 'auto' + "default": et2_no_init }, height: { name: "height", diff --git a/api/js/etemplate/et2_widget_dialog.ts b/api/js/etemplate/et2_widget_dialog.ts index e821d77110..44ed88f6a6 100644 --- a/api/js/etemplate/et2_widget_dialog.ts +++ b/api/js/etemplate/et2_widget_dialog.ts @@ -95,106 +95,106 @@ import {et2_DOMWidget} from "./et2_core_DOMWidget"; */ export class et2_dialog extends et2_widget { static readonly _attributes: any = { - callback: { - name: "Callback", - type: "js", - description: "Callback function is called with the value when the dialog is closed", - "default": function (button_id) { - egw.debug("log", "Button ID: %d", button_id); - } - }, - beforeClose: { - name: "before close callback", - type: "js", - description: "Callback function before dialog is closed, return false to prevent that", - "default": function () { - } - }, - message: { - name: "Message", - type: "string", - description: "Dialog message (plain text, no html)", - "default": "Somebody forgot to set this..." - }, - dialog_type: { - name: "Dialog type", - type: "integer", - description: "To use a pre-defined dialog style, use et2_dialog.ERROR_MESSAGE, INFORMATION_MESSAGE,WARNING_MESSAGE,QUESTION_MESSAGE,PLAIN_MESSAGE constants. Default is et2_dialog.PLAIN_MESSAGE", - "default": 0 //this.PLAIN_MESSAGE - }, - buttons: { - name: "Buttons", - type: "any", - "default": 0, //this.BUTTONS_OK, - description: "Buttons that appear at the bottom of the dialog. You can use the constants et2_dialog.BUTTONS_OK, BUTTONS_YES_NO, BUTTONS_YES_NO_CANCEL, BUTTONS_OK_CANCEL, or pass in an array for full control" - }, - icon: { - name: "Icon", - type: "string", - description: "URL of an icon for the dialog. If omitted, an icon based on dialog_type will be used.", - "default": "" - }, - title: { - name: "Title", - type: "string", - description: "Title for the dialog box (plain text, no html)", - "default": "" - }, - modal: { - name: "Modal", - type: "boolean", - description: "Prevent the user from interacting with the page", - "default": true - }, - resizable: { - name: "Resizable", - type: "boolean", - description: "Allow the user to resize the dialog", - "default": true - }, - value: { - "name": "Value", - "description": "The (default) value of the dialog. Use with template.", - "type": "any", - "default": et2_no_init - }, - template: { - "name": "Template", - "description": "Instead of displaying a simple message, a full template can be loaded instead. Set defaults with value.", - "type": "string", - "default": et2_no_init - }, - minWidth: { - name: "minimum width", - type: "integer", - description: "Define minimum width of dialog", - "default": 0 - }, - minHeight: { - name: "minimum height", - type: "integer", - description: "Define minimum height of dialog", - "default": 0 - }, - width: { - name: "width", - type: "string", - description: "Define width of dialog, the default is auto", - "default": 'auto' - }, - height: { - name: "height", - type: "string", - description: "Define width of dialog, the default is auto", - "default": 'auto' - }, - position: { - name: "position", - type: "string", - description: "Define position of dialog in the main window", - default: "center" - } - }; + callback: { + name: "Callback", + type: "js", + description: "Callback function is called with the value when the dialog is closed", + "default": function (button_id) { + egw.debug("log", "Button ID: %d", button_id); + } + }, + beforeClose: { + name: "before close callback", + type: "js", + description: "Callback function before dialog is closed, return false to prevent that", + "default": function () { + } + }, + message: { + name: "Message", + type: "string", + description: "Dialog message (plain text, no html)", + "default": "Somebody forgot to set this..." + }, + dialog_type: { + name: "Dialog type", + type: "integer", + description: "To use a pre-defined dialog style, use et2_dialog.ERROR_MESSAGE, INFORMATION_MESSAGE,WARNING_MESSAGE,QUESTION_MESSAGE,PLAIN_MESSAGE constants. Default is et2_dialog.PLAIN_MESSAGE", + "default": 0 //this.PLAIN_MESSAGE + }, + buttons: { + name: "Buttons", + type: "any", + "default": 0, //this.BUTTONS_OK, + description: "Buttons that appear at the bottom of the dialog. You can use the constants et2_dialog.BUTTONS_OK, BUTTONS_YES_NO, BUTTONS_YES_NO_CANCEL, BUTTONS_OK_CANCEL, or pass in an array for full control" + }, + icon: { + name: "Icon", + type: "string", + description: "URL of an icon for the dialog. If omitted, an icon based on dialog_type will be used.", + "default": "" + }, + title: { + name: "Title", + type: "string", + description: "Title for the dialog box (plain text, no html)", + "default": "" + }, + modal: { + name: "Modal", + type: "boolean", + description: "Prevent the user from interacting with the page", + "default": true + }, + resizable: { + name: "Resizable", + type: "boolean", + description: "Allow the user to resize the dialog", + "default": true + }, + value: { + "name": "Value", + "description": "The (default) value of the dialog. Use with template.", + "type": "any", + "default": et2_no_init + }, + template: { + "name": "Template", + "description": "Instead of displaying a simple message, a full template can be loaded instead. Set defaults with value.", + "type": "string", + "default": et2_no_init + }, + minWidth: { + name: "minimum width", + type: "integer", + description: "Define minimum width of dialog", + "default": 0 + }, + minHeight: { + name: "minimum height", + type: "integer", + description: "Define minimum height of dialog", + "default": 0 + }, + width: { + name: "width", + type: "string", + description: "Define width of dialog, the default is auto", + "default": et2_no_init + }, + height: { + name: "height", + type: "string", + description: "Define width of dialog, the default is auto", + "default": 'auto' + }, + position: { + name: "position", + type: "string", + description: "Define position of dialog in the main window", + default: "center" + } + }; /** * Details for dialog type options diff --git a/api/js/etemplate/et2_widget_vfs.js b/api/js/etemplate/et2_widget_vfs.js index 3f1ad3f914..2a02b91c25 100644 --- a/api/js/etemplate/et2_widget_vfs.js +++ b/api/js/etemplate/et2_widget_vfs.js @@ -1072,7 +1072,18 @@ var et2_vfsSelect = /** @class */ (function (_super) { } } buttons.push({ text: egw.lang("Close"), id: "close", image: "cancel" }); - var data = jQuery.extend(_data, { 'currentapp': egw(window).app_name() }); + // Don't rely only on app_name to fetch et2 object as app_name may not + // always represent current app of the window, e.g.: mail admin account. + // Try to fetch et2 from its template name. + var etemplate = jQuery('form').data('etemplate'); + var et2; + if (etemplate && etemplate.name && !app[egw(window).app_name()]) { + et2 = etemplate2.getByTemplate(etemplate.name)[0]; + } + else { + et2 = etemplate2.getByApplication(egw(window).app_name())[0]; + } + var data = jQuery.extend(_data, { 'currentapp': egw(window).app_name(), etemplate_exec_id: et2.etemplate_exec_id }); // define a mini app object for vfs select UI app.vfsSelectUI = new app.classes.vfsSelectUI; // callback for dialog @@ -1146,26 +1157,15 @@ var et2_vfsSelect = /** @class */ (function (_super) { this.dialog.template.uniqueId = 'api.vfsSelectUI'; app.vfsSelectUI.et2 = this.dialog.template.widgetContainer; app.vfsSelectUI.vfsSelectWidget = this; - // Don't rely only on app_name to fetch et2 object as app_name may not - // always represent current app of the window, e.g.: mail admin account. - // Try to fetch et2 from its template name. - var etemplate = jQuery('form').data('etemplate'); - var et2; - if (etemplate && etemplate.name && !app[egw(window).app_name()]) { - et2 = etemplate2.getByTemplate(etemplate.name)[0]; - } - else { - et2 = etemplate2.getByApplication(egw(window).app_name())[0]; - } - // we need an etemplate_exec_id for better handling serverside parts of - // widgets and since we can not have a etemplate_exec_id specifically - // for dialog template our best shot is to inherit its parent etemplate_exec_id. - this.dialog.template.etemplate_exec_id = et2.etemplate_exec_id; // Keep the dialog always at the top this.dialog.div.parent().css({ "z-index": 100000 }); this.dialog.div.on('load', function (e) { app.vfsSelectUI.et2_ready(app.vfsSelectUI.et2, 'api.vfsSelectUI'); }); + // we need an etemplate_exec_id for better handling serverside parts of + // widgets and since we can not have a etemplate_exec_id specifically + // for dialog template our best shot is to inherit its parent etemplate_exec_id. + this.dialog.template.etemplate_exec_id = et2.etemplate_exec_id; }; /** * Set recent path into sessionStorage diff --git a/api/js/etemplate/et2_widget_vfs.ts b/api/js/etemplate/et2_widget_vfs.ts index 39fd125acc..3a5c79d151 100644 --- a/api/js/etemplate/et2_widget_vfs.ts +++ b/api/js/etemplate/et2_widget_vfs.ts @@ -1304,7 +1304,23 @@ export class et2_vfsSelect extends et2_inputWidget } buttons.push({text: egw.lang("Close"), id:"close", image:"cancel"}); - let data = jQuery.extend(_data, {'currentapp': egw(window).app_name()}); + + + // Don't rely only on app_name to fetch et2 object as app_name may not + // always represent current app of the window, e.g.: mail admin account. + // Try to fetch et2 from its template name. + let etemplate = jQuery('form').data('etemplate'); + let et2; + if (etemplate && etemplate.name && !app[egw(window).app_name()]) + { + et2 = etemplate2.getByTemplate(etemplate.name)[0]; + } + else + { + et2 = etemplate2.getByApplication(egw(window).app_name())[0]; + } + + let data = jQuery.extend(_data, {'currentapp': egw(window).app_name(), etemplate_exec_id: et2.etemplate_exec_id}); // define a mini app object for vfs select UI app.vfsSelectUI = new app.classes.vfsSelectUI; @@ -1401,29 +1417,16 @@ export class et2_vfsSelect extends et2_inputWidget app.vfsSelectUI.et2 = this.dialog.template.widgetContainer; app.vfsSelectUI.vfsSelectWidget = this; - // Don't rely only on app_name to fetch et2 object as app_name may not - // always represent current app of the window, e.g.: mail admin account. - // Try to fetch et2 from its template name. - let etemplate = jQuery('form').data('etemplate'); - let et2; - if (etemplate && etemplate.name && !app[egw(window).app_name()]) - { - et2 = etemplate2.getByTemplate(etemplate.name)[0]; - } - else - { - et2 = etemplate2.getByApplication(egw(window).app_name())[0]; - } - // we need an etemplate_exec_id for better handling serverside parts of - // widgets and since we can not have a etemplate_exec_id specifically - // for dialog template our best shot is to inherit its parent etemplate_exec_id. - this.dialog.template.etemplate_exec_id = et2.etemplate_exec_id; - // Keep the dialog always at the top this.dialog.div.parent().css({"z-index": 100000}); this.dialog.div.on('load', function(e) { app.vfsSelectUI.et2_ready(app.vfsSelectUI.et2, 'api.vfsSelectUI'); }); + + // we need an etemplate_exec_id for better handling serverside parts of + // widgets and since we can not have a etemplate_exec_id specifically + // for dialog template our best shot is to inherit its parent etemplate_exec_id. + this.dialog.template.etemplate_exec_id = et2.etemplate_exec_id; } /**