From 12b7cb94c2f22af1db045203267b58a8ffa48bed Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 30 Jan 2025 10:06:18 +0100 Subject: [PATCH] Bug 38993: Restore add patrons to list --- .../prog/js/fetch/patron-api-client.js | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/fetch/patron-api-client.js b/koha-tmpl/intranet-tmpl/prog/js/fetch/patron-api-client.js index 835952242b3..666aa639d27 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/fetch/patron-api-client.js +++ b/koha-tmpl/intranet-tmpl/prog/js/fetch/patron-api-client.js @@ -1,7 +1,7 @@ export class PatronAPIClient { constructor(HttpClient) { this.httpClient = new HttpClient({ - baseURL: "/api/v1/", + baseURL: "", }); } @@ -9,10 +9,30 @@ export class PatronAPIClient { return { get: id => this.httpClient.get({ - endpoint: "patrons/" + id, + endpoint: "/api/v1/patrons/" + id, }), }; } + + get lists() { + return { + add_patrons: ({ patron_ids, list_id, new_list_name }) => + this.httpClient.post({ + endpoint: "/cgi-bin/koha/svc/members/add_to_list", + body: "add_to_patron_list=%s&new_patron_list=%s&%s".format( + list_id, + new_list_name, + patron_ids + .map(id => "borrowernumber=%s".format(id)) + .join("&") + ), + headers: { + "Content-Type": + "application/x-www-form-urlencoded;charset=utf-8", + }, + }), + }; + } } export default PatronAPIClient; -- 2.34.1