From cb4a1999550bac4375b69ef929e967896242cc84 Mon Sep 17 00:00:00 2001 From: Matt Blenkinsop Date: Mon, 16 Sep 2024 15:28:00 +0000 Subject: [PATCH] Bug 37930: Update the ERM and Preservation apps --- .../prog/js/vue/components/ERM/Main.vue | 81 ++++--------------- .../js/vue/components/Preservation/Main.vue | 49 ++++------- .../intranet-tmpl/prog/js/vue/modules/erm.ts | 2 +- .../prog/js/vue/modules/preservation.ts | 2 +- 4 files changed, 36 insertions(+), 98 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/Main.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/Main.vue index 3eaf6dd4891..beabf6e96c2 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/Main.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/Main.vue @@ -42,6 +42,7 @@ export default { const vendorStore = inject("vendorStore") const AVStore = inject("AVStore") + const { initialiseAVStore } = AVStore const mainStore = inject("mainStore") @@ -59,6 +60,7 @@ export default { setError, loading, loaded, + initialiseAVStore, } }, data() { @@ -71,8 +73,6 @@ export default { this.loading() const fetch_config = () => { - let promises = [] - const acq_client = APIClient.acquisition acq_client.vendors.getAll().then( vendors => { @@ -80,72 +80,25 @@ export default { }, error => {} ) - - const av_client = APIClient.authorised_values - const authorised_values = { - av_agreement_statuses: "ERM_AGREEMENT_STATUS", - av_agreement_closure_reasons: "ERM_AGREEMENT_CLOSURE_REASON", - av_agreement_renewal_priorities: - "ERM_AGREEMENT_RENEWAL_PRIORITY", - av_user_roles: "ERM_USER_ROLES", - av_license_types: "ERM_LICENSE_TYPE", - av_license_statuses: "ERM_LICENSE_STATUS", - av_agreement_license_statuses: "ERM_AGREEMENT_LICENSE_STATUS", - av_agreement_license_location: "ERM_AGREEMENT_LICENSE_LOCATION", - av_package_types: "ERM_PACKAGE_TYPE", - av_package_content_types: "ERM_PACKAGE_CONTENT_TYPE", - av_title_publication_types: "ERM_TITLE_PUBLICATION_TYPE", - av_report_types: "ERM_REPORT_TYPES", - av_platform_reports_metrics: "ERM_PLATFORM_REPORTS_METRICS", - av_database_reports_metrics: "ERM_DATABASE_REPORTS_METRICS", - av_title_reports_metrics: "ERM_TITLE_REPORTS_METRICS", - av_item_reports_metrics: "ERM_ITEM_REPORTS_METRICS", - } - - let av_cat_array = Object.keys(authorised_values).map(function ( - av_cat - ) { - return '"' + authorised_values[av_cat] + '"' + this.initialiseAVStore("erm").then(() => { + this.loaded() + this.initialized = true }) - - promises.push( - av_client.values - .getCategoriesWithValues(av_cat_array) - .then(av_categories => { - Object.entries(authorised_values).forEach( - ([av_var, av_cat]) => { - const av_match = av_categories.find( - element => element.category_name == av_cat - ) - this.AVStore[av_var] = - av_match.authorised_values - } - ) - }) - ) - - return Promise.all(promises) } const client = APIClient.erm - client.config - .get() - .then(config => { - this.config = config - if (this.config.settings.ERMModule != 1) { - return this.setError( - this.$__( - 'The e-resource management module is disabled, turn on ERMModule to use it' - ), - false - ) - } - return fetch_config() - }) - .then(() => { - this.loaded() - this.initialized = true - }) + client.config.get().then(config => { + this.config = config + if (this.config.settings.ERMModule != 1) { + return this.setError( + this.$__( + 'The e-resource management module is disabled, turn on ERMModule to use it' + ), + false + ) + } + return fetch_config() + }) }, methods: { async filterProviders(navigationTree) { 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 008c1393a71..aa0b47424cf 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 @@ -37,6 +37,7 @@ import { storeToRefs } from "pinia" export default { setup() { const AVStore = inject("AVStore") + const { initialiseAVStore } = AVStore const mainStore = inject("mainStore") @@ -52,6 +53,7 @@ export default { loaded, config, setError, + initialiseAVStore, } }, data() { @@ -62,39 +64,22 @@ 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(() => { - this.loaded() - this.initialized = true - }) + 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 + ) + } + }) + this.initialiseAVStore("preservation").then(() => { + this.loaded() + this.initialized = true + }) }, components: { diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/modules/erm.ts b/koha-tmpl/intranet-tmpl/prog/js/vue/modules/erm.ts index f00746675b1..26ecaba18f7 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/modules/erm.ts +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/modules/erm.ts @@ -21,7 +21,7 @@ import { routes as routesDef } from "../routes/erm"; import { useMainStore } from "../stores/main"; import { useVendorStore } from "../stores/vendors"; -import { useAVStore } from "../stores/authorised-values"; +import { useAVStore } from "../stores/authorisedValues/authorised-values"; import { useERMStore } from "../stores/erm"; import { useNavigationStore } from "../stores/navigation"; import { useReportsStore } from "../stores/usage-reports"; diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/modules/preservation.ts b/koha-tmpl/intranet-tmpl/prog/js/vue/modules/preservation.ts index b23624fc1b8..67d754a8268 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/modules/preservation.ts +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/modules/preservation.ts @@ -32,7 +32,7 @@ import App from "../components/Preservation/Main.vue"; import { routes as routesDef } from "../routes/preservation"; import { useMainStore } from "../stores/main"; -import { useAVStore } from "../stores/authorised-values"; +import { useAVStore } from "../stores/authorisedValues/authorised-values"; import { usePreservationStore } from "../stores/preservation"; import { useNavigationStore } from "../stores/navigation"; import i18n from "../i18n"; -- 2.39.3 (Apple Git-146)