From 858d3a91d72c947f129f09759e43a5f73cae59ba Mon Sep 17 00:00:00 2001 From: Sukhwinder Dhillon Date: Tue, 30 Jul 2024 11:45:49 +0200 Subject: [PATCH 1/3] action-list: Take items with css propery `display:contents` into account The list items of icingadb/(hostgroups/servicegroups) have the css property `display:contents`, which leads to the scrollIntoView() function having no effect. --- public/js/action-list.js | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/public/js/action-list.js b/public/js/action-list.js index c176a0db7..1bfc77f1a 100644 --- a/public/js/action-list.js +++ b/public/js/action-list.js @@ -432,9 +432,15 @@ * @param pressedKey Pressed key (`ArrowUp` or `ArrowDown`) */ scrollItemIntoView(item, pressedKey) { - item.scrollIntoView({block: "nearest"}); let directionalNext = this.getDirectionalNext(item, pressedKey); + if ("isDisplayContents" in item.parentElement.dataset) { + item = item.firstChild; + directionalNext = directionalNext ? directionalNext.firstChild : null; + } + // required when ArrowUp is pressed in new list OR after selecting all items with ctrl+A + item.scrollIntoView({block: "nearest"}); + if (directionalNext) { directionalNext.scrollIntoView({block: "nearest"}); } @@ -737,6 +743,30 @@ list = _this.findDetailUrlActionList(container); } + if (! list || ! ("isDisplayContents" in list.dataset)) { + // no detail view || ignore when already set + let actionLists = null; + if (! list) { + actionLists = document.querySelectorAll('.action-list'); + } else { + actionLists = [list]; + } + + for (let actionList of actionLists) { + let firstSelectableItem = actionList.querySelector(':scope > [data-action-item]'); + if ( + firstSelectableItem + && ( + ! firstSelectableItem.checkVisibility() + && firstSelectableItem.firstChild + && firstSelectableItem.firstChild.checkVisibility() + ) + ) { + actionList.dataset.isDisplayContents = ""; + } + } + } + if (list && list.matches('[data-icinga-multiselect-url], [data-icinga-detail-url]')) { let detailUrl = _this.icinga.utils.parseUrl( _this.icinga.history.getCol2State().replace(/^#!/, '') From 9112fd40f69ca76e63432786597e0c6393740dd7 Mon Sep 17 00:00:00 2001 From: Sukhwinder Dhillon Date: Tue, 30 Jul 2024 12:50:44 +0200 Subject: [PATCH 2/3] action-list: Deselect `dashboard` items when not in detail url --- public/js/action-list.js | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/public/js/action-list.js b/public/js/action-list.js index 1bfc77f1a..15a2840ab 100644 --- a/public/js/action-list.js +++ b/public/js/action-list.js @@ -133,11 +133,7 @@ let dashboard = list.closest('.dashboard'); if (dashboard) { - dashboard.querySelectorAll('.action-list').forEach(otherList => { - if (otherList !== list) { - toDeactivateItems.push(..._this.getAllItems(otherList)); - } - }) + _this.clearDashboardSelections(dashboard, list); } let lastActivatedUrl = null; @@ -151,11 +147,7 @@ _this.clearSelection(toDeactivateItems); _this.setActive(toActiveItems); - - if (! dashboard) { - _this.addSelectionCountToFooter(list); - } - + _this.addSelectionCountToFooter(list); _this.setLastActivatedItemUrl(lastActivatedUrl); _this.loadDetailUrl(list, target.matches('a') ? target.getAttribute('href') : null); } @@ -166,7 +158,7 @@ * @param list */ addSelectionCountToFooter(list) { - if (! list.matches('[data-icinga-multiselect-url]')) { + if (! list.matches('[data-icinga-multiselect-url]') || list.closest('.dashboard')) { return; } @@ -446,6 +438,14 @@ } } + clearDashboardSelections(dashboard, currentList) { + dashboard.querySelectorAll('.action-list').forEach(otherList => { + if (otherList !== currentList) { + this.clearSelection(this.getActiveItems(otherList)); + } + }) + } + /** * Load the detail url with selected items * @@ -792,6 +792,11 @@ } } + let dashboard = list.closest('.dashboard'); + if (dashboard) { + _this.clearDashboardSelections(dashboard, list); + } + _this.clearSelection(_this.getAllItems(list).filter(item => !toActiveItems.includes(item))); _this.setActive(toActiveItems); } From e7a67f80d5c1ef5eb961fb1268d9c2b9f4e09553 Mon Sep 17 00:00:00 2001 From: Sukhwinder Dhillon Date: Wed, 31 Jul 2024 11:02:20 +0200 Subject: [PATCH 3/3] action-list: Add method doc --- public/js/action-list.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/public/js/action-list.js b/public/js/action-list.js index 15a2840ab..d48739048 100644 --- a/public/js/action-list.js +++ b/public/js/action-list.js @@ -200,6 +200,8 @@ /** * Key navigation for .action-list * + * Only for primary lists (dashboard or lists in detail view are not taken into account) + * * - `Shift + ArrowUp|ArrowDown` = Multiselect * - `ArrowUp|ArrowDown` = Select next/previous * - `Ctrl|cmd + A` = Select all on currect page