From 96bb3a68840b81712fc4212c8841667eceee35fe Mon Sep 17 00:00:00 2001 From: ralf Date: Tue, 11 Jul 2023 13:38:09 +0200 Subject: [PATCH] WIP new app.ts method dialogExec(_menuaction) opening a popup into a dialog ToDo: overwrite Framework actions in etemplate2.handle_load() to eg. close dialog, but not window, or refresh window instead of opener --- api/js/etemplate/Et2Dialog/Et2Dialog.ts | 2 +- api/js/jsapi/egw_app.ts | 23 +++++++++++++++++++++++ api/src/Etemplate.php | 15 +++++++++++---- 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/api/js/etemplate/Et2Dialog/Et2Dialog.ts b/api/js/etemplate/Et2Dialog/Et2Dialog.ts index 53bcef624a..a3aca525e5 100644 --- a/api/js/etemplate/Et2Dialog/Et2Dialog.ts +++ b/api/js/etemplate/Et2Dialog/Et2Dialog.ts @@ -956,7 +956,7 @@ export class Et2Dialog extends Et2Widget(SlotMixin(SlDialog)) let template_buttons = [ ...search_in.querySelectorAll('[slot="footer"],[slot="buttons"]'), // Look for a dialog footer, which will contain several buttons and possible other widgets - ...search_in.querySelectorAll(".dialogFooterToolbar"), + ...search_in.querySelectorAll(".dialogFooterToolbar et2-button"), // Look for buttons at high level (not everywhere, otherwise we can't have other buttons in the template) ...search_in.querySelectorAll(":scope > et2-button, :scope > * > et2-button") ]; diff --git a/api/js/jsapi/egw_app.ts b/api/js/jsapi/egw_app.ts index c61c8a0e54..43183b2b5c 100644 --- a/api/js/jsapi/egw_app.ts +++ b/api/js/jsapi/egw_app.ts @@ -748,6 +748,29 @@ export abstract class EgwApp this.et2_view.close = destroy; } + /** + * Opens _menuaction in an Et2Dialog + * + * @param _menuaction + * @return Promise + */ + dialogExec(_menuaction : string) + { + const ajax = this.egw.json(_menuaction.match(/^([^.:]+)/)[0] + '.jdots_framework.ajax_exec.template.' + _menuaction, + ['index.php?menuaction=' + _menuaction], _response => + { + if (Array.isArray(_response) && typeof _response[0] === 'string') + { + jQuery(_response[0]).appendTo(document.body); + } + else + { + console.log("Invalid response to dialogExec('"+_menuaction+"')", _response); + } + }); + return ajax.sendRequest(); + } + /** * Merge selected entries into template document * diff --git a/api/src/Etemplate.php b/api/src/Etemplate.php index 4eb63207b5..26280cb765 100644 --- a/api/src/Etemplate.php +++ b/api/src/Etemplate.php @@ -93,7 +93,7 @@ class Etemplate extends Etemplate\Widget\Template * 0 = echo incl. navbar * 1 = return html * -1 = first time return html, after use 0 (echo html incl. navbar), eg. for home - * 2 = echo without navbar (eg. for popups) + * 2 = popup or show in dialog (echo without navbar) * 3 = return eGW independent html site * 4 = json response * 5 = return Request object @@ -258,8 +258,15 @@ class Etemplate extends Etemplate\Widget\Template // check if we are in an ajax-exec call from jdots template (or future other tabbed templates) if (isset($GLOBALS['egw']->framework->response)) { - $content = '
'."\n". - ''; + if ($output_mode == 2) + { + $content = '
'."\n"; + } + else + { + $content = '
'."\n". + ''; + } $GLOBALS['egw']->framework->response->generic("data", array($content)); $GLOBALS['egw']->framework->response->generic('et2_load',$load_array+Framework::get_extra()); Framework::clear_extra(); // to not send/set it twice for multiple etemplates (eg. CRM view) @@ -774,4 +781,4 @@ class Etemplate extends Etemplate\Widget\Template } return (int)$size; } -} +} \ No newline at end of file