From b775467d91145b2370d1c9f53c1d4ba61eed7bc2 Mon Sep 17 00:00:00 2001 From: Luigi D'Acunto Date: Tue, 16 Jun 2026 17:51:35 +0200 Subject: [PATCH] feat: estesi accordion badge anche alla pagina bulkedit Aggiunta costante ACCORDION_MODES (Set con 'edit_host' e 'bulkedit') per centralizzare il guard URL. I badge di conteggio checkbox e valori ereditati ora si attivano su entrambe le pagine di modifica host, singola e massiva. Co-Authored-By: Claude Sonnet 4.6 --- user_script/checkmk_swissknife.user.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/user_script/checkmk_swissknife.user.js b/user_script/checkmk_swissknife.user.js index 979cffb..86d2a00 100644 --- a/user_script/checkmk_swissknife.user.js +++ b/user_script/checkmk_swissknife.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name Checkmk SwissKnife // @namespace https://luigidacunto.com/ -// @version 2.3 +// @version 2.4 // @description Raccolta di miglioramenti all'interfaccia di Checkmk WATO. Ogni fix o enhancement viene aggiunto qui come feature indipendente. // @author Luigi D'Acunto // @homepageURL https://git.luigidacunto.com/tools/checkmk-swissknife @@ -43,6 +43,9 @@ catch (e) { return ''; } } + // Pagine che supportano gli accordion badge (stessa struttura form_edit_host + table.nform) + const ACCORDION_MODES = new Set(['edit_host', 'bulkedit']); + // Inietta CSS nel documento target (una sola volta, deduplica per id) function injectStyles(iDoc, id, css) { if (iDoc.getElementById(id)) return; @@ -557,8 +560,8 @@ if (++attemptsAcc < MAX_ATTEMPTS) setTimeout(tryInitAccordionCounts, POLL_INTERVAL_MS); return; } - // Guard URL: attiva solo sulla pagina edit_host - if (getPageMode(iDoc) !== 'edit_host') return; + // Guard URL: attiva solo sulle pagine con accordion supportati + if (!ACCORDION_MODES.has(getPageMode(iDoc))) return; if (!initAccordionCheckedCounts(iDoc)) { if (++attemptsAcc < MAX_ATTEMPTS) setTimeout(tryInitAccordionCounts, POLL_INTERVAL_MS); } @@ -571,9 +574,9 @@ attemptsAcc = 0; // Folder select: si auto-ferma se non trova l'elemento, schedula sempre. setTimeout(tryEnhanceFolderSelect, 800); - // Accordion: solo su edit_host. Se mode è vuoto (iframe non ancora caricato) - // si schedula comunque: tryInitAccordionCounts farà il guard URL. - if (!mode || mode === 'edit_host') { + // Accordion: solo sulle pagine in ACCORDION_MODES. Se mode è vuoto (iframe non ancora + // caricato) si schedula comunque: tryInitAccordionCounts farà il guard URL. + if (!mode || ACCORDION_MODES.has(mode)) { setTimeout(tryInitAccordionCounts, 800); } } @@ -594,7 +597,7 @@ attemptsFolder = 0; setTimeout(tryEnhanceFolderSelect, 300); } - if (mode === 'edit_host') { + if (ACCORDION_MODES.has(mode)) { const form = iDoc.getElementById('form_edit_host'); if (form && !form.dataset.cmkAccBadge) { attemptsAcc = 0;