Fix some bugs in nextmatch dialog action

Wrong action was used, leading to an error.  Plus, it kept a copy of the nextmatch in memory across the reload.
This commit is contained in:
nathan 2022-03-24 14:48:02 -06:00
parent 76d6ed81cd
commit 467e2ca8e2

View File

@ -437,6 +437,18 @@ export function nm_open_popup(_action, _selected)
} }
let action = _action; let action = _action;
let selected = _selected; let selected = _selected;
nm_popup_action = _action;
if (_selected.length && typeof _selected[0] == 'object')
{
_action.data.nextmatch = _selected[0]._context._widget;
nm_popup_ids = _selected;
}
else
{
egw().debug("warn", 'Not proper format for IDs, should be array of egwActionObject', _selected);
nm_popup_ids = _selected;
}
// Find the popup div // Find the popup div
var popup = document.body.querySelector("et2-dialog[id*='" + _action.id + "_popup']") || document.body.querySelector("#" + (uid || "") + "_" + _action.id + "_popup") || document.body.querySelector("[id*='" + _action.id + "_popup']"); var popup = document.body.querySelector("et2-dialog[id*='" + _action.id + "_popup']") || document.body.querySelector("#" + (uid || "") + "_" + _action.id + "_popup") || document.body.querySelector("[id*='" + _action.id + "_popup']");
@ -446,22 +458,16 @@ export function nm_open_popup(_action, _selected)
} }
else if (popup) else if (popup)
{ {
nm_popup_action = _action;
if (_selected.length && typeof _selected[0] == 'object')
{
_action.data.nextmatch = _selected[0]._context._widget;
nm_popup_ids = _selected;
}
else
{
egw().debug("warn", 'Not proper format for IDs, should be array of egwActionObject', _selected);
nm_popup_ids = _selected;
}
let dialog = new Et2Dialog(); let dialog = new Et2Dialog();
dialog.destroy_on_close = false; dialog.destroy_on_close = false;
dialog.id = popup.id; dialog.id = popup.id;
popup.setAttribute("id", "_" + popup.id); popup.setAttribute("id", "_" + popup.id);
dialog.addEventListener("close", () =>
{
window.nm_popup_action = null;
})
dialog.getUpdateComplete().then(() => dialog.getUpdateComplete().then(() =>
{ {
let title = popup.querySelector(".promptheader") let title = popup.querySelector(".promptheader")
@ -479,7 +485,7 @@ export function nm_open_popup(_action, _selected)
let button_click = button.onclick; let button_click = button.onclick;
button.onclick = (e) => button.onclick = (e) =>
{ {
window.nm_popup_action = button_click ? _action : null; window.nm_popup_action = button_click ? action : null;
window.nm_popup_ids = selected; window.nm_popup_ids = selected;
dialog.close(); dialog.close();