diff --git a/etemplate/js/et2_widget_toolbar.js b/etemplate/js/et2_widget_toolbar.js
index 634158e850..396aad2431 100644
--- a/etemplate/js/et2_widget_toolbar.js
+++ b/etemplate/js/et2_widget_toolbar.js
@@ -100,7 +100,8 @@ var et2_toolbar = et2_DOMWidget.extend(
this.actionlist.empty();
this.actionbox.append('');
this.actionbox.append('
');
-
+ var that = this;
+
var pref = egw.preference(this.id,this.egw().getAppName());
if (pref && !jQuery.isArray(pref)) this.preference = pref;
@@ -114,7 +115,43 @@ var et2_toolbar = et2_DOMWidget.extend(
}
}
- this.countActions = Object.keys(actions).length - Object.keys(this.preference).length;
+ //Count number of actions including their children
+ var countActions = function (actions)
+ {
+ var totalCount = 0;
+ var childCounter = function (action, count)
+ {
+ var children = action.children || 0,
+ returnCounter = count || 0;
+ if (children)
+ {
+ returnCounter -= 1;
+ for (var nChild in children)
+ returnCounter += 1;
+ returnCounter = childCounter (children[nChild], returnCounter);
+ }
+ else
+ {
+ returnCounter = count;
+ }
+ return returnCounter;
+ }
+ for (var nAction in actions)
+ {
+ if (that.flat_list)
+ {
+ totalCount += childCounter(actions[nAction],1);
+ }
+ else
+ {
+ totalCount ++;
+ }
+ }
+ return totalCount;
+ }
+
+ this.countActions = countActions(actions) - Object.keys(this.preference).length;
+
var last_group = false;
var last_group_id = false;
for(var name in actions)
@@ -227,7 +264,7 @@ var et2_toolbar = et2_DOMWidget.extend(
var toolbar =jQuery('#'+this.id+'-'+'actionlist').find('button'),
toolbox = jQuery('#'+this.id+'-'+'actionbox'),
menulist = jQuery('#'+this.id+'-'+'menulist');
- var that = this;
+
toolbar.draggable({
cancel:true,
zIndex: 1000,