mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-08-19 04:46:42 +02:00
WIP allow to place custom-fields in specified tabs and automatic tab generation
- no more need to add custom-field tabs to the template, if a et2-tabs is used - new custom-field options for et2-tabs: + cfTypeFilter propagated to type_filter of customfields widget + cfPrivateTab use an extra tab for private cfs + cfPrepend where to add cf tabs, default before history tab or at the end, if no history tab
This commit is contained in:
@@ -186,8 +186,20 @@ 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: tab.content};
|
||||
tabData[tab.prepend ? 'unshift' : 'push'].call(tabData, {
|
||||
let tab_options = {id: tab_id, template: tab.template, url: tab.url, content: tab.content, title: tab.statustext};
|
||||
let pos = tabData.length;
|
||||
if (typeof tab.prepend === "string")
|
||||
{
|
||||
if ((pos = tabData.findIndex(t => t.id === tab.prepend)) === -1)
|
||||
{
|
||||
pos = tabData.length;
|
||||
}
|
||||
}
|
||||
else if (tab.prepend)
|
||||
{
|
||||
pos = 0;
|
||||
}
|
||||
tabData.splice(pos, 0, {
|
||||
"id": tab_id,
|
||||
"label": this.egw().lang(tab.label),
|
||||
"widget": null,
|
||||
@@ -543,10 +555,10 @@ export class Et2Tabs extends Et2InputWidget(SlTabGroup) implements et2_IResizeab
|
||||
* get tab panel-name or label the given widget is in
|
||||
*
|
||||
* @param widget
|
||||
* @param label true: return label, otherwise return panel-name
|
||||
* @param label true: return label, otherwise return panel-name / id
|
||||
* @return string panel-name or undefined
|
||||
*/
|
||||
static getTabPanel(widget, label)
|
||||
static getTabPanel(widget, label? : boolean) : string|undefined
|
||||
{
|
||||
let tab = widget;
|
||||
while(tab._parent && tab._parent.nodeName !== 'ET2-TABBOX')
|
||||
|
@@ -171,9 +171,17 @@ export class et2_customfields_list extends et2_valueWidget implements et2_IDetac
|
||||
}
|
||||
|
||||
// tab === "panel" --> use label of tab panel
|
||||
const default_tab = Et2Tabs.getTabPanel(this)?.match(/^cf-default(-(non-)?private)?$/);
|
||||
if (this.options.tab === 'panel')
|
||||
{
|
||||
this.options.tab = Et2Tabs.getTabPanel(this, true);
|
||||
if (default_tab)
|
||||
{
|
||||
this.options.tab = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
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)
|
||||
@@ -185,17 +193,39 @@ export class et2_customfields_list extends et2_valueWidget implements et2_IDetac
|
||||
{
|
||||
this.options.fields[field_name] = true;
|
||||
}
|
||||
else if (default_tab)
|
||||
{
|
||||
if (this.options.customfields[field_name].private.length) // private cf
|
||||
{
|
||||
this.options.fields[field_name] = default_tab[1] !== '-non-private';
|
||||
}
|
||||
else // non-private cf
|
||||
{
|
||||
this.options.fields[field_name] = default_tab[1] !== '-private';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(let field_name in this.options.customfields)
|
||||
{
|
||||
if (this.options.customfields[field_name].tab !== this.options.tab)
|
||||
if (default_tab ? this.options.customfields[field_name].tab : this.options.customfields[field_name].tab !== this.options.tab)
|
||||
{
|
||||
this.options.fields[field_name] = false;
|
||||
}
|
||||
else if (this.options.tab)
|
||||
else if (default_tab)
|
||||
{
|
||||
if (this.options.customfields[field_name].private.length) // private cf
|
||||
{
|
||||
this.options.fields[field_name] = default_tab[1] !== '-non-private';
|
||||
}
|
||||
else // non-private cf
|
||||
{
|
||||
this.options.fields[field_name] = default_tab[1] !== '-private';
|
||||
}
|
||||
}
|
||||
else if (this.options.customfields[field_name].tab === this.options.tab)
|
||||
{
|
||||
this.options.fields[field_name] = true;
|
||||
}
|
||||
@@ -326,6 +356,7 @@ export class et2_customfields_list extends et2_valueWidget implements et2_IDetac
|
||||
// Label in first column, widget in 2nd
|
||||
const label = this.options.label || field.label || '';
|
||||
jQuery(document.createElement("td"))
|
||||
.attr('colspan', (attrs.type || field.type) === 'label' ? 2 : 1)
|
||||
.prependTo(row);
|
||||
et2_createWidget("label", {id: id + "_label", value: label.trim(), for: id}, this);
|
||||
}
|
||||
|
Reference in New Issue
Block a user