Skip to content

Commit

Permalink
Merge pull request #5177 from camptocamp/rm_ExclusiveGroupSingleChecked
Browse files Browse the repository at this point in the history
Remove manageExclusiveGroupSingleChecked_ function
  • Loading branch information
fredj committed Sep 27, 2019
2 parents e70b584 + 11c142a commit 739ab3d
Showing 1 changed file with 0 additions and 38 deletions.
38 changes: 0 additions & 38 deletions contribs/gmf/src/layertree/TreeManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,47 +303,9 @@ LayertreeTreeManager.prototype.addFirstLevelGroup_ = function(group) {
this.promiseForGroupsToAddInThisDigestLoop_ = null;
});

// If the group has the `exclusiveGroup` property set, then make
// sure that only one of its children can be checked,
// i.e. 'visible'.
if (group.metadata.exclusiveGroup) {
this.manageExclusiveGroupSingleChecked_(group, false);
}

return true;
};

/**
* Loop in the children of a node. Make sure that only one of them can
* be checked. If a child also have children, include them in the loop
* as well.
*
* @param {import('gmf/themes.js').GmfGroup|import('gmf/themes.js').GmfLayer} node Group or layer node
* @param {boolean} found Whether a checked node was already found or not.
* @return {boolean} Whether a checked node was already found or not.
* @private
*/
LayertreeTreeManager.prototype.manageExclusiveGroupSingleChecked_ = function(node, found) {
const groupNode = /** @type import('gmf/themes.js').GmfGroup */ (node);
const children = groupNode.children;
if (children) {
for (const child of children) {
const childGroup = /** @type import('gmf/themes.js').GmfGroup */ (child);
if (childGroup.children) {
found = this.manageExclusiveGroupSingleChecked_(childGroup, found);
} else {
if (child.metadata.isChecked) {
if (found) {
child.metadata.isChecked = false;
} else {
found = true;
}
}
}
}
}
return found;
};

/**
* Retrieve a group (first found) by its name and add in the tree. Do nothing
Expand Down

0 comments on commit 739ab3d

Please sign in to comment.