From 4708c1966501cdd70ab3c7072f53612da9ef6bfc Mon Sep 17 00:00:00 2001 From: nathan Date: Thu, 6 Apr 2023 16:14:09 -0600 Subject: [PATCH] Fix vfsSelectUI path closed dialog if you pressed enter --- api/js/etemplate/et2_widget_vfs.ts | 7 +++-- api/js/etemplate/vfsSelectUI.ts | 39 ++++++++++++++++++++++----- api/templates/default/vfsSelectUI.xet | 32 ++++++++++++++-------- 3 files changed, 58 insertions(+), 20 deletions(-) diff --git a/api/js/etemplate/et2_widget_vfs.ts b/api/js/etemplate/et2_widget_vfs.ts index f5ae87d954..18298407e1 100644 --- a/api/js/etemplate/et2_widget_vfs.ts +++ b/api/js/etemplate/et2_widget_vfs.ts @@ -1098,6 +1098,7 @@ export class et2_vfsSelect extends et2_inputWidget { this.dialog.close(); } + app.vfsSelectUI.destroy(); delete app.vfsSelectUI; } let attrs = { @@ -1136,7 +1137,8 @@ export class et2_vfsSelect extends et2_inputWidget { label: egw.lang(_data.content.label), id: "submit", - image: _data.content.mode.match(/saveas|select-dir/) ? "save" : this.options.button_icon + image: _data.content.mode.match(/saveas|select-dir/) ? "save" : this.options.button_icon, + default: false } ]; let extra_buttons_action = {}; @@ -1173,7 +1175,7 @@ export class et2_vfsSelect extends et2_inputWidget let data = jQuery.extend(_data, {'currentapp': currentApp, etemplate_exec_id: et2.etemplate_exec_id}); // define a mini app object for vfs select UI - app.vfsSelectUI = new app.classes.vfsSelectUI; + app.vfsSelectUI = et2.app_obj['vfsSelectUI'] = new app.classes.vfsSelectUI; // callback for dialog this.submit_callback = function(submit_button_id, submit_value, savemode) @@ -1277,6 +1279,7 @@ export class et2_vfsSelect extends et2_inputWidget app.vfsSelectUI.et2 = self.dialog.template.widgetContainer; app.vfsSelectUI.vfsSelectWidget = self; app.vfsSelectUI.et2_ready(app.vfsSelectUI.et2, 'api.vfsSelectUI'); + app.vfsSelectUI.et2.getInstanceManager().app_obj['vfsSelectUI'] = app.vfsSelectUI; }); this.dialog.addEventListener("close", () => { diff --git a/api/js/etemplate/vfsSelectUI.ts b/api/js/etemplate/vfsSelectUI.ts index 837184c242..a909ed028d 100644 --- a/api/js/etemplate/vfsSelectUI.ts +++ b/api/js/etemplate/vfsSelectUI.ts @@ -283,16 +283,41 @@ export class vfsSelectUI extends EgwApp */ do_action(action : string, widget : Et2Button | Et2Select | et2_vfsPath) { - if (!action) return; - let field = '', value : string|string[] = '' ; - switch (action) + if(!this.et2) { - case 'path': field = 'path'; value = (widget).getValue(); break; - case 'home': field = 'action'; value = 'home'; break; - case 'app': field = 'app'; value = (widget).getValue(); break; - case 'mime': field = 'mime'; value = (widget).getValue(); break; + // Etemplate has already gone + return; + } + if(!action && widget && widget.id) + { + action = widget.id; + } + if(!action) + { + return; + } + let field = '', value : string | string[] = ''; + switch(action) + { + case 'path': + field = 'path'; + value = (widget).getValue(); + break; + case 'home': + field = 'action'; + value = 'home'; + break; + case 'app': + field = 'app'; + value = (widget).getValue(); + break; + case 'mime': + field = 'mime'; + value = (widget).getValue(); + break; } this.submit(field, value); + return false; } /** diff --git a/api/templates/default/vfsSelectUI.xet b/api/templates/default/vfsSelectUI.xet index af23269be0..739e5735d0 100644 --- a/api/templates/default/vfsSelectUI.xet +++ b/api/templates/default/vfsSelectUI.xet @@ -12,17 +12,27 @@ - - - - - - - - - - - + + + + + + + + + + +