mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-27 09:09:04 +01:00
WIP allow to place custom-fields in tabs: cfExclude option to et2-tabs to exclude cfs from the tabs e.g. to place them separate into the template
This commit is contained in:
parent
2e37f9bd34
commit
dedaa29204
@ -42,6 +42,12 @@ export class et2_customfields_list extends et2_valueWidget implements et2_IDetac
|
||||
'description': 'Auto filled',
|
||||
'type': 'any'
|
||||
},
|
||||
exclude: {
|
||||
name: 'Fields to exclude',
|
||||
description: 'comma-separated list of fields to exclude',
|
||||
type: 'string',
|
||||
default: undefined,
|
||||
},
|
||||
'value': {
|
||||
'name': 'Custom fields',
|
||||
'description': 'Auto filled',
|
||||
@ -183,12 +189,14 @@ export class et2_customfields_list extends et2_valueWidget implements et2_IDetac
|
||||
this.options.tab = Et2Tabs.getTabPanel(this, true);
|
||||
}
|
||||
}
|
||||
const exclude : Array<string> = this.options.exclude ? this.options.exclude.split(',') : [];
|
||||
// filter fields additionally by tab attribute
|
||||
if (typeof this.options.fields === "undefined" || !Object.keys(this.options.fields).length)
|
||||
{
|
||||
this.options.fields = {};
|
||||
for(let field_name in this.options.customfields)
|
||||
{
|
||||
if (exclude.indexOf(field_name) >= 0) continue;
|
||||
if (this.options.customfields[field_name].tab === this.options.tab)
|
||||
{
|
||||
this.options.fields[field_name] = true;
|
||||
@ -210,7 +218,11 @@ export class et2_customfields_list extends et2_valueWidget implements et2_IDetac
|
||||
{
|
||||
for(let field_name in this.options.customfields)
|
||||
{
|
||||
if (default_tab ? this.options.customfields[field_name].tab : this.options.customfields[field_name].tab !== this.options.tab)
|
||||
if (exclude.indexOf(field_name) >= 0)
|
||||
{
|
||||
this.options.fields[field_name] = false;
|
||||
}
|
||||
else if (default_tab ? this.options.customfields[field_name].tab : this.options.customfields[field_name].tab !== this.options.tab)
|
||||
{
|
||||
this.options.fields[field_name] = false;
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ use EGroupware\Api;
|
||||
* - cfTypeFilter: optional type-filter for automatic created custom-fields tabs
|
||||
* - cfPrivateTab: true: create an extra tab for private custom-fields, false (default): show private ones together with non-private ones
|
||||
* - cfPrepend: value for prepend tab-attribute for dynamic generated custom-field tabs, default "history"
|
||||
* - cfExclude: custom fields to exclude, comma-separated, to list fields added e.g. manually to the template
|
||||
*/
|
||||
class Tabbox extends Etemplate\Widget
|
||||
{
|
||||
@ -161,9 +162,16 @@ class Tabbox extends Etemplate\Widget
|
||||
// check if template still contains a legacy customfield tab
|
||||
$have_legacy_cf_tab = $this->haveLegacyCfTab();
|
||||
|
||||
$exclude = self::getElementAttribute($form_name, 'cfExclude') ?? $this->attrs['cfExclude'] ?? null;
|
||||
$exclude = $exclude ? explode(',', $exclude) : [];
|
||||
|
||||
$tabs = $private_tab = $default_tab = [];
|
||||
foreach($cfs as $cf)
|
||||
{
|
||||
if (in_array($cf['name'], $exclude))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (!empty($cf['tab']))
|
||||
{
|
||||
$tab = $tabs[$cf['tab']]['id'] ?? 'cf-tab'.(1+count($tabs));
|
||||
@ -215,6 +223,13 @@ class Tabbox extends Etemplate\Widget
|
||||
$content['cfTypeFilter'] = self::expand_name($type_filter, 0, 0, 0, 0, $content);
|
||||
self::$request->content = $content;
|
||||
}
|
||||
// pass cfExclude attribute via content to all customfields widgets (set in api.cf-tab template)
|
||||
if ($exclude)
|
||||
{
|
||||
$content = self::$request->content;
|
||||
$content['cfExclude'] = implode(',', $exclude);
|
||||
self::$request->content = $content;
|
||||
}
|
||||
|
||||
// addTabs is default false (= replace tabs), we need a default of true
|
||||
$add_tabs =& self::setElementAttribute($this->id, 'addTabs', null);
|
||||
|
@ -2,6 +2,6 @@
|
||||
<!DOCTYPE overlay PUBLIC "-//EGroupware GmbH//eTemplate 2.0//EN" "https://www.egroupware.org/etemplate2.0.dtd">
|
||||
<overlay>
|
||||
<template id="api.cf-tab" template="" lang="" group="0" version="23.1">
|
||||
<customfields tab="panel" type_filter="@cfTypeFilter"/>
|
||||
<customfields tab="panel" type_filter="@cfTypeFilter" exclude="@cfExclude"/>
|
||||
</template>
|
||||
</overlay>
|
Loading…
Reference in New Issue
Block a user