Bugzilla – Attachment 147315 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: Use APIClient to fetch patrons
Bug-32939-Use-APIClient-to-fetch-patrons.patch (text/plain), 3.67 KB, created by
Nick Clemens (kidclamp)
on 2023-02-24 12:22:49 UTC
(
hide
)
Description:
Bug 32939: Use APIClient to fetch patrons
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2023-02-24 12:22:49 UTC
Size:
3.67 KB
patch
obsolete
>From 6fe4f2569a0dd637c9d1f30d1abd8709c63d0029 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 21 Feb 2023 10:14:55 +0100 >Subject: [PATCH] Bug 32939: Use APIClient to fetch patrons > >Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com> >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > .../prog/js/vue/components/ERM/UserRoles.vue | 5 +++-- > .../prog/js/vue/fetch/api-client.js | 2 ++ > .../intranet-tmpl/prog/js/vue/fetch/erm.js | 6 ------ > .../prog/js/vue/fetch/patron-api-client.js | 20 +++++++++++++++++++ > 4 files changed, 25 insertions(+), 8 deletions(-) > create mode 100644 koha-tmpl/intranet-tmpl/prog/js/vue/fetch/patron-api-client.js > >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/UserRoles.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/UserRoles.vue >index 6848b047c6..22237fb8e8 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/UserRoles.vue >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/UserRoles.vue >@@ -64,7 +64,7 @@ > </template> > > <script> >-import { fetchPatron } from "../../fetch/erm.js" >+import { APIClient } from "../../fetch/api-client.js" > > export default { > name: "UserRoles", >@@ -110,8 +110,9 @@ export default { > let selected_patron_id = > document.getElementById("selected_patron_id").value > let patron >+ const client = APIClient.patron > // FIXME We are missing a "loading..." >- fetchPatron(selected_patron_id).then(p => { >+ client.patrons.get(selected_patron_id).then(p => { > patron = p > this.user_roles[c].patron = patron > this.user_roles[c].patron_str = $patron_to_html(patron) >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 >index 61b2dcb606..0b11b7f6d0 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/api-client.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/api-client.js >@@ -1,5 +1,7 @@ > import ERMAPIClient from "./erm-api-client"; >+import PatronAPIClient from "./patron-api-client"; > > export const APIClient = { > erm: new ERMAPIClient(), >+ patron: new PatronAPIClient(), > }; >\ No newline at end of file >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/erm.js b/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/erm.js >index 1526853330..9d8a245933 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/erm.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/erm.js >@@ -2,12 +2,6 @@ import { setError } from "../messages"; > > //TODO: all of these functions should be deleted and reimplemented in the components using ERMAPIClient > >-export const fetchPatron = function (patron_id) { >- if (!patron_id) return; >- const apiUrl = "/api/v1/patrons/" + patron_id; >- return myFetch(apiUrl); >-}; >- > export const fetchVendors = function () { > const apiUrl = "/api/v1/acquisitions/vendors?_per_page=-1"; > return myFetch(apiUrl); >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/patron-api-client.js b/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/patron-api-client.js >new file mode 100644 >index 0000000000..2e57e1ea49 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/patron-api-client.js >@@ -0,0 +1,20 @@ >+import HttpClient from "./http-client"; >+ >+export class PatronAPIClient extends HttpClient { >+ constructor() { >+ super({ >+ baseURL: "/api/v1/", >+ }); >+ } >+ >+ get patrons() { >+ return { >+ get: (id) => >+ this.get({ >+ endpoint: "patrons/" + id, >+ }), >+ }; >+ } >+} >+ >+export default PatronAPIClient; >-- >2.30.2
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