WIP allowing to speard custom fields optionally to dynamic generated tabs

This commit is contained in:
ralf 2024-03-21 10:28:27 +02:00
parent 91f70e354d
commit 5352972e2a
4 changed files with 11 additions and 10 deletions

View File

@ -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),

View File

@ -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;
}
}
}

View File

@ -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;

View File

@ -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'],
);