fix vfs-select dialog destroyed et2 session of popup calling it

dialog set etemplate_exec_id of popup, to be able to submit to server, but must NOT destroy the et2 session when the dialog closes
et2_dialog now calls etemplate2.clear(true, true) to keep app-object AND et2 session
This commit is contained in:
Ralf Becker 2021-07-07 16:29:04 +02:00
parent 052f5f23cc
commit b2a48fc942
3 changed files with 9 additions and 11 deletions

View File

@ -322,7 +322,9 @@ export class et2_dialog extends et2_widget {
this.div.dialog("destroy");
if (this.template) {
this.template.clear(true);
// if the dialog has an etemplate_exec_id, like the vfs select dialog, we must NOT delete the server-side
// et2 session, as the exec-id is NOT from the dialog, but some other template
this.template.clear(true, true);
this.template = null;
}
@ -904,5 +906,5 @@ export class et2_dialog extends et2_widget {
}
}
// make et2_dialog publicly available as we need to call it from templates
window['et2_dialog'] = et2_dialog;
if (typeof window.et2_dialog === 'undefined') window['et2_dialog'] = et2_dialog;
et2_register_widget(et2_dialog, ["dialog"]);

View File

@ -1460,11 +1460,6 @@ export class et2_vfsSelect extends et2_inputWidget
app.vfsSelectUI.vfsSelectWidget = self;
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;
}
/**

View File

@ -224,8 +224,9 @@ export class etemplate2
/**
* Clears the current instance.
* @param _keep_app_object keep app object
* @param _keep_session keep server-side et2 session eg. for vfs-select
*/
public clear(_keep_app_object?:boolean)
public clear(_keep_app_object?:boolean, _keep_session?: boolean)
{
jQuery(this._DOMContainer).trigger('clear');
@ -238,7 +239,7 @@ export class etemplate2
// call our destroy_session handler, if it is not already unbind, and unbind it after
if (this.destroy_session)
{
this.destroy_session();
if (!_keep_session) this.destroy_session();
this.unbind_unload();
}
if (this._widgetContainer != null)
@ -257,7 +258,7 @@ export class etemplate2
if (typeof etemplate2._byTemplate[name] == "undefined") continue;
for (let i = 0; i < etemplate2._byTemplate[name].length; i++)
{
if (etemplate2._byTemplate[name][i] == this)
if (etemplate2._byTemplate[name][i] === this)
{
etemplate2._byTemplate[name].splice(i, 1);
}
@ -1444,7 +1445,7 @@ export class etemplate2
}
// make etemplate2 global, as we need it to check an app uses it and then call methods on it
window['etemplate2'] = etemplate2;
if (typeof window.etemplate2 === 'undefined') window['etemplate2'] = etemplate2;
// Calls etemplate2_handle_response in the context of the object which
// requested the response from the server