Skip to content

Commit

Permalink
ENGCOM-3174: [2.2] added component status based filtering magento#18561
Browse files Browse the repository at this point in the history
  • Loading branch information
Stanislav Idolov authored Oct 17, 2018
2 parents 1ab485e + b7946b1 commit eb1f5f2
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion app/code/Magento/Ui/view/base/web/js/core/renderer/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ define([
*/
build: function (parent, node, name) {
var defaults = parent && parent.childDefaults || {},
children = node.children,
children = this.filterDisabledChildren(node.children),
type = getNodeType(parent, node),
dataScope = getDataScope(parent, node),
component,
Expand Down Expand Up @@ -294,6 +294,35 @@ define([
return node;
},

/**
* Filter out all disabled components.
*
* @param {Object} children
* @returns {*}
*/
filterDisabledChildren: function (children) {
var cIds;

//cleanup children config.componentDisabled = true
if (children && typeof children === 'object') {
cIds = Object.keys(children);

if (cIds) {
_.each(cIds, function (cId) {
if (typeof children[cId] === 'object' &&
children[cId].hasOwnProperty('config') &&
typeof children[cId].config === 'object' &&
children[cId].config.hasOwnProperty('componentDisabled') &&
children[cId].config.componentDisabled === true) {
delete children[cId];
}
});
}
}

return children;
},

/**
* Init component.
*
Expand Down

0 comments on commit eb1f5f2

Please sign in to comment.