From 76f37867c5a60794469c7653856324854827fa10 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 26 Sep 2023 12:52:30 +0200 Subject: [PATCH] js: Fix broken autorefresh of col2 Suspending the autorefresh is only required while the user is actively choosing multiple list items. fixes #879 --- public/js/action-list.js | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/public/js/action-list.js b/public/js/action-list.js index 44738c251..a3eef4622 100644 --- a/public/js/action-list.js +++ b/public/js/action-list.js @@ -58,13 +58,15 @@ let item = target.closest('[data-action-item]'); let list = target.closest('.action-list'); + const container = list.closest('#main > .container'); let activeItems = _this.getActiveItems(list); let toActiveItems = [], toDeactivateItems = []; - list.closest('#main > .container').dataset.suspendAutorefresh = ''; + const isBeingMultiSelected = list.matches('[data-icinga-multiselect-url]') + && (event.ctrlKey || event.metaKey || event.shiftKey); - if (list.matches('[data-icinga-multiselect-url]') && (event.ctrlKey || event.metaKey || event.shiftKey)) { + if (isBeingMultiSelected) { if (event.ctrlKey || event.metaKey) { if (item.classList.contains('active')) { toDeactivateItems.push(item); @@ -114,6 +116,12 @@ : activeItems[activeItems.length - 1].dataset.icingaDetailFilter; } + if (isBeingMultiSelected && container.id === 'col1' && list.matches('.content > :scope')) { + // The restriction on col1 is currently only in place as it's not defined what should happen + // with primary lists in col2. (as a detail load then moves the list to col1) + container.dataset.suspendAutorefresh = ''; + } + _this.clearSelection(toDeactivateItems); _this.setActive(toActiveItems); _this.addSelectionCountToFooter(list); @@ -224,8 +232,6 @@ event.preventDefault(); - list.closest('#main > .container').dataset.suspendAutorefresh = ''; - let allItems = _this.getAllItems(list); let firstListItem = allItems[0]; let lastListItem = allItems[allItems.length -1]; @@ -295,6 +301,14 @@ return; } + const isBeingMultiSelected = isMultiSelectableList && (event.ctrlKey || event.metaKey || event.shiftKey); + const container = list.closest('#main > .container'); + if (isBeingMultiSelected && container.id === 'col1' && list.matches('.content > :scope')) { + // The restriction on col1 is currently only in place as it's not defined what should happen + // with primary lists in col2. (as a detail load then moves the list to col1) + container.dataset.suspendAutorefresh = ''; + } + _this.setActive(toActiveItem); _this.setLastActivatedItemUrl( markAsLastActive ? markAsLastActive.dataset.icingaDetailFilter : toActiveItem.dataset.icingaDetailFilter