From c63784d7e81ff6683f03877d19b825cb6ddf6e2b Mon Sep 17 00:00:00 2001 From: ralf Date: Tue, 11 Jul 2023 22:45:33 +0200 Subject: [PATCH] WIP new app.ts method dialogExec(_menuaction) opening a popup into a dialog --- api/js/etemplate/etemplate2.ts | 23 +++++++++++++++++++---- api/src/Etemplate.php | 2 +- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/api/js/etemplate/etemplate2.ts b/api/js/etemplate/etemplate2.ts index 0fb7d38575..4a3c14c81c 100644 --- a/api/js/etemplate/etemplate2.ts +++ b/api/js/etemplate/etemplate2.ts @@ -1515,27 +1515,36 @@ export class etemplate2 { // Check the parameters const data = _response.data; + // window-close does NOT send data.DOMNodeID! + const dialog = document.querySelector('et2-dialog > form'+(data.DOMNodeID?'#'+data.DOMNodeID:''))?.parentNode; // handle Api\Framework::refresh_opener() if(Array.isArray(data['refresh-opener'])) { if(window.opener)// && typeof window.opener.egw_refresh == 'function') { - var egw = window.egw(opener); + const egw = window.egw(dialog ? window : opener); egw.refresh.apply(egw, data['refresh-opener']); } } - var egw = window.egw(window); + const egw = window.egw(window); // need to set app_header before message, as message temp. replaces app_header if(typeof data.data == 'object' && typeof data.data.app_header == 'string') { - egw.app_header(data.data.app_header, data.data.currentapp || null); + if (dialog) + { + dialog.title = data.data.app_header; + } + else + { + egw.app_header(data.data.app_header, data.data.currentapp || null); + } delete data.data.app_header; } // handle Api\Framework::message() - if(jQuery.isArray(data.message)) + if(Array.isArray(data.message)) { egw.message.apply(egw, data.message); } @@ -1547,6 +1556,12 @@ export class etemplate2 { alert(data['window-close']); } + if (dialog) + { + dialog.close(); + dialog.parentNode.removeChild(dialog); + return Promise.resolve(); + } egw.close(); return true; } diff --git a/api/src/Etemplate.php b/api/src/Etemplate.php index 26280cb765..d2ec7e3fe0 100644 --- a/api/src/Etemplate.php +++ b/api/src/Etemplate.php @@ -260,7 +260,7 @@ class Etemplate extends Etemplate\Widget\Template { if ($output_mode == 2) { - $content = '
'."\n"; + $content = '
'."\n"; } else {