From bcfe7bacae0c6fa167145f01e57e2781ebc450ac Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 6 Jul 2023 16:13:22 +0200 Subject: [PATCH] Bug 34219: Allow getAll to receive additional URL parameters It's not possible to pass additional URL parameters. We need it at least for bug 32474. Signed-off-by: Pedro Amorim --- .../prog/js/vue/fetch/acquisition-api-client.js | 6 ++++-- .../prog/js/vue/fetch/erm-api-client.js | 15 +++++++++------ .../prog/js/vue/fetch/http-client.js | 1 + 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/acquisition-api-client.js b/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/acquisition-api-client.js index 4a4553506e..d3f4e5ddd2 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/acquisition-api-client.js +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/acquisition-api-client.js @@ -9,9 +9,11 @@ export class AcquisitionAPIClient extends HttpClient { get vendors() { return { - getAll: query => + getAll: (query, params) => this.get({ - endpoint: "vendors?" + (query || "_per_page=-1"), + endpoint: "vendors", + query, + params, headers: { "x-koha-embed": "aliases", }, 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 0acdcac5a4..7f3679bd08 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 @@ -26,10 +26,11 @@ export class ERMAPIClient extends HttpClient { "periods,user_roles,user_roles.patron,agreement_licenses,agreement_licenses.license,agreement_relationships,agreement_relationships.related_agreement,documents,agreement_packages,agreement_packages.package,vendor", }, }), - getAll: query => + getAll: (query, params) => this.getAll({ endpoint: "agreements", - query: query, + query, + params, }), delete: id => this.delete({ @@ -68,10 +69,11 @@ export class ERMAPIClient extends HttpClient { "user_roles,user_roles.patron,vendor,documents", }, }), - getAll: query => + getAll: (query, params) => this.getAll({ endpoint: "licenses", - query: query, + query, + params, headers: { "x-koha-embed": "vendor", }, @@ -113,10 +115,11 @@ export class ERMAPIClient extends HttpClient { "package_agreements,package_agreements.agreement,resources+count,vendor", }, }), - getAll: query => + getAll: (query, params) => this.getAll({ endpoint: "eholdings/local/packages", - query: query, + query, + params, headers: { "x-koha-embed": "resources+count,vendor.name", }, diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/http-client.js b/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/http-client.js index 936231c3f6..8d880d258e 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/http-client.js +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/http-client.js @@ -57,6 +57,7 @@ class HttpClient { "?" + new URLSearchParams({ _per_page: -1, + ...(params.params && params.params), ...(params.query && { q: JSON.stringify(params.query) }), }); return this._fetchJSON(url, params.headers, { -- 2.30.2