From b80df784351e02ca9e41a22a1611703efb83fc33 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 25 Feb 2026 14:20:31 +0000 Subject: [PATCH] Bug 10190: warn when no default triggers exist and show libraries with rules When viewing the default library context with no triggers defined, show a warning message explaining defaults apply to all libraries. If any libraries have specific triggers, list them as clickable links that switch the filter to that library. If no rules exist anywhere, show a prompt to add the first trigger. Signed-off-by: Michaela Signed-off-by: Nick Clemens Signed-off-by: Pedro Amorim --- .../CirculationTriggersList.vue | 54 +++++++++++++++++++ .../prog/js/vue/stores/circulation-rules.js | 16 ++++++ 2 files changed, 70 insertions(+) diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Admin/CirculationTriggers/CirculationTriggersList.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Admin/CirculationTriggers/CirculationTriggersList.vue index a11b9940ef..6ded9bdcf7 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Admin/CirculationTriggers/CirculationTriggersList.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Admin/CirculationTriggers/CirculationTriggersList.vue @@ -89,6 +89,50 @@ }}

+
+

+ {{ + $__( + "No default overdue triggers are defined. Default triggers apply to all libraries unless overridden." + ) + }} +

+ +

+ {{ + $__( + "No library-specific triggers are defined either. Select add new trigger above to get started." + ) + }} +

+
Filter by @@ -294,6 +338,7 @@ export default { setAllEffectiveRuleSets, setAllExhaustiveEffectiveRuleSets, isLastTrigger, + getLibrariesWithRules, } = circRulesStore; const { currentLibraryId, @@ -305,6 +350,7 @@ export default { triggerCounts, allExhaustiveEffectiveRuleSets, allEffectiveRuleSets, + librariesWithRules, storeInitialized, } = storeToRefs(circRulesStore); @@ -322,7 +368,9 @@ export default { setAllEffectiveRuleSets, setAllExhaustiveEffectiveRuleSets, allEffectiveRuleSets, + librariesWithRules, isLastTrigger, + getLibrariesWithRules, storeInitialized, from_branch, }; @@ -343,6 +391,12 @@ export default { this.updateTriggerCount(); this.setAllEffectiveRuleSets(); this.setAllExhaustiveEffectiveRuleSets(); + if ( + this.currentLibraryId === "*" && + this.triggerCounts["*"] === 0 + ) { + await this.getLibrariesWithRules(); + } this.storeInitialized = true; }, formatSelectedParams() { diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/stores/circulation-rules.js b/koha-tmpl/intranet-tmpl/prog/js/vue/stores/circulation-rules.js index 27ad9875cd..77af0caa18 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/stores/circulation-rules.js +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/stores/circulation-rules.js @@ -38,6 +38,7 @@ export const useCircRulesStore = defineStore("circRules", () => { allEffectiveRuleSets: [], // main data set for display explicitly set rules for current library allExhaustiveEffectiveRuleSets: [], // main data set for display all applied rules for current library currentAndDefaultRawRuleSets: [], // data set to identify effective rules from (combines allDefaultLibraryRawRuleSets and allCurrentLibraryRawRuleSets) + librariesWithRules: [], storeInitialized: false, }); @@ -411,6 +412,21 @@ export const useCircRulesStore = defineStore("circRules", () => { } this.updateCircRuleSets(rulesForDeletion, triggerNumber); }, + async getLibrariesWithRules() { + const client = APIClient.circRule; + const allRules = await client.circ_rules.getAll( + {}, + { effective: false } + ); + const libraryIds = new Set( + allRules + .map(r => r.context?.library_id) + .filter(id => id && id !== "*") + ); + this.librariesWithRules = this.libraries.filter( + lib => lib.library_id !== "*" && libraryIds.has(lib.library_id) + ); + }, async getAllRawRuleSets() { const client = APIClient.circRule; this.allDefaultLibraryRawRuleSets = await client.circ_rules.getAll(