Home: Fix single entry did not save correctly

This commit is contained in:
nathan 2023-03-17 10:27:27 -06:00
parent e497e31ed5
commit 25207003df
2 changed files with 23 additions and 3 deletions

View File

@ -474,13 +474,22 @@ export class Et2Portlet extends Et2Widget(SlCard)
return; 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 // 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 // Extend, not replace, because settings has types while value has just value
if(typeof value == 'object') if(typeof value == 'object')
{ {
this.settings = {...this.settings, value}; this.settings = {...settings, ...value};
} }
this.requestUpdate(); this.requestUpdate();
} }
@ -500,7 +509,7 @@ export class Et2Portlet extends Et2Widget(SlCard)
{ {
this[p.name] = settings[p.name]; this[p.name] = settings[p.name];
} }
}) });
// Save settings - server might reply with new content if the portlet needs an update, // Save settings - server might reply with new content if the portlet needs an update,
// but ideally it doesn't // but ideally it doesn't

View File

@ -2,6 +2,7 @@ import {Et2Portlet} from "../../api/js/etemplate/Et2Portlet/Et2Portlet";
import shoelace from "../../api/js/etemplate/Styles/shoelace"; import shoelace from "../../api/js/etemplate/Styles/shoelace";
import {css} from "@lion/core"; import {css} from "@lion/core";
import {SelectOption} from "../../api/js/etemplate/Et2Select/FindSelectOptions"; import {SelectOption} from "../../api/js/etemplate/Et2Select/FindSelectOptions";
import {Et2Dialog} from "../../api/js/etemplate/Et2Dialog/Et2Dialog";
/** /**
* Home portlet to show a list of entries * 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"} {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")) if(!customElements.get("et2-portlet-link"))