From 50aab456bc37fefa74149e85f2dfa9d6d308ab6c Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 21 Feb 2023 12:42:15 +0100 Subject: [PATCH] Bug 32939: Use APIClient to fetch EBSCO eHoldings Signed-off-by: Matt Blenkinsop Signed-off-by: Nick Clemens Signed-off-by: Tomas Cohen Arazi --- .../ERM/EHoldingsEBSCOPackageAgreements.vue | 11 +++- .../ERM/EHoldingsEBSCOPackagesList.vue | 10 ++-- .../ERM/EHoldingsEBSCOPackagesShow.vue | 17 +++--- .../ERM/EHoldingsEBSCOResourcesShow.vue | 17 +++--- .../ERM/EHoldingsEBSCOTitlesShow.vue | 16 ++++-- .../prog/js/vue/fetch/erm-api-client.js | 53 +++++++++++++++++++ 6 files changed, 102 insertions(+), 22 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsEBSCOPackageAgreements.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsEBSCOPackageAgreements.vue index d82d7e380c..734db3e594 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsEBSCOPackageAgreements.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsEBSCOPackageAgreements.vue @@ -58,6 +58,10 @@ export default { erm_package.provider = "ebsco" erm_package.package_id = erm_package.koha_internal_id delete erm_package.koha_internal_id + delete erm_package.resources + delete erm_package.vendor + delete erm_package.resources_count + delete erm_package.is_selected return erm_package }, addAgreement(agreement_id) { @@ -72,7 +76,10 @@ export default { ) { erm_package.package_agreements.push({ agreement_id }) const client = APIClient.erm + if (this.erm_package.koha_internal_id) { + let package_id = erm_package.package_id + delete erm_package.package_id client.localPackages.update(erm_package, package_id).then( success => { this.$emit("refresh-agreements") @@ -97,8 +104,10 @@ export default { }, deleteAgreement(counter) { let erm_package = this.serializeAgreement() - const client = APIClient.erm erm_package.package_agreements.splice(counter, 1) + let package_id = erm_package.package_id + delete erm_package.package_id + const client = APIClient.erm client.localPackages.update(erm_package, package_id).then( success => { this.$emit("refresh-agreements") diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsEBSCOPackagesList.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsEBSCOPackagesList.vue index 900c459bfb..27d54c5931 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsEBSCOPackagesList.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsEBSCOPackagesList.vue @@ -137,11 +137,13 @@ export default { .draw() if (this.erm_providers.includes("local")) { const client = APIClient.erm - const query = filters + const query = this.filters ? { - "me.name": { like: "%" + filters.package_name + "%" }, - ...(filters.content_type - ? { "me.content_type": filters.content_type } + "me.name": { + like: "%" + this.filters.package_name + "%", + }, + ...(this.filters.content_type + ? { "me.content_type": this.filters.content_type } : {}), } : {} diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsEBSCOPackagesShow.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsEBSCOPackagesShow.vue index 7809cdfe74..abb80afccc 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsEBSCOPackagesShow.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsEBSCOPackagesShow.vue @@ -116,7 +116,7 @@ import { inject } from "vue" import EHoldingsPackageAgreements from "./EHoldingsEBSCOPackageAgreements.vue" import EHoldingsPackageTitlesList from "./EHoldingsEBSCOPackageTitlesList.vue" -import { fetchEBSCOPackage, checkError } from "../../fetch/erm.js" +import { APIClient } from "../../fetch/api-client.js" export default { setup() { @@ -157,11 +157,16 @@ export default { this.erm_package = this.getPackage(to.params.package_id) }, methods: { - async getPackage(package_id) { - const erm_package = await fetchEBSCOPackage(package_id) - this.erm_package = erm_package - this.initialized = true - this.updating_is_selected = false + getPackage(package_id) { + const client = APIClient.erm + client.EBSCOPackages.get(package_id).then( + erm_package => { + this.erm_package = erm_package + this.initialized = true + this.updating_is_selected = false + }, + error => {} + ) }, edit_selected(is_selected) { this.updating_is_selected = true diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsEBSCOResourcesShow.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsEBSCOResourcesShow.vue index fc4a9fbf37..e764194e93 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsEBSCOResourcesShow.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsEBSCOResourcesShow.vue @@ -115,9 +115,9 @@