Bug 38993: Restore add patrons to list

Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Jonathan Druart 2025-01-30 10:06:18 +01:00 committed by Katrin Fischer
parent 72c45bd209
commit d85c6ec0b4
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
4 changed files with 34 additions and 3 deletions

View File

@ -309,7 +309,7 @@
function patronListAdd() {
var borrowernumbers = JSON.parse(localStorage.getItem("patron_search_selections")) || [];
if (borrowernumbers.length > 0) {
const client = APIClient.patron;
const client = APIClient.patron_list;
client.lists.add_patrons({ patron_ids: borrowernumbers, new_list_name: $("#new_patron_list").val(), list_id: $("#add_to_patron_list").val() }).then(
success => {
$("#patron_list_dialog").show();

View File

@ -8,6 +8,7 @@ import ClubAPIClient from "./club-api-client.js";
import CoverImageAPIClient from "./cover-image-api-client.js";
import LocalizationAPIClient from "./localization-api-client.js";
import PatronAPIClient from "./patron-api-client.js";
import PatronListAPIClient from "./patron-list-api-client.js";
import RecallAPIClient from "./recall-api-client.js";
import SysprefAPIClient from "./system-preferences-api-client.js";
import TicketAPIClient from "./ticket-api-client.js";
@ -21,6 +22,7 @@ export const APIClient = {
cover_image: new CoverImageAPIClient(HttpClient),
localization: new LocalizationAPIClient(HttpClient),
patron: new PatronAPIClient(HttpClient),
patron_list: new PatronListAPIClient(HttpClient),
recall: new RecallAPIClient(HttpClient),
sysprefs: new SysprefAPIClient(HttpClient),
ticket: new TicketAPIClient(HttpClient),

View File

@ -1,7 +1,7 @@
export class PatronAPIClient {
constructor(HttpClient) {
this.httpClient = new HttpClient({
baseURL: "/api/v1/",
baseURL: "/api/v1/patrons/",
});
}
@ -9,7 +9,7 @@ export class PatronAPIClient {
return {
get: id =>
this.httpClient.get({
endpoint: "patrons/" + id,
endpoint: id,
}),
};
}

View File

@ -0,0 +1,29 @@
export class PatronAPIClient {
constructor(HttpClient) {
this.httpClient = new HttpClient({
baseURL: "/cgi-bin/koha/svc/",
});
}
get lists() {
return {
add_patrons: ({ patron_ids, list_id, new_list_name }) =>
this.httpClient.post({
endpoint: "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;