From cd2f674b7ed15db78d55051ec3a0bdaa904779b5 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Mon, 9 Jul 2012 21:26:24 +0000 Subject: [PATCH] Allow apps to add tabs through modifications array --- etemplate/js/et2_widget_tabs.js | 38 +++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/etemplate/js/et2_widget_tabs.js b/etemplate/js/et2_widget_tabs.js index 515847451a..ac09b60d9e 100644 --- a/etemplate/js/et2_widget_tabs.js +++ b/etemplate/js/et2_widget_tabs.js @@ -23,6 +23,14 @@ */ var et2_tabbox = et2_DOMWidget.extend({ + attributes: { + 'tabs': { + 'name': 'Tabs', + 'default': et2_no_init, + 'description': "Array of [extra] tabs. Each tab needs {label:..., template:...}" + } + }, + /** * Currently selected tab */ @@ -143,6 +151,22 @@ var et2_tabbox = et2_DOMWidget.extend({ // Read and create the widgets defined in the "tabpanels" this._readTabPanels(tabData, tabpanels); + // Add any extra tabs + if(this.options.tabs) + { + for(var i = 0; i < this.options.tabs.length; i++) + { + var tab = this.options.tabs[i]; + tabData.push({ + "label": this.egw().lang(tab.label), + "widget": et2_createWidget('template',{id:tab.template},this), + "contentDiv": null, + "flagDiv": null, + "hidden": false + }); + } + } + // Create the tab DOM-Nodes this.createTabs(tabData) } @@ -152,6 +176,20 @@ var et2_tabbox = et2_DOMWidget.extend({ } }, + /** + * Check for custom tabs + */ + transformAttributes: function(_attrs) { + this._super.apply(this, arguments); + + // Add in settings that are objects + var data = this.getArrayMgr("modifications").getEntry(this.id); + for(var key in data) + { + if(typeof data[key] === 'object' && ! _attrs[key]) _attrs[key] = data[key]; + } + }, + createTabs: function(tabData) { this.tabData = tabData;