Bugzilla – Attachment 156019 Details for
Bug 34055
Add API client class to get items
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 34055: Add API client class to get items
Bug-34055-Add-API-client-class-to-get-items.patch (text/plain), 2.88 KB, created by
Chris Cormack
on 2023-09-21 21:34:04 UTC
(
hide
)
Description:
Bug 34055: Add API client class to get items
Filename:
MIME Type:
Creator:
Chris Cormack
Created:
2023-09-21 21:34:04 UTC
Size:
2.88 KB
patch
obsolete
>From 8720d3a36fad6e03205d4708f612a42c5bdad39c Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 25 Apr 2023 12:11:51 +0200 >Subject: [PATCH] Bug 34055: Add API client class to get items > >This patch add a new item-api-client.js API client to fetch items using >our /items REST API endpoint. > >Test plan: >Add the following two lines to one of the existing Vue component (in >data() for instance) and hit the view that is using it. > let client = APIClient.item > client.items.getAll().then((items) => console.log(items)) >Notice that you see all the items in the console. > >Sponsored-by: BULAC - http://www.bulac.fr/ >Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com> > >Was failing the pretty test, fixed with yarn pretty >Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz> >--- > .../prog/js/vue/fetch/api-client.js | 2 ++ > .../prog/js/vue/fetch/item-api-client.js | 26 +++++++++++++++++++ > 2 files changed, 28 insertions(+) > create mode 100644 koha-tmpl/intranet-tmpl/prog/js/vue/fetch/item-api-client.js > >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 6ac1717fbf9..e570309fa17 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 >@@ -2,6 +2,7 @@ import ERMAPIClient from "./erm-api-client"; > import PatronAPIClient from "./patron-api-client"; > import AcquisitionAPIClient from "./acquisition-api-client"; > import AVAPIClient from "./authorised-values-api-client"; >+import ItemAPIClient from "./item-api-client"; > import SysprefAPIClient from "./system-preferences-api-client"; > > export const APIClient = { >@@ -9,5 +10,6 @@ export const APIClient = { > patron: new PatronAPIClient(), > acquisition: new AcquisitionAPIClient(), > authorised_values: new AVAPIClient(), >+ item: new ItemAPIClient(), > sysprefs: new SysprefAPIClient(), > }; >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/item-api-client.js b/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/item-api-client.js >new file mode 100644 >index 00000000000..87df66c29a1 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/item-api-client.js >@@ -0,0 +1,26 @@ >+import HttpClient from "./http-client"; >+ >+export class ItemAPIClient extends HttpClient { >+ constructor() { >+ super({ >+ baseURL: "/api/v1/", >+ }); >+ } >+ >+ get items() { >+ return { >+ getAll: (query, params) => >+ this.get({ >+ endpoint: >+ "items?" + >+ new URLSearchParams({ >+ _per_page: -1, >+ ...(query && { q: JSON.stringify(query) }), >+ }), >+ ...params, >+ }), >+ }; >+ } >+} >+ >+export default ItemAPIClient; >-- >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 34055
:
152468
|
152470
|
153098
|
153529
|
153530
| 156019 |
156020