Skip to content

Commit

Permalink
js: Fix broken autorefresh of col2
Browse files Browse the repository at this point in the history
Suspending the autorefresh is only required while the user
is actively choosing multiple list items.

fixes #879
  • Loading branch information
nilmerg committed Sep 26, 2023
1 parent bef893b commit 76f3786
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions public/js/action-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 76f3786

Please sign in to comment.