diff --git a/phpgwapi/js/egw_action/egw_action.js b/phpgwapi/js/egw_action/egw_action.js index 8fc97d63ef..bf854ec25c 100644 --- a/phpgwapi/js/egw_action/egw_action.js +++ b/phpgwapi/js/egw_action/egw_action.js @@ -54,6 +54,8 @@ function egwAction(_parent, _id, _caption, _iconUrl, _onExecute, _allowOnMultipl this.iconUrl = _iconUrl; this.allowOnMultiple = _allowOnMultiple; this.enabled = true; + this.hideOnDisabled = false; + this.data = null; // Data which can be freely assigned to the action this.type = "default"; //All derived classes have to override this! this.canHaveChildren = false; //Has to be overwritten by inherited action classes @@ -271,12 +273,21 @@ egwAction.prototype.set_allowOnMultiple = function(_value) this.allowOnMultiple = _value; } +egwAction.prototype.set_hideOnDisabled = function(_value) +{ + this.hideOnDisabled = _value; +} + +egwAction.prototype.set_data = function(_value) +{ + this.data = _value; +} + egwAction.prototype.updateAction = function(_data) { egwActionStoreJSON(_data, this, true); } - function _egwActionTreeContains(_tree, _elem) { for (var i = 0; i < _tree.length; i++) @@ -1354,7 +1365,7 @@ egwActionObject.prototype.getSelectedLinks = function(_actionType) var llink = actionLinks[olink.actionId]; llink.enabled = olink.actionObj.enabled && llink.enabled && olink.enabled && olink.visible; - llink.visible = llink.visible || olink.visible; + llink.visible = (llink.visible || olink.visible); llink.cnt++; } } @@ -1368,6 +1379,8 @@ egwActionObject.prototype.getSelectedLinks = function(_actionType) (actionLinks[k].cnt >= testedSelected.length) && (actionLinks[k].actionObj.allowOnMultiple || actionLinks[k].cnt == 1); + actionLinks[k].visible = actionLinks[k].visible && + (actionLinks[k].enabled || !actionLinks[k].actionObj.hideOnDisabled); } // Return an object which contains the accumulated actionLinks and all selected diff --git a/phpgwapi/js/egw_action/egw_action_popup.js b/phpgwapi/js/egw_action/egw_action_popup.js index a9f261c43b..7f36c10444 100644 --- a/phpgwapi/js/egw_action/egw_action_popup.js +++ b/phpgwapi/js/egw_action/egw_action_popup.js @@ -256,13 +256,11 @@ function egwPopupActionImplementation() */ ai._buildMenuLayer = function(_menu, _groups, _selected, _enabled) { + var firstGroup = true; + for (var i = 0; i < _groups.length; i++) { - // Add an seperator after each group - if (i != 0) - { - _menu.addItem("", "-"); - } + var firstElem = true; // Go through the elements of each group for (var j = 0; j < _groups[i].length; j++) @@ -271,6 +269,14 @@ function egwPopupActionImplementation() if (link.visible) { + + // Add an seperator after each group + if (!firstGroup && firstElem) + { + _menu.addItem("", "-"); + } + firstElem = false; + var item = _menu.addItem(link.actionObj.id, link.actionObj.caption, link.actionObj.iconUrl); item["default"] = link.actionObj["default"]; @@ -293,6 +299,8 @@ function egwPopupActionImplementation() } } } + + firstGroup = firstGroup && firstElem; } }