Bugzilla – Attachment 194293 Details for
Bug 14962
Temp Shelving Location / On Display Module
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14962: On Display code for API Clients
90bc14f.patch (text/plain), 11.10 KB, created by
Martin Renvoize (ashimema)
on 2026-03-02 10:23:22 UTC
(
hide
)
Description:
Bug 14962: On Display code for API Clients
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2026-03-02 10:23:22 UTC
Size:
11.10 KB
patch
obsolete
>From 90bc14ff8f4d5dfbffc43c201959b6fbc2779657 Mon Sep 17 00:00:00 2001 >From: Jake Deery <jake.deery@openfifth.co.uk> >Date: Mon, 1 Dec 2025 14:37:22 +0000 >Subject: [PATCH] Bug 14962: On Display code for API Clients > >This patch adds the required API clients for use with the On Display module. >Please see the test files commit for instructions on how to test this bundle of patches. > >Sponsored-by: ByWater Solutions >Signed-of-by: Martin Renvoize <martin.renvoize@openfifth.co.uk> >--- > .../intranet-tmpl/prog/js/fetch/api-client.js | 6 + > .../prog/js/fetch/biblio-api-client.js | 25 ++++ > .../prog/js/fetch/display-api-client.js | 121 ++++++++++++++++++ > .../prog/js/fetch/http-client.js | 6 + > .../prog/js/fetch/item-api-client.js | 12 ++ > .../prog/js/fetch/item-type-api-client.js | 21 +++ > .../prog/js/fetch/library-api-client.js | 21 +++ > 7 files changed, 212 insertions(+) > create mode 100644 koha-tmpl/intranet-tmpl/prog/js/fetch/biblio-api-client.js > create mode 100644 koha-tmpl/intranet-tmpl/prog/js/fetch/display-api-client.js > create mode 100644 koha-tmpl/intranet-tmpl/prog/js/fetch/item-type-api-client.js > create mode 100644 koha-tmpl/intranet-tmpl/prog/js/fetch/library-api-client.js > >diff --git a/koha-tmpl/intranet-tmpl/prog/js/fetch/api-client.js b/koha-tmpl/intranet-tmpl/prog/js/fetch/api-client.js >index 918947db605..b9c71db3b53 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/fetch/api-client.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/fetch/api-client.js >@@ -187,10 +187,16 @@ export const APIClient = { > () => import("./authorised-values-api-client.js") > ), > acquisition: createClientProxy(() => import("./acquisition-api-client.js")), >+ acquisition: createClientProxy(() => import("./acquisition-api-client.js")), >+ biblio: createClientProxy(() => import("./biblio-api-client.js")), > cataloguing: createClientProxy(() => import("./cataloguing-api-client.js")), > circulation: createClientProxy(() => import("./circulation-api-client.js")), > club: createClientProxy(() => import("./club-api-client.js")), > cover_image: createClientProxy(() => import("./cover-image-api-client.js")), >+ display: createClientProxy(() => import("./display-api-client.js")), >+ item: createClientProxy(() => import("./item-api-client.js")), >+ item_type: createClientProxy(() => import("./item-type-api-client.js")), >+ library: createClientProxy(() => import("./library-api-client.js")), > localization: createClientProxy( > () => import("./localization-api-client.js") > ), >diff --git a/koha-tmpl/intranet-tmpl/prog/js/fetch/biblio-api-client.js b/koha-tmpl/intranet-tmpl/prog/js/fetch/biblio-api-client.js >new file mode 100644 >index 00000000000..6a0ba72553d >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/js/fetch/biblio-api-client.js >@@ -0,0 +1,25 @@ >+export class BiblioAPIClient { >+ constructor(HttpClient) { >+ this.httpClient = new HttpClient({ >+ baseURL: "/api/v1/", >+ }); >+ } >+ >+ get biblios() { >+ return { >+ getAll: (query, params, headers) => >+ this.httpClient.getAll({ >+ endpoint: "biblios", >+ query, >+ params, >+ headers, >+ }), >+ get: id => >+ this.httpClient.get({ >+ endpoint: "items/" + id, >+ }), >+ }; >+ } >+} >+ >+export default BiblioAPIClient; >diff --git a/koha-tmpl/intranet-tmpl/prog/js/fetch/display-api-client.js b/koha-tmpl/intranet-tmpl/prog/js/fetch/display-api-client.js >new file mode 100644 >index 00000000000..d5490a789c7 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/js/fetch/display-api-client.js >@@ -0,0 +1,121 @@ >+export class DisplayAPIClient { >+ constructor(HttpClient) { >+ this.httpClientDisplaysConfig = new HttpClient({ >+ baseURL: "/api/v1/displays/config/", >+ }); >+ >+ this.httpClientDisplays = new HttpClient({ >+ baseURL: "/api/v1/displays/", >+ }); >+ >+ this.httpClientDisplayItems = new HttpClient({ >+ baseURL: "/api/v1/display/items/", >+ }); >+ } >+ >+ get config() { >+ return { >+ get: () => >+ this.httpClientDisplaysConfig.get({ >+ endpoint: "", >+ }), >+ }; >+ } >+ >+ get displays() { >+ return { >+ create: display => >+ this.httpClientDisplays.post({ >+ endpoint: "", >+ body: display, >+ }), >+ get: id => >+ this.httpClientDisplays.get({ >+ endpoint: "" + id, >+ headers: { >+ "x-koha-embed": "display_items,home_library,holding_library,item_type,+strings", >+ }, >+ }), >+ getAll: (query, params) => >+ this.httpClientDisplays.getAll({ >+ endpoint: "", >+ headers: { >+ "x-koha-embed": "display_items,home_library,holding_library,+strings", >+ }, >+ params, >+ query, >+ }), >+ update: (display, id) => >+ this.httpClientDisplays.put({ >+ endpoint: "" + id, >+ body: display, >+ }), >+ delete: id => >+ this.httpClientDisplays.delete({ >+ endpoint: "" + id, >+ }), >+ count: (query = {}) => >+ this.httpClientDisplays.count({ >+ endpoint: >+ "?" + >+ new URLSearchParams({ >+ _page: 1, >+ _per_page: 1, >+ ...(query && { q: JSON.stringify(query) }), >+ }), >+ }), >+ }; >+ } >+ >+ get displayItems() { >+ return { >+ create: displayItem => >+ this.httpClientDisplayItems.post({ >+ endpoint: "", >+ body: displayItem, >+ }), >+ get: (display_id, itemnumber) => >+ this.httpClientDisplayItems.get({ >+ endpoint: "" + display_id + "/" + itemnumber, >+ }), >+ getAll: (query, params) => >+ this.httpClientDisplayItems.getAll({ >+ endpoint: "", >+ query, >+ params, >+ }), >+ update: (displayItem, display_id, itemnumber) => >+ this.httpClientDisplayItems.put({ >+ endpoint: "" + display_id + "/" + itemnumber, >+ body: displayItem, >+ }), >+ delete: (display_id, itemnumber) => >+ this.httpClientDisplayItems.delete({ >+ endpoint: "" + display_id + "/" + itemnumber, >+ }), >+ batchAdd: displayItems => >+ this.httpClientDisplayItems.post({ >+ endpoint: "batch", >+ body: displayItems, >+ }), >+ batchDelete: displayItems => >+ this.httpClientDisplayItems.delete({ >+ endpoint: "batch", >+ body: displayItems, >+ parseResponse: true, >+ }), >+ count: (query = {}) => >+ this.httpClientDisplayItems.count({ >+ endpoint: >+ "?" + >+ new URLSearchParams({ >+ _page: 1, >+ _per_page: 1, >+ ...(query && { q: JSON.stringify(query) }), >+ }), >+ }), >+ }; >+ } >+} >+ >+export default DisplayAPIClient; >diff --git a/koha-tmpl/intranet-tmpl/prog/js/fetch/http-client.js b/koha-tmpl/intranet-tmpl/prog/js/fetch/http-client.js >index ee2722faa64..7cfc3539eb3 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/fetch/http-client.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/fetch/http-client.js >@@ -184,6 +184,11 @@ class HttpClient { > } > > delete(params = {}) { >+ const body = params.body >+ ? typeof params.body === "string" >+ ? params.body >+ : JSON.stringify(params.body) >+ : undefined; > let csrf_token = { "CSRF-TOKEN": this.csrf_token }; > let headers = { ...csrf_token, ...params.headers }; > return this._fetchJSON( >@@ -192,6 +197,7 @@ class HttpClient { > { > parseResponse: false, > ...params.options, >+ body, > method: "DELETE", > }, > params.return_response ?? true, >diff --git a/koha-tmpl/intranet-tmpl/prog/js/fetch/item-api-client.js b/koha-tmpl/intranet-tmpl/prog/js/fetch/item-api-client.js >index c4a31f0fed5..f94ff01e8ce 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/fetch/item-api-client.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/fetch/item-api-client.js >@@ -14,6 +14,18 @@ export class ItemAPIClient { > params, > headers, > }), >+ get: id => >+ this.httpClient.get({ >+ endpoint: "items/" + id, >+ }), >+ getByExternalId: external_id => >+ this.httpClient.get({ >+ endpoint: "items?" + >+ new URLSearchParams({ >+ _match: 'starts_with', >+ external_id: external_id, >+ }), >+ }), > }; > } > >diff --git a/koha-tmpl/intranet-tmpl/prog/js/fetch/item-type-api-client.js b/koha-tmpl/intranet-tmpl/prog/js/fetch/item-type-api-client.js >new file mode 100644 >index 00000000000..c4ac342f876 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/js/fetch/item-type-api-client.js >@@ -0,0 +1,21 @@ >+export class ItemTypeAPIClient { >+ constructor(HttpClient) { >+ this.httpClient = new HttpClient({ >+ baseURL: "/api/v1/", >+ }); >+ } >+ >+ get item_types() { >+ return { >+ getAll: (query, params, headers) => >+ this.httpClient.getAll({ >+ endpoint: "item_types", >+ query, >+ params, >+ headers, >+ }), >+ }; >+ } >+} >+ >+export default ItemTypeAPIClient; >diff --git a/koha-tmpl/intranet-tmpl/prog/js/fetch/library-api-client.js b/koha-tmpl/intranet-tmpl/prog/js/fetch/library-api-client.js >new file mode 100644 >index 00000000000..474a19d1d4e >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/js/fetch/library-api-client.js >@@ -0,0 +1,21 @@ >+export class LibraryAPIClient { >+ constructor(HttpClient) { >+ this.httpClient = new HttpClient({ >+ baseURL: "/api/v1/", >+ }); >+ } >+ >+ get libraries() { >+ return { >+ getAll: (query, params, headers) => >+ this.httpClient.getAll({ >+ endpoint: "libraries", >+ query, >+ params, >+ headers, >+ }), >+ }; >+ } >+} >+ >+export default LibraryAPIClient; >-- >2.53.0 >
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 14962
:
190216
|
190217
|
190218
|
190219
|
190220
|
190221
|
190222
|
190223
|
190224
|
190225
|
190226
|
190227
|
190228
|
190229
|
190230
|
190231
|
190232
|
190571
|
190572
|
193719
|
193720
|
193721
|
193722
|
193723
|
193724
|
193725
|
193726
|
193727
|
193728
|
193729
|
193730
|
193731
|
193732
|
193733
|
193734
|
193735
|
193736
|
193737
|
193738
|
193739
|
193740
|
193741
|
193742
|
193743
|
193744
|
193745
|
193746
|
193747
|
193748
|
193749
|
193750
|
193751
|
193752
|
193753
|
193754
|
193755
|
194285
|
194286
|
194287
|
194288
|
194289
|
194290
|
194291
|
194292
| 194293 |
194294
|
194295
|
194296
|
194297
|
194298
|
194299
|
194300
|
194301
|
194302
|
194303
|
194304
|
194305
|
194306
|
194307
|
194308
|
194309
|
194310
|
194311
|
194312
|
194313
|
194314
|
194315
|
194316
|
194317
|
194318
|
194320
|
194321
|
194322