|
133 | 133 |
|
134 | 134 | let dashboard = list.closest('.dashboard'); |
135 | 135 | if (dashboard) { |
136 | | - dashboard.querySelectorAll('.action-list').forEach(otherList => { |
137 | | - if (otherList !== list) { |
138 | | - toDeactivateItems.push(..._this.getAllItems(otherList)); |
139 | | - } |
140 | | - }) |
| 136 | + _this.clearDashboardSelections(dashboard, list); |
141 | 137 | } |
142 | 138 |
|
143 | 139 | let lastActivatedUrl = null; |
|
151 | 147 |
|
152 | 148 | _this.clearSelection(toDeactivateItems); |
153 | 149 | _this.setActive(toActiveItems); |
154 | | - |
155 | | - if (! dashboard) { |
156 | | - _this.addSelectionCountToFooter(list); |
157 | | - } |
158 | | - |
| 150 | + _this.addSelectionCountToFooter(list); |
159 | 151 | _this.setLastActivatedItemUrl(lastActivatedUrl); |
160 | 152 | _this.loadDetailUrl(list, target.matches('a') ? target.getAttribute('href') : null); |
161 | 153 | } |
|
166 | 158 | * @param list |
167 | 159 | */ |
168 | 160 | addSelectionCountToFooter(list) { |
169 | | - if (! list.matches('[data-icinga-multiselect-url]')) { |
| 161 | + if (! list.matches('[data-icinga-multiselect-url]') || list.closest('.dashboard')) { |
170 | 162 | return; |
171 | 163 | } |
172 | 164 |
|
|
208 | 200 | /** |
209 | 201 | * Key navigation for .action-list |
210 | 202 | * |
| 203 | + * Only for primary lists (dashboard or lists in detail view are not taken into account) |
| 204 | + * |
211 | 205 | * - `Shift + ArrowUp|ArrowDown` = Multiselect |
212 | 206 | * - `ArrowUp|ArrowDown` = Select next/previous |
213 | 207 | * - `Ctrl|cmd + A` = Select all on currect page |
|
432 | 426 | * @param pressedKey Pressed key (`ArrowUp` or `ArrowDown`) |
433 | 427 | */ |
434 | 428 | scrollItemIntoView(item, pressedKey) { |
435 | | - item.scrollIntoView({block: "nearest"}); |
436 | 429 | let directionalNext = this.getDirectionalNext(item, pressedKey); |
437 | 430 |
|
| 431 | + if ("isDisplayContents" in item.parentElement.dataset) { |
| 432 | + item = item.firstChild; |
| 433 | + directionalNext = directionalNext ? directionalNext.firstChild : null; |
| 434 | + } |
| 435 | + // required when ArrowUp is pressed in new list OR after selecting all items with ctrl+A |
| 436 | + item.scrollIntoView({block: "nearest"}); |
| 437 | + |
438 | 438 | if (directionalNext) { |
439 | 439 | directionalNext.scrollIntoView({block: "nearest"}); |
440 | 440 | } |
441 | 441 | } |
442 | 442 |
|
| 443 | + clearDashboardSelections(dashboard, currentList) { |
| 444 | + dashboard.querySelectorAll('.action-list').forEach(otherList => { |
| 445 | + if (otherList !== currentList) { |
| 446 | + this.clearSelection(this.getActiveItems(otherList)); |
| 447 | + } |
| 448 | + }) |
| 449 | + } |
| 450 | + |
443 | 451 | /** |
444 | 452 | * Load the detail url with selected items |
445 | 453 | * |
|
737 | 745 | list = _this.findDetailUrlActionList(container); |
738 | 746 | } |
739 | 747 |
|
| 748 | + if (! list || ! ("isDisplayContents" in list.dataset)) { |
| 749 | + // no detail view || ignore when already set |
| 750 | + let actionLists = null; |
| 751 | + if (! list) { |
| 752 | + actionLists = document.querySelectorAll('.action-list'); |
| 753 | + } else { |
| 754 | + actionLists = [list]; |
| 755 | + } |
| 756 | + |
| 757 | + for (let actionList of actionLists) { |
| 758 | + let firstSelectableItem = actionList.querySelector(':scope > [data-action-item]'); |
| 759 | + if ( |
| 760 | + firstSelectableItem |
| 761 | + && ( |
| 762 | + ! firstSelectableItem.checkVisibility() |
| 763 | + && firstSelectableItem.firstChild |
| 764 | + && firstSelectableItem.firstChild.checkVisibility() |
| 765 | + ) |
| 766 | + ) { |
| 767 | + actionList.dataset.isDisplayContents = ""; |
| 768 | + } |
| 769 | + } |
| 770 | + } |
| 771 | + |
740 | 772 | if (list && list.matches('[data-icinga-multiselect-url], [data-icinga-detail-url]')) { |
741 | 773 | let detailUrl = _this.icinga.utils.parseUrl( |
742 | 774 | _this.icinga.history.getCol2State().replace(/^#!/, '') |
|
762 | 794 | } |
763 | 795 | } |
764 | 796 |
|
| 797 | + let dashboard = list.closest('.dashboard'); |
| 798 | + if (dashboard) { |
| 799 | + _this.clearDashboardSelections(dashboard, list); |
| 800 | + } |
| 801 | + |
765 | 802 | _this.clearSelection(_this.getAllItems(list).filter(item => !toActiveItems.includes(item))); |
766 | 803 | _this.setActive(toActiveItems); |
767 | 804 | } |
|
0 commit comments