From 4f40ef01da6109cc43f4a7d20ec53cef5c976ffa Mon Sep 17 00:00:00 2001 From: nathan Date: Fri, 17 Mar 2023 10:27:27 -0600 Subject: [PATCH] Home: Fix single entry did not save correctly --- api/js/etemplate/Et2Portlet/Et2Portlet.ts | 15 ++++++++++++--- home/js/Et2PortletLink.ts | 11 +++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/api/js/etemplate/Et2Portlet/Et2Portlet.ts b/api/js/etemplate/Et2Portlet/Et2Portlet.ts index 70d10b25f2..7f3aeffa51 100644 --- a/api/js/etemplate/Et2Portlet/Et2Portlet.ts +++ b/api/js/etemplate/Et2Portlet/Et2Portlet.ts @@ -474,13 +474,22 @@ export class Et2Portlet extends Et2Widget(SlCard) return; } + // Keep settings, but remove any properties, no need to pass those on + let settings = {}; + Object.keys(this.settings || {}).forEach(k => + { + if(typeof k == "string" && isNaN(parseInt(k)) || typeof this.settings[k].name == "undefined" && typeof this.settings[k].type == "undefined") + { + settings[k] = this.settings[k]; + } + }); // Pass updated settings, unless we're removing - this.update_settings({...this.settings, ...value}); + this.update_settings({...settings, ...value}); // Extend, not replace, because settings has types while value has just value if(typeof value == 'object') { - this.settings = {...this.settings, value}; + this.settings = {...settings, ...value}; } this.requestUpdate(); } @@ -500,7 +509,7 @@ export class Et2Portlet extends Et2Widget(SlCard) { this[p.name] = settings[p.name]; } - }) + }); // Save settings - server might reply with new content if the portlet needs an update, // but ideally it doesn't diff --git a/home/js/Et2PortletLink.ts b/home/js/Et2PortletLink.ts index a3fdf8526b..f9692d8817 100644 --- a/home/js/Et2PortletLink.ts +++ b/home/js/Et2PortletLink.ts @@ -2,6 +2,7 @@ import {Et2Portlet} from "../../api/js/etemplate/Et2Portlet/Et2Portlet"; import shoelace from "../../api/js/etemplate/Styles/shoelace"; import {css} from "@lion/core"; import {SelectOption} from "../../api/js/etemplate/Et2Select/FindSelectOptions"; +import {Et2Dialog} from "../../api/js/etemplate/Et2Dialog/Et2Dialog"; /** * Home portlet to show a list of entries @@ -29,6 +30,16 @@ export class Et2PortletLink extends Et2Portlet {name: "entry", type: "et2-link-entry", label: "Entry"} ] } + + _process_edit(button_id, value) + { + if(button_id == Et2Dialog.OK_BUTTON && value.entry && value.entry != this.settings.entry) + { + // Update title with new app immediately + this.title = this.egw().lang(value.entry.app); + } + super._process_edit(button_id, value); + } } if(!customElements.get("et2-portlet-link"))