View | Details | Raw Unified | Return to bug 10190
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Admin/CirculationTriggers/CirculationTriggersList.vue (+54 lines)
Lines 89-94 Link Here
89
                }}
89
                }}
90
            </p>
90
            </p>
91
        </div>
91
        </div>
92
        <div
93
            v-if="
94
                ruleSetInitialized &&
95
                currentLibraryId === '*' &&
96
                triggerCounts['*'] === 0
97
            "
98
            class="alert alert-warning"
99
        >
100
            <p>
101
                {{
102
                    $__(
103
                        "No default overdue triggers are defined. Default triggers apply to all libraries unless overridden."
104
                    )
105
                }}
106
            </p>
107
            <template v-if="librariesWithRules.length > 0">
108
                <p>
109
                    {{
110
                        $__(
111
                            "The following libraries have library-specific triggers defined:"
112
                        )
113
                    }}
114
                </p>
115
                <ul>
116
                    <li v-for="lib in librariesWithRules" :key="lib.library_id">
117
                        <a
118
                            href="#"
119
                            @click.prevent="
120
                                currentLibraryId = lib.library_id;
121
                                filterRuleSetsbySearchParam();
122
                            "
123
                            >{{ lib.name }}</a
124
                        >
125
                    </li>
126
                </ul>
127
            </template>
128
            <p v-else>
129
                {{
130
                    $__(
131
                        "No library-specific triggers are defined either. Select add new trigger above to get started."
132
                    )
133
                }}
134
            </p>
135
        </div>
92
        <div class="page-section" v-if="filtersInitialized">
136
        <div class="page-section" v-if="filtersInitialized">
93
            <legend>
137
            <legend>
94
                Filter by
138
                Filter by
Lines 294-299 export default { Link Here
294
            setAllEffectiveRuleSets,
338
            setAllEffectiveRuleSets,
295
            setAllExhaustiveEffectiveRuleSets,
339
            setAllExhaustiveEffectiveRuleSets,
296
            isLastTrigger,
340
            isLastTrigger,
341
            getLibrariesWithRules,
297
        } = circRulesStore;
342
        } = circRulesStore;
298
        const {
343
        const {
299
            currentLibraryId,
344
            currentLibraryId,
Lines 305-310 export default { Link Here
305
            triggerCounts,
350
            triggerCounts,
306
            allExhaustiveEffectiveRuleSets,
351
            allExhaustiveEffectiveRuleSets,
307
            allEffectiveRuleSets,
352
            allEffectiveRuleSets,
353
            librariesWithRules,
308
            storeInitialized,
354
            storeInitialized,
309
        } = storeToRefs(circRulesStore);
355
        } = storeToRefs(circRulesStore);
310
356
Lines 322-328 export default { Link Here
322
            setAllEffectiveRuleSets,
368
            setAllEffectiveRuleSets,
323
            setAllExhaustiveEffectiveRuleSets,
369
            setAllExhaustiveEffectiveRuleSets,
324
            allEffectiveRuleSets,
370
            allEffectiveRuleSets,
371
            librariesWithRules,
325
            isLastTrigger,
372
            isLastTrigger,
373
            getLibrariesWithRules,
326
            storeInitialized,
374
            storeInitialized,
327
            from_branch,
375
            from_branch,
328
        };
376
        };
Lines 343-348 export default { Link Here
343
            this.updateTriggerCount();
391
            this.updateTriggerCount();
344
            this.setAllEffectiveRuleSets();
392
            this.setAllEffectiveRuleSets();
345
            this.setAllExhaustiveEffectiveRuleSets();
393
            this.setAllExhaustiveEffectiveRuleSets();
394
            if (
395
                this.currentLibraryId === "*" &&
396
                this.triggerCounts["*"] === 0
397
            ) {
398
                await this.getLibrariesWithRules();
399
            }
346
            this.storeInitialized = true;
400
            this.storeInitialized = true;
347
        },
401
        },
348
        formatSelectedParams() {
402
        formatSelectedParams() {
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/stores/circulation-rules.js (-1 / +16 lines)
Lines 38-43 export const useCircRulesStore = defineStore("circRules", () => { Link Here
38
        allEffectiveRuleSets: [], // main data set for display explicitly set rules for current library
38
        allEffectiveRuleSets: [], // main data set for display explicitly set rules for current library
39
        allExhaustiveEffectiveRuleSets: [], // main data set for display all applied rules for current library
39
        allExhaustiveEffectiveRuleSets: [], // main data set for display all applied rules for current library
40
        currentAndDefaultRawRuleSets: [], // data set to identify effective rules from (combines allDefaultLibraryRawRuleSets and allCurrentLibraryRawRuleSets)
40
        currentAndDefaultRawRuleSets: [], // data set to identify effective rules from (combines allDefaultLibraryRawRuleSets and allCurrentLibraryRawRuleSets)
41
        librariesWithRules: [],
41
        storeInitialized: false,
42
        storeInitialized: false,
42
    });
43
    });
43
44
Lines 411-416 export const useCircRulesStore = defineStore("circRules", () => { Link Here
411
            }
412
            }
412
            this.updateCircRuleSets(rulesForDeletion, triggerNumber);
413
            this.updateCircRuleSets(rulesForDeletion, triggerNumber);
413
        },
414
        },
415
        async getLibrariesWithRules() {
416
            const client = APIClient.circRule;
417
            const allRules = await client.circ_rules.getAll(
418
                {},
419
                { effective: false }
420
            );
421
            const libraryIds = new Set(
422
                allRules
423
                    .map(r => r.context?.library_id)
424
                    .filter(id => id && id !== "*")
425
            );
426
            this.librariesWithRules = this.libraries.filter(
427
                lib => lib.library_id !== "*" && libraryIds.has(lib.library_id)
428
            );
429
        },
414
        async getAllRawRuleSets() {
430
        async getAllRawRuleSets() {
415
            const client = APIClient.circRule;
431
            const client = APIClient.circRule;
416
            this.allDefaultLibraryRawRuleSets = await client.circ_rules.getAll(
432
            this.allDefaultLibraryRawRuleSets = await client.circ_rules.getAll(
417
- 

Return to bug 10190