diff --git a/modules/plugin_dbui/__init__.py b/modules/plugin_dbui/__init__.py index 90429d40227e1f46dedd3144f6b3c45ac250bbe7..51090280d1c76b5f9ed171723b0b61f5495d34ff 100755 --- a/modules/plugin_dbui/__init__.py +++ b/modules/plugin_dbui/__init__.py @@ -16,5 +16,5 @@ from helper import (get_js_files, get_script_path) from mapper import map_default, map_tabpanel from modifier import Spacer, Widget -from navtree import NodeDB +from navtree import NodeDB, NodeURL from viewportmodifier import ViewportModifier \ No newline at end of file diff --git a/modules/plugin_dbui/navtree.py b/modules/plugin_dbui/navtree.py index bbdc2e37e79bd3362207807ba795c680c48e772c..010ec811b7502ff2b175fb8a63ebdbf36f1737f9 100644 --- a/modules/plugin_dbui/navtree.py +++ b/modules/plugin_dbui/navtree.py @@ -69,7 +69,7 @@ class NodeDB(NodeBase): """ - def __init__(self, text, tables=[], widget='', hidden=[], widgets=[]): + def __init__(self, text, tables=[], widget='', hidden=[], widgets={}): T = current.T @@ -94,5 +94,47 @@ class NodeDB(NodeBase): if table in widgets: wdg = widgets[table] - self.add_children(text=tr_table, widget=wdg, tableName=table) - \ No newline at end of file + self.add_children(refName=table, text=tr_table, widget=wdg) + + +class NodeURL(NodeBase): + """Navigation node where each leaf is associated to an url. + + ExtJS widget can be associated to each leaf either globally + or individually using widget and widgets arguments respectively. + The widget identifier is its ExtJS type: xform, xgrid, ... + + Some leaf my be hidden depending on the context using hidden + argument. + + Leaves are sorted by alphabetic order. + Name of the leaf appearing in the tree are translated. + + """ + def __init__(self, text, leaves=[], url=[], widget='', hidden=[], widgets={}): + + T = current.T + + NodeBase.__init__(self, text) + + # order leaf in alphabetic order according to local setting + # the local setting is defined in the model as the time as the language + leavesCvt = {} + for el in leaves: + leavesCvt[T(el)] = leaves.index(el) + + translate_leaves = leavesCvt.keys() + translate_leaves.sort(cmp=locale.strcoll) + + # fill the node with its children + for tr_leaf in translate_leaves: + i = leavesCvt[tr_leaf] + leaf = leaves[i] + if leaf in hidden: + continue + + wdg = widget + if leaf in widgets: + wdg = widgets[leaf] + + self.add_children(refName=leaf, text=tr_leaf, url=url[i], widget=wdg) \ No newline at end of file diff --git a/static/plugin_dbui/src/appviewport.js b/static/plugin_dbui/src/appviewport.js index 6d856dacf68c24e30836b7df43c0b04e39361bb5..7cc76832ae0555a982ea4e8c6cc12b6e85169c4d 100644 --- a/static/plugin_dbui/src/appviewport.js +++ b/static/plugin_dbui/src/appviewport.js @@ -99,7 +99,7 @@ App.Viewport = Ext.extend(Ext.Viewport, { var parent = node.parentNode, panel, tabId, - tableName = node.attributes.tableName, + refName = node.attributes.refName, viewport = this, wdg, xtype = node.attributes.widget; @@ -116,7 +116,7 @@ App.Viewport = Ext.extend(Ext.Viewport, { } // generate a unique tab identifier - tabId = tableName + '/' + xtype; + tabId = refName + '/' + xtype; // activate an existing tab if (this.tabPanel.getComponent(tabId)) { @@ -135,6 +135,6 @@ App.Viewport = Ext.extend(Ext.Viewport, { this.tabPanel.setActiveTab(tabId); // add the widget in the newly created tab - Dbui.getConfiguration(tableName, xtype, addWidget); + Dbui.getConfiguration(refName, xtype, addWidget); } });