Skip to content

Commit 4a7b13e

Browse files
committed
chore: Rewrite logic for activeColumns
1 parent 8b2a221 commit 4a7b13e

1 file changed

Lines changed: 6 additions & 12 deletions

File tree

view/adminhtml/templates/script/component-partial/columns-selector-component-partial.phtml

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,23 @@ use Magento\Framework\View\Element\Template;
1010
<script>
1111
const LokiAdminColumnsSelectorComponentPartial = {
1212
activeColumns: null,
13-
initActiveColumns() {
14-
this.activeColumns = new Set();
15-
if (Array.isArray(this.columns)) {
16-
this.columns.forEach(column => {
17-
this.activeColumns.add(column.code);
18-
})
19-
}
20-
},
2113
isColumnActive() {
2214
const columnName = this.$el.getAttribute('data-column');
23-
return this.activeColumns.has(columnName);
15+
return this.activeColumns.includes(columnName);
2416
},
2517
showColumnsSelector: false,
2618
toggleColumnsSelector() {
2719
this.showColumnsSelector = !this.showColumnsSelector;
2820
},
2921
toggleActiveColumn() {
3022
const columnName = this.$el.getAttribute('data-column');
31-
if (this.activeColumns.has(columnName)) {
32-
this.activeColumns.delete(columnName);
23+
if (this.activeColumns.includes(columnName)) {
24+
this.activeColumns = this.activeColumns.filter(item => item !== columnName);
3325
} else {
34-
this.activeColumns.add(columnName);
26+
this.activeColumns.push(columnName);
3527
}
28+
29+
this.post({activeColumns: this.activeColumns});
3630
}
3731
}
3832
</script>

0 commit comments

Comments
 (0)