From 72e5c43a965efbc950e47bd54434635eefe502d0 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Wed, 4 Sep 2013 19:09:48 +0000 Subject: [PATCH] Add child action visbile/enabled checking - previously children were always enabled --- phpgwapi/js/egw_action/egw_action.js | 63 ++++++++++++++++++---------- 1 file changed, 41 insertions(+), 22 deletions(-) diff --git a/phpgwapi/js/egw_action/egw_action.js b/phpgwapi/js/egw_action/egw_action.js index ce3db18aca..088f5e29a1 100644 --- a/phpgwapi/js/egw_action/egw_action.js +++ b/phpgwapi/js/egw_action/egw_action.js @@ -1894,6 +1894,46 @@ egwActionObject.prototype._getLinks = function(_objs, _actionType) { var actionLinks = {}; var testedSelected = []; + + var test = function(olink) + { + // Test whether the action type is of the given implementation type + if (olink.actionObj.type == _actionType) + { + if (typeof actionLinks[olink.actionId] == "undefined") + { + actionLinks[olink.actionId] = { + "actionObj": olink.actionObj, + "enabled": (testedSelected.length == 1), + "visible": false, + "cnt": 0 + } + } + + // Accumulate the action link properties + var llink = actionLinks[olink.actionId]; + llink.enabled = llink.enabled && olink.actionObj.enabled.exec(olink.actionObj, _objs, _objs[i]) && + olink.enabled && olink.visible; + llink.visible = (llink.visible || olink.visible); + llink.cnt++; + + // Add in children, so they can get checked for visible / enabled + if(olink.actionObj && olink.actionObj.children.length > 0) + { + for(var j = 0; j < olink.actionObj.children.length; j++) + { + var child = olink.actionObj.children[j]; + test({ + actionObj: child, + actionId: child.id, + enabled: olink.enabled, + visible: olink.visible + }); + } + } + } + }; + for (var i = 0; i < _objs.length; i++) { var obj = _objs[i]; @@ -1903,28 +1943,7 @@ egwActionObject.prototype._getLinks = function(_objs, _actionType) for (var j = 0; j < obj.actionLinks.length; j++) { - var olink = obj.actionLinks[j]; //object link - - // Test whether the action type is of the given implementation type - if (olink.actionObj.type == _actionType) - { - if (typeof actionLinks[olink.actionId] == "undefined") - { - actionLinks[olink.actionId] = { - "actionObj": olink.actionObj, - "enabled": (testedSelected.length == 1), - "visible": false, - "cnt": 0 - } - } - - // Accumulate the action link properties - var llink = actionLinks[olink.actionId]; - llink.enabled = llink.enabled && olink.actionObj.enabled.exec(olink.actionObj, _objs, _objs[i]) && - olink.enabled && olink.visible; - llink.visible = (llink.visible || olink.visible); - llink.cnt++; - } + test(obj.actionLinks[j]); //object link } } }