Skip to content

Commit

Permalink
Allow to define row count after which a collapsible can be collapsed
Browse files Browse the repository at this point in the history
  • Loading branch information
yhabteab committed Aug 31, 2023
1 parent fe74f49 commit 4bbef6c
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions public/js/icinga/behavior/collapsible.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,14 +320,21 @@

let rowSelector = this.getRowSelector(collapsible);
if (!! rowSelector) {
let visibleRows = Number(collapsible.dataset.visibleRows);
if (isNaN(visibleRows)) {
visibleRows = this.defaultVisibleRows;
} else if (visibleRows === 0) {
let canCollapseAfter = Number(collapsible.dataset.canCollapseAfter)
if (isNaN(canCollapseAfter)) {
canCollapseAfter = Number(collapsible.dataset.visibleRows);
if (isNaN(canCollapseAfter)) {
canCollapseAfter = this.defaultVisibleRows;
}

canCollapseAfter *= 2;
}

if (canCollapseAfter === 0) {
return true;
}

return collapsible.querySelectorAll(rowSelector).length > visibleRows * 2;
return collapsible.querySelectorAll(rowSelector).length > canCollapseAfter;
} else {
let maxHeight = Number(collapsible.dataset.visibleHeight);
if (isNaN(maxHeight)) {
Expand Down

0 comments on commit 4bbef6c

Please sign in to comment.