From 5b04818fae367b49770a1be081877f0989356d57 Mon Sep 17 00:00:00 2001 From: ashklianko Date: Fri, 13 Sep 2024 18:31:58 +0200 Subject: [PATCH] Misc changes for the new tree- and -list api #3696 --- .../ui/selector/list/ListSelectionController.ts | 1 + .../ui/selector/list/SelectableListBoxWrapper.ts | 16 ++++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/main/resources/assets/admin/common/js/ui/selector/list/ListSelectionController.ts b/src/main/resources/assets/admin/common/js/ui/selector/list/ListSelectionController.ts index 37d1b0e78..b28600a88 100644 --- a/src/main/resources/assets/admin/common/js/ui/selector/list/ListSelectionController.ts +++ b/src/main/resources/assets/admin/common/js/ui/selector/list/ListSelectionController.ts @@ -47,6 +47,7 @@ export class ListSelectionController if (this.isChecked() || this.isPartial()) { this.selectableListBox.deselectAll(); } else { + this.selectableListBox.setSelectionMode(SelectionMode.SELECT); this.selectableListBox.selectAll(); } } diff --git a/src/main/resources/assets/admin/common/js/ui/selector/list/SelectableListBoxWrapper.ts b/src/main/resources/assets/admin/common/js/ui/selector/list/SelectableListBoxWrapper.ts index 59901bfd8..f8337b37c 100644 --- a/src/main/resources/assets/admin/common/js/ui/selector/list/SelectableListBoxWrapper.ts +++ b/src/main/resources/assets/admin/common/js/ui/selector/list/SelectableListBoxWrapper.ts @@ -131,12 +131,7 @@ export class SelectableListBoxWrapper const itemId = this.listBox.getIdOfItem(item); const actualItem = this.listBox.getItem(itemId) || item; // making sure we work with actual list item value - if (!this.isMultiSelect() || this.selectionMode === SelectionMode.HIGHLIGHT) { // unselect all other items - this.getCurrentlySelectedItems().filter((selectedItem) => this.listBox.getIdOfItem(selectedItem) !== itemId).forEach( - (selectedItem: I) => { - this.handleUserDeselected(selectedItem); - }); - } + this.unSelectOtherItems(itemId); if (this.isSelected(itemId)) { this.handleUserDeselected(actualItem); @@ -145,6 +140,15 @@ export class SelectableListBoxWrapper } } + private unSelectOtherItems(itemId: string): void { + if (!this.isMultiSelect() || this.selectionMode === SelectionMode.HIGHLIGHT) { // unselect all other items + this.getCurrentlySelectedItems().filter((selectedItem) => this.listBox.getIdOfItem(selectedItem) !== itemId).forEach( + (selectedItem: I) => { + this.handleUserDeselected(selectedItem); + }); + } + } + protected getCurrentlySelectedItems(): I[] { return Array.from(this.selectedItems.values()); }