From d186604b629eeafbf66bf0da67e92223a38fd858 Mon Sep 17 00:00:00 2001 From: Yonas Habteab Date: Wed, 30 Aug 2023 10:55:58 +0200 Subject: [PATCH] Allow to define row count after which a collapsible can be collapsed --- public/js/icinga/behavior/collapsible.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/public/js/icinga/behavior/collapsible.js b/public/js/icinga/behavior/collapsible.js index c0b5349e3..16f719506 100644 --- a/public/js/icinga/behavior/collapsible.js +++ b/public/js/icinga/behavior/collapsible.js @@ -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 collapseAfter = Number(collapsible.dataset.collapseAfter) + if (isNaN(collapseAfter)) { + collapseAfter = Number(collapsible.dataset.visibleRows); + if (isNaN(collapseAfter)) { + collapseAfter = this.defaultVisibleRows; + } + + collapseAfter *= 2; + } + + if (collapseAfter === 0) { return true; } - return collapsible.querySelectorAll(rowSelector).length > visibleRows * 2; + return collapsible.querySelectorAll(rowSelector).length > collapseAfter; } else { let maxHeight = Number(collapsible.dataset.visibleHeight); if (isNaN(maxHeight)) {