Home: Restore ability to manually add to list portlet

Now just using the properties dialog to add
This commit is contained in:
nathan 2023-03-14 09:14:15 -06:00
parent a71229cd48
commit b09c6e804f
3 changed files with 40 additions and 3 deletions

View File

@ -411,12 +411,23 @@ export class Et2Portlet extends Et2Widget(SlCard)
*/ */
edit_settings() edit_settings()
{ {
let content = this.portletProperties;
// Add values, but skip any lingering properties
Object.keys(this.settings).forEach(k =>
{
if(typeof k == "string" && isNaN(parseInt(k)))
{
content[k] = this.settings[k];
}
});
let dialog = new Et2Dialog(this.egw()); let dialog = new Et2Dialog(this.egw());
dialog.transformAttributes({ dialog.transformAttributes({
callback: this._process_edit.bind(this), callback: this._process_edit.bind(this),
template: this.editTemplate, template: this.editTemplate,
value: { value: {
content: {...this.settings, ...this.portletProperties} content: content
}, },
buttons: [ buttons: [
{ {

View File

@ -200,7 +200,7 @@ class home_ui
$settings = $portlet->get_properties(); $settings = $portlet->get_properties();
foreach($settings as $key => $setting) foreach($settings as $key => $setting)
{ {
if(is_array($setting) && !array_key_exists('type', $setting)) if(is_array($setting) && !array_key_exists('type', $setting) || is_numeric($key))
{ {
unset($settings[$key]); unset($settings[$key]);
} }

View File

@ -2,6 +2,8 @@ import {Et2Portlet} from "../../api/js/etemplate/Et2Portlet/Et2Portlet";
import {et2_createWidget} from "../../api/js/etemplate/et2_core_widget"; import {et2_createWidget} from "../../api/js/etemplate/et2_core_widget";
import {css, html, TemplateResult} from "@lion/core"; import {css, html, TemplateResult} from "@lion/core";
import shoelace from "../../api/js/etemplate/Styles/shoelace"; import shoelace from "../../api/js/etemplate/Styles/shoelace";
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
@ -147,7 +149,7 @@ export class Et2PortletList extends Et2Portlet
{ {
return; return;
} }
// Not used, but delete puts link in event.data // Not used, but delete puts link in event.data
let link_data = event.data || false; let link_data = event.data || false;
@ -158,6 +160,30 @@ export class Et2PortletList extends Et2Portlet
} }
} }
/**
* Get a list of user-configurable properties
* @returns {[{name : string, type : string, select_options? : [SelectOption]}]}
*/
get portletProperties() : { name : string, type : string, label : string, select_options? : SelectOption[] }[]
{
return [
...super.portletProperties,
{name: "title", type: "et2-textbox", label: "Title"},
{name: "add", type: "et2-link-entry", label: "Add"}
]
}
_process_edit(button_id, value)
{
if(button_id == Et2Dialog.OK_BUTTON && value.add)
{
// Add in to list, remove from value or it will be saved
value.list = [...this.settings.list, value.add];
delete value.add;
}
super._process_edit(button_id, value);
}
bodyTemplate() : TemplateResult bodyTemplate() : TemplateResult
{ {
return html` return html`