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 <michaela.sieber@kit.edu> Signed-off-by: Nick Clemens <nick@bywatersolutions.com> Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
This commit is contained in:
parent
17c3aab6c4
commit
b80df78435
|
|
@ -89,6 +89,50 @@
|
|||
}}
|
||||
</p>
|
||||
</div>
|
||||
<div
|
||||
v-if="
|
||||
ruleSetInitialized &&
|
||||
currentLibraryId === '*' &&
|
||||
triggerCounts['*'] === 0
|
||||
"
|
||||
class="alert alert-warning"
|
||||
>
|
||||
<p>
|
||||
{{
|
||||
$__(
|
||||
"No default overdue triggers are defined. Default triggers apply to all libraries unless overridden."
|
||||
)
|
||||
}}
|
||||
</p>
|
||||
<template v-if="librariesWithRules.length > 0">
|
||||
<p>
|
||||
{{
|
||||
$__(
|
||||
"The following libraries have library-specific triggers defined:"
|
||||
)
|
||||
}}
|
||||
</p>
|
||||
<ul>
|
||||
<li v-for="lib in librariesWithRules" :key="lib.library_id">
|
||||
<a
|
||||
href="#"
|
||||
@click.prevent="
|
||||
currentLibraryId = lib.library_id;
|
||||
filterRuleSetsbySearchParam();
|
||||
"
|
||||
>{{ lib.name }}</a
|
||||
>
|
||||
</li>
|
||||
</ul>
|
||||
</template>
|
||||
<p v-else>
|
||||
{{
|
||||
$__(
|
||||
"No library-specific triggers are defined either. Select add new trigger above to get started."
|
||||
)
|
||||
}}
|
||||
</p>
|
||||
</div>
|
||||
<div class="page-section" v-if="filtersInitialized">
|
||||
<legend>
|
||||
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() {
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Reference in New Issue