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
This commit is contained in:
ralf 2023-07-11 13:38:09 +02:00
parent e9038d2f34
commit 96bb3a6884
3 changed files with 35 additions and 5 deletions

View File

@ -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")
];

View File

@ -748,6 +748,29 @@ export abstract class EgwApp
this.et2_view.close = destroy;
}
/**
* Opens _menuaction in an Et2Dialog
*
* @param _menuaction
* @return Promise<any>
*/
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
*

View File

@ -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 = '<form target="egw_iframe_autocomplete_helper" action="'.$form_action.'" id="'.$dom_id.'" class="et2_container"></form>'."\n".
'<iframe name="egw_iframe_autocomplete_helper" style="width:0;height:0;position: absolute;visibility:hidden;"></iframe>';
if ($output_mode == 2)
{
$content = '<et2-dialog><form id="'.$dom_id.'" class="et2_container"></form></et2-dialog>'."\n";
}
else
{
$content = '<form target="egw_iframe_autocomplete_helper" action="'.$form_action.'" id="'.$dom_id.'" class="et2_container"></form>'."\n".
'<iframe name="egw_iframe_autocomplete_helper" style="width:0;height:0;position: absolute;visibility:hidden;"></iframe>';
}
$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)