WIP allow to place custom-fields in tabs: fix type-filter was not used

This commit is contained in:
ralf 2024-03-25 19:52:21 +02:00
parent e3b3078066
commit fd77467b9c
2 changed files with 10 additions and 4 deletions

View File

@ -232,7 +232,7 @@ export class et2_customfields_list extends et2_valueWidget implements et2_IDetac
{
this.options.fields[field_name] = default_tab[1] !== '-non-private';
}
else // non-private cf
else if (this.options.fields[field_name]) // non-private cf
{
this.options.fields[field_name] = default_tab[1] !== '-private';
}

View File

@ -169,10 +169,16 @@ class Tabbox extends Etemplate\Widget
$exclude = self::getElementAttribute($form_name, 'cfExclude') ?? $this->attrs['cfExclude'] ?? null;
$exclude = $exclude ? explode(',', $exclude) : [];
$type_filter = self::expand_name(self::getElementAttribute($form_name, 'cfTypeFilter') ?? $this->attrs['cfTypeFilter'] ?? null,
0, 0, 0, 0, self::$request->content);
$type_filter = $type_filter ? explode(',', $type_filter) : [];
$tabs = $private_tab = $default_tab = [];
foreach($cfs as $cf)
{
if (in_array($cf['name'], $exclude))
// if excluded or wrong type --> ignore
if (in_array($cf['name'], $exclude) ||
$type_filter && $cf['type2'] && !array_intersect($cf['type2'], $type_filter))
{
continue;
}
@ -221,10 +227,10 @@ class Tabbox extends Etemplate\Widget
if ($tabs || $default_tab || $private_tab)
{
// pass given cfTypeFilter attribute via content to all customfields widgets (set in api.cf-tab template)
if (($type_filter = self::getElementAttribute($form_name, 'cfTypeFilter') ?? $this->attrs['cfTypeFilter'] ?? null))
if ($type_filter)
{
$content = self::$request->content;
$content['cfTypeFilter'] = self::expand_name($type_filter, 0, 0, 0, 0, $content);
$content['cfTypeFilter'] = implode(',', $type_filter);
self::$request->content = $content;
}
// pass cfExclude attribute via content to all customfields widgets (set in api.cf-tab template)