Bugzilla – Attachment 146669 Details for
Bug 32939
Have generic fetch functions in vue modules
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 32939: Have a generic APIClient object
Bug-32939-Have-a-generic-APIClient-object.patch (text/plain), 6.23 KB, created by
Jonathan Druart
on 2023-02-15 09:45:30 UTC
(
hide
)
Description:
Bug 32939: Have a generic APIClient object
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2023-02-15 09:45:30 UTC
Size:
6.23 KB
patch
obsolete
>From f282de63f248890471e83a0c1f178897052ec829 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >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. >--- > .../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 cb69d3e6490..52093af883b 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 = new 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 e82d067fa1a..257a5de33f2 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 @@ > </template> > > <script> >-import { ERMAPIClient } from "../../fetch/erm-api-client.js" >+import { APIClient } from "../../fetch/api-client.js" > import { setMessage, setError } from "../../messages" > > export default { >@@ -53,7 +53,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 >@@ -66,7 +66,7 @@ export default { > onSubmit(e) { > e.preventDefault() > >- const client = new ERMAPIClient() >+ const client = APIClient.erm > ;(async () => { > try { > await client.agreements >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsList.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsList.vue >index 458616b3f1a..1684c245917 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsList.vue >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsList.vue >@@ -37,7 +37,7 @@ > import flatPickr from "vue-flatpickr-component" > import Toolbar from "./AgreementsToolbar.vue" > import { inject, createVNode, render } from "vue" >-import { ERMAPIClient } from "../../fetch/erm-api-client.js" >+import { APIClient } from "../../fetch/api-client.js" > import { storeToRefs } from "pinia" > import { useDataTable, build_url } from "../../composables/datatables" > >@@ -93,7 +93,7 @@ export default { > }, > methods: { > async getAgreements() { >- const client = new ERMAPIClient() >+ const client = APIClient.erm > const agreements = await client.agreements.getAll() > this.agreements = agreements > this.initialized = true >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsShow.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsShow.vue >index 65ac12d0ae9..ef882e019b8 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsShow.vue >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsShow.vue >@@ -300,7 +300,7 @@ > > <script> > import { inject } from "vue" >-import { ERMAPIClient } from "../../fetch/erm-api-client.js" >+import { APIClient } from "../../fetch/api-client.js" > import { setError } from "../../messages" > > export default { >@@ -347,7 +347,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 >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/api-client.js b/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/api-client.js >new file mode 100644 >index 00000000000..61b2dcb606f >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/api-client.js >@@ -0,0 +1,5 @@ >+import ERMAPIClient from "./erm-api-client"; >+ >+export const APIClient = { >+ erm: new ERMAPIClient(), >+}; >\ No newline at end of file >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/erm-api-client.js b/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/erm-api-client.js >index 76c4f2a5059..bdad9f6b179 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/erm-api-client.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/erm-api-client.js >@@ -43,4 +43,4 @@ export class ERMAPIClient extends HttpClient { > } > } > >-export default ERMAPIClient; >+export default ERMAPIClient; >\ No newline at end of file >-- >2.25.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 32939
:
146470
|
146509
|
146642
|
146644
|
146645
|
146668
|
146669
|
146670
|
146671
|
146672
|
146674
|
146675
|
146676
|
146677
|
146678
|
146679
|
146680
|
146681
|
146682
|
147029
|
147030
|
147031
|
147032
|
147033
|
147034
|
147035
|
147036
|
147037
|
147038
|
147039
|
147040
|
147041
|
147042
|
147043
|
147044
|
147056
|
147057
|
147059
|
147060
|
147061
|
147062
|
147063
|
147064
|
147065
|
147066
|
147067
|
147068
|
147069
|
147070
|
147071
|
147072
|
147073
|
147306
|
147307
|
147308
|
147309
|
147310
|
147311
|
147312
|
147313
|
147314
|
147315
|
147316
|
147317
|
147318
|
147319
|
147320
|
147321
|
147322
|
147332
|
149441