From 5352972e2ad77819551b6bcb6a2e782d9a0e2886 Mon Sep 17 00:00:00 2001 From: ralf Date: Thu, 21 Mar 2024 10:28:27 +0200 Subject: [PATCH] WIP allowing to speard custom fields optionally to dynamic generated tabs --- api/js/etemplate/Layout/Et2Tabs/Et2Tabs.ts | 6 +----- api/js/etemplate/et2_extension_customfields.ts | 10 +++++++--- api/src/Etemplate/Widget/Customfields.php | 4 ++-- preferences/inc/class.preferences_settings.inc.php | 1 + 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/api/js/etemplate/Layout/Et2Tabs/Et2Tabs.ts b/api/js/etemplate/Layout/Et2Tabs/Et2Tabs.ts index 714ceed841..c80d89bad6 100644 --- a/api/js/etemplate/Layout/Et2Tabs/Et2Tabs.ts +++ b/api/js/etemplate/Layout/Et2Tabs/Et2Tabs.ts @@ -186,11 +186,7 @@ export class Et2Tabs extends Et2InputWidget(SlTabGroup) implements et2_IResizeab { let tab = this.extraTabs[i]; let tab_id = tab.id || tab.template; - let tab_options = {id: tab_id, template: tab.template, url: tab.url, content: undefined}; - if(tab.id) - { - tab_options.content = tab.id; - } + let tab_options = {id: tab_id, template: tab.template, url: tab.url, content: tab.content}; tabData[tab.prepend ? 'unshift' : 'push'].call(tabData, { "id": tab_id, "label": this.egw().lang(tab.label), diff --git a/api/js/etemplate/et2_extension_customfields.ts b/api/js/etemplate/et2_extension_customfields.ts index becd4ee419..7d5060a382 100644 --- a/api/js/etemplate/et2_extension_customfields.ts +++ b/api/js/etemplate/et2_extension_customfields.ts @@ -165,17 +165,17 @@ export class et2_customfields_list extends et2_valueWidget implements et2_IDetac if(jQuery.inArray(types[i],this.options.type_filter) > -1) { this.options.fields[field_name] = true; - } } } } - // filter fields by tab attribute + // tab === "panel" --> use label of tab panel if (this.options.tab === 'panel') { this.options.tab = Et2Tabs.getTabPanel(this, true); } + // filter fields additionally by tab attribute if (typeof this.options.fields === "undefined" || !Object.keys(this.options.fields).length) { this.options.fields = {}; @@ -193,7 +193,11 @@ export class et2_customfields_list extends et2_valueWidget implements et2_IDetac { if (this.options.customfields[field_name].tab !== this.options.tab) { - delete this.options.fields[field_name]; + this.options.fields[field_name] = false; + } + else if (this.options.tab) + { + this.options.fields[field_name] = true; } } } diff --git a/api/src/Etemplate/Widget/Customfields.php b/api/src/Etemplate/Widget/Customfields.php index ba4153bcb1..9cb44faa73 100644 --- a/api/src/Etemplate/Widget/Customfields.php +++ b/api/src/Etemplate/Widget/Customfields.php @@ -481,9 +481,9 @@ class Customfields extends Transformer { foreach(array_keys($value_in) as $field) { - $field_settings = $customfields[$fname = substr($field, strlen($this->attrs['prefix']))]; + $field_settings = $customfields[$fname = substr($field, strlen($this->attrs['prefix']))] ?? null; - if((string)$use_private !== '' && // are only (non-)private fields requested + if(!isset($field_settings) || (string)$use_private !== '' && // are only (non-)private fields requested (boolean)$field_settings['private'] != ($use_private != '0')) { continue; diff --git a/preferences/inc/class.preferences_settings.inc.php b/preferences/inc/class.preferences_settings.inc.php index 704352d7e6..3219676534 100644 --- a/preferences/inc/class.preferences_settings.inc.php +++ b/preferences/inc/class.preferences_settings.inc.php @@ -451,6 +451,7 @@ class preferences_settings $tab = 'tab'.(1+count($tabs)); $tabs[] = array( 'id' => $tab, + 'content' => $tab, 'template' => 'preferences.settings.tab1', 'label' => $setting['title'], );