From 3105054be0e50115b26bded7781e5e781adda0ad Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Thu, 20 Feb 2014 18:04:04 +0000 Subject: [PATCH] Fix toolbar default actions for flat_list toolbar --- etemplate/js/et2_widget_toolbar.js | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/etemplate/js/et2_widget_toolbar.js b/etemplate/js/et2_widget_toolbar.js index b55d3d08d0..e53524f433 100644 --- a/etemplate/js/et2_widget_toolbar.js +++ b/etemplate/js/et2_widget_toolbar.js @@ -110,7 +110,8 @@ var et2_toolbar = et2_DOMWidget.extend( { for (var name in actions) { - if (!actions[name].toolbarDefault) + if (!actions[name].toolbarDefault && + (typeof actions[name].children === 'undefined' || !this.flat_list)) this.set_prefered(actions[name].id,'add'); } } @@ -135,7 +136,7 @@ var et2_toolbar = et2_DOMWidget.extend( returnCounter = count; } return returnCounter; - } + }; for (var nAction in actions) { if (that.flat_list) @@ -148,7 +149,7 @@ var et2_toolbar = et2_DOMWidget.extend( } } return totalCount; - } + }; this.countActions = countActions(actions) - Object.keys(this.preference).length; @@ -196,8 +197,15 @@ var et2_toolbar = et2_DOMWidget.extend( if (that.flat_list) { childaction = root.children[id]; - if (typeof root.children[id].group != 'undefined' && - typeof root.group != 'undefined') + if (typeof pref === 'undefined') + { + if (!childaction.toolbarDefault) + { + that.set_prefered(childaction.id,'add'); + } + } + if (typeof root.children[id].group !== 'undefined' && + typeof root.group !== 'undefined') { childaction.group = root.group; } @@ -359,7 +367,7 @@ var et2_toolbar = et2_DOMWidget.extend( { if ((this.countActions <= parseInt(this.view_range) || this.preference[action.id]) && - typeof button[0] != 'undefined') + typeof button[0] !== 'undefined') { button[0].textContent = action.caption; }