From 2c0a8b8b8bb224246b3a6992cc57841a482dc372 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 15 Feb 2023 09:35:19 +0100 Subject: [PATCH] Bug 32939: Have a generic APIClient object You always import the same, only once, and you can access other resources from the same object. Signed-off-by: Matt Blenkinsop Signed-off-by: Nick Clemens --- .../prog/js/vue/components/ERM/AgreementsFormAdd.vue | 6 +++--- .../js/vue/components/ERM/AgreementsFormConfirmDelete.vue | 6 +++--- .../prog/js/vue/components/ERM/AgreementsList.vue | 4 ++-- .../prog/js/vue/components/ERM/AgreementsShow.vue | 4 ++-- koha-tmpl/intranet-tmpl/prog/js/vue/fetch/api-client.js | 5 +++++ koha-tmpl/intranet-tmpl/prog/js/vue/fetch/erm-api-client.js | 2 +- 6 files changed, 16 insertions(+), 11 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/js/vue/fetch/api-client.js diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsFormAdd.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsFormAdd.vue index cb69d3e649..5c0932387e 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsFormAdd.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsFormAdd.vue @@ -190,7 +190,7 @@ import AgreementLicenses from "./AgreementLicenses.vue" import AgreementRelationships from "./AgreementRelationships.vue" import Documents from "./Documents.vue" import { setMessage, setError, setWarning } from "../../messages" -import { ERMAPIClient } from "../../fetch/erm-api-client.js" +import { APIClient } from "../../fetch/api-client.js" import { storeToRefs } from "pinia" export default { @@ -253,7 +253,7 @@ export default { }, methods: { async getAgreement(agreement_id) { - const client = new ERMAPIClient() + const client = APIClient.erm try { await client.agreements.get(agreement_id).then(data => { this.agreement = data @@ -375,7 +375,7 @@ export default { delete agreement.agreement_packages - const client = new ERMAPIClient() + const client = APIClient.erm ;(async () => { try { if (agreement_id) { diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsFormConfirmDelete.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsFormConfirmDelete.vue index e82d067fa1..257a5de33f 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsFormConfirmDelete.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsFormConfirmDelete.vue @@ -36,7 +36,7 @@