From 80fbd3cc2675277fc5f6aea92f609e919fec46ac Mon Sep 17 00:00:00 2001 From: nathan Date: Thu, 19 Jan 2023 08:44:52 -0700 Subject: [PATCH] Fix placeholder widget IDs on et2-boxes caused unwanted namespace, Et2Listbox couldn't find its ID before fully initializing --- api/js/etemplate/Et2Select/Et2Listbox.ts | 10 +++++--- api/js/etemplate/et2_widget_placeholder.ts | 9 +++---- .../default/insert_merge_placeholder.xet | 25 ++++++++++--------- 3 files changed, 24 insertions(+), 20 deletions(-) diff --git a/api/js/etemplate/Et2Select/Et2Listbox.ts b/api/js/etemplate/Et2Select/Et2Listbox.ts index 1bea8b7c23..835d2c6fae 100644 --- a/api/js/etemplate/Et2Select/Et2Listbox.ts +++ b/api/js/etemplate/Et2Select/Et2Listbox.ts @@ -117,9 +117,13 @@ export class Et2Listbox extends RowLimitedMixin(Et2widgetWithSelectMixin(SlMenu) get value() { - let value = this.getAllItems() - .filter((item) => item.checked) - .map((item) => item.value); + let value = []; + if(this.defaultSlot) + { + value = this.getAllItems() + .filter((item) => item.checked) + .map((item) => item.value); + } return this.multiple ? value : value.pop(); } diff --git a/api/js/etemplate/et2_widget_placeholder.ts b/api/js/etemplate/et2_widget_placeholder.ts index a1116f6431..57b37933d1 100644 --- a/api/js/etemplate/et2_widget_placeholder.ts +++ b/api/js/etemplate/et2_widget_placeholder.ts @@ -136,11 +136,10 @@ export class et2_placeholder_select extends et2_inputWidget content: {app: '', group: '', entry: {}}, sel_options: {app: [], group: []}, modifications: { - outer_box: { entry: { application_list: [] } - } + } }; @@ -156,13 +155,13 @@ export class et2_placeholder_select extends et2_inputWidget data.content.app = data.sel_options.app[0].value; data.content.group = data.sel_options.group[0]?.value; data.content.entry = {app: data.content.app}; - data.modifications.outer_box.entry.application_list = Object.keys(_data); + data.modifications.entry.application_list = Object.keys(_data); // Remove non-app placeholders (user & general) let non_apps = ['user', 'general']; for(let i = 0; i < non_apps.length; i++) { - let index = data.modifications.outer_box.entry.application_list.indexOf(non_apps[i]); - data.modifications.outer_box.entry.application_list.splice(index, 1); + let index = data.modifications.entry.application_list.indexOf(non_apps[i]); + data.modifications.entry.application_list.splice(index, 1); } // callback for dialog diff --git a/api/templates/default/insert_merge_placeholder.xet b/api/templates/default/insert_merge_placeholder.xet index 605965b113..62938e19ea 100644 --- a/api/templates/default/insert_merge_placeholder.xet +++ b/api/templates/default/insert_merge_placeholder.xet @@ -2,18 +2,19 @@