Skip to content

Commit

Permalink
Appease coding standard
Browse files Browse the repository at this point in the history
  • Loading branch information
fredden committed Nov 25, 2022
1 parent a3f60e1 commit b94ee40
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions app/code/Magento/User/view/adminhtml/web/js/roles-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ define([
const $tree = $.jstree.reference(this.element),
collapseAllButton = document.createElement('button'),
expandAllButton = document.createElement('button'),
expandUsedButton = document.createElement('button');
expandUsedButton = document.createElement('button'),
parent = this.element[0],
ul = this.element.find('ul')[0];

collapseAllButton.innerText = $.mage.__('Collapse all');
collapseAllButton.addEventListener('click', function () {
Expand All @@ -62,11 +64,13 @@ define([
expandUsedButton.innerText = $.mage.__('Expand selected');
expandUsedButton.addEventListener('click', function () {
const hasOpened = [];

$tree.get_checked(true).forEach(function (node) {
$tree.open_node(node);
hasOpened.push(node.id);
for (let i = 0; i < node.parents.length - 1; i++) {
const id = node.parents[i];

if (!hasOpened.includes(id)) {
$tree.open_node($tree.get_node(id));
hasOpened.push(id);
Expand All @@ -78,12 +82,9 @@ define([
this.buttons = [
collapseAllButton,
expandAllButton,
expandUsedButton,
expandUsedButton
];

const parent = this.element[0],
ul = this.element.find('ul')[0];

this.buttons.forEach(function (button) {
button.type = 'button';
parent.insertBefore(button, ul);
Expand Down

0 comments on commit b94ee40

Please sign in to comment.