From f634bb43b3c5e07c991ed425efd1159bbc5748aa Mon Sep 17 00:00:00 2001 From: Matt Blenkinsop Date: Mon, 7 Apr 2025 17:21:59 +0100 Subject: [PATCH] Bug 37930: Extend new AV logic to the Preservation module --- .../js/vue/components/Preservation/Main.vue | 54 +++++------ .../vue/components/Preservation/Settings.vue | 14 ++- .../SettingsProcessingsFormAdd.vue | 3 - .../components/Preservation/TrainsFormAdd.vue | 12 +-- .../components/Preservation/TrainsList.vue | 4 +- .../components/Preservation/TrainsShow.vue | 4 +- .../prog/js/vue/stores/preservation.js | 7 ++ .../integration/Preservation/Settings.ts | 75 ++++++++------- t/cypress/integration/Preservation/Trains.ts | 93 +++++++++++-------- 9 files changed, 134 insertions(+), 132 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Preservation/Main.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Preservation/Main.vue index d0d4104dd50..106b427e79d 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Preservation/Main.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Preservation/Main.vue @@ -36,22 +36,23 @@ import { storeToRefs } from "pinia"; export default { setup() { - const AVStore = inject("AVStore"); - const mainStore = inject("mainStore"); const { loading, loaded, setError } = mainStore; const PreservationStore = inject("PreservationStore"); - const { config } = storeToRefs(PreservationStore); + const { config, authorisedValues } = storeToRefs(PreservationStore); + const { loadAuthorisedValues } = PreservationStore; return { - AVStore, loading, loaded, config, setError, + authorisedValues, + loadAuthorisedValues, + PreservationStore, }; }, data() { @@ -62,39 +63,26 @@ export default { beforeCreate() { this.loading(); - const fetch_additional_config = () => { - let promises = []; - const av_client = APIClient.authorised_values; - promises.push( - av_client.values.get("NOT_LOAN").then( - values => { - this.AVStore.av_notforloan = values; - }, - error => {} - ) - ); - return Promise.all(promises); - }; - const client = APIClient.preservation; - client.config - .get() - .then(config => { - this.config = config; - if (this.config.settings.enabled != 1) { - return this.setError( - this.$__( - 'The preservation module is disabled, turn on PreservationModule to use it' - ), - false - ); - } - return fetch_additional_config(); - }) - .then(() => { + client.config.get().then(config => { + this.config = config; + if (this.config.settings.enabled != 1) { + this.loaded(); + return this.setError( + this.$__( + 'The preservation module is disabled, turn on PreservationModule to use it' + ), + false + ); + } + this.loadAuthorisedValues( + this.authorisedValues, + this.PreservationStore + ).then(() => { this.loaded(); this.initialized = true; }); + }); }, components: { diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Preservation/Settings.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Preservation/Settings.vue index 3db5d715419..9d3a8bce8b2 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Preservation/Settings.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Preservation/Settings.vue @@ -29,7 +29,7 @@ " label="description" :reduce="av => av.value" - :options="av_notforloan" + :options="authorisedValues.av_notforloan" >