View | Details | Raw Unified | Return to bug 38993
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/member.tt (-1 / +1 lines)
Lines 309-315 Link Here
309
        function patronListAdd() {
309
        function patronListAdd() {
310
            var borrowernumbers = JSON.parse(localStorage.getItem("patron_search_selections")) || [];
310
            var borrowernumbers = JSON.parse(localStorage.getItem("patron_search_selections")) || [];
311
            if (borrowernumbers.length > 0) {
311
            if (borrowernumbers.length > 0) {
312
                const client = APIClient.patron;
312
                const client = APIClient.patron_list;
313
                client.lists.add_patrons({ patron_ids: borrowernumbers, new_list_name: $("#new_patron_list").val(), list_id: $("#add_to_patron_list").val() }).then(
313
                client.lists.add_patrons({ patron_ids: borrowernumbers, new_list_name: $("#new_patron_list").val(), list_id: $("#add_to_patron_list").val() }).then(
314
                    success => {
314
                    success => {
315
                        $("#patron_list_dialog").show();
315
                        $("#patron_list_dialog").show();
(-)a/koha-tmpl/intranet-tmpl/prog/js/fetch/api-client.js (+2 lines)
Lines 8-13 import ClubAPIClient from "./club-api-client.js"; Link Here
8
import CoverImageAPIClient from "./cover-image-api-client.js";
8
import CoverImageAPIClient from "./cover-image-api-client.js";
9
import LocalizationAPIClient from "./localization-api-client.js";
9
import LocalizationAPIClient from "./localization-api-client.js";
10
import PatronAPIClient from "./patron-api-client.js";
10
import PatronAPIClient from "./patron-api-client.js";
11
import PatronListAPIClient from "./patron-list-api-client.js";
11
import RecallAPIClient from "./recall-api-client.js";
12
import RecallAPIClient from "./recall-api-client.js";
12
import SysprefAPIClient from "./system-preferences-api-client.js";
13
import SysprefAPIClient from "./system-preferences-api-client.js";
13
import TicketAPIClient from "./ticket-api-client.js";
14
import TicketAPIClient from "./ticket-api-client.js";
Lines 21-26 export const APIClient = { Link Here
21
    cover_image: new CoverImageAPIClient(HttpClient),
22
    cover_image: new CoverImageAPIClient(HttpClient),
22
    localization: new LocalizationAPIClient(HttpClient),
23
    localization: new LocalizationAPIClient(HttpClient),
23
    patron: new PatronAPIClient(HttpClient),
24
    patron: new PatronAPIClient(HttpClient),
25
    patron_list: new PatronListAPIClient(HttpClient),
24
    recall: new RecallAPIClient(HttpClient),
26
    recall: new RecallAPIClient(HttpClient),
25
    sysprefs: new SysprefAPIClient(HttpClient),
27
    sysprefs: new SysprefAPIClient(HttpClient),
26
    ticket: new TicketAPIClient(HttpClient),
28
    ticket: new TicketAPIClient(HttpClient),
(-)a/koha-tmpl/intranet-tmpl/prog/js/fetch/patron-api-client.js (-2 / +2 lines)
Lines 1-7 Link Here
1
export class PatronAPIClient {
1
export class PatronAPIClient {
2
    constructor(HttpClient) {
2
    constructor(HttpClient) {
3
        this.httpClient = new HttpClient({
3
        this.httpClient = new HttpClient({
4
            baseURL: "/api/v1/",
4
            baseURL: "/api/v1/patrons/",
5
        });
5
        });
6
    }
6
    }
7
7
Lines 9-15 export class PatronAPIClient { Link Here
9
        return {
9
        return {
10
            get: id =>
10
            get: id =>
11
                this.httpClient.get({
11
                this.httpClient.get({
12
                    endpoint: "patrons/" + id,
12
                    endpoint: id,
13
                }),
13
                }),
14
        };
14
        };
15
    }
15
    }
(-)a/koha-tmpl/intranet-tmpl/prog/js/fetch/patron-list-api-client.js (-1 / +29 lines)
Line 0 Link Here
0
- 
1
export class PatronAPIClient {
2
    constructor(HttpClient) {
3
        this.httpClient = new HttpClient({
4
            baseURL: "/cgi-bin/koha/svc/",
5
        });
6
    }
7
8
    get lists() {
9
        return {
10
            add_patrons: ({ patron_ids, list_id, new_list_name }) =>
11
                this.httpClient.post({
12
                    endpoint: "members/add_to_list",
13
                    body: "add_to_patron_list=%s&new_patron_list=%s&%s".format(
14
                        list_id,
15
                        new_list_name,
16
                        patron_ids
17
                            .map(id => "borrowernumber=%s".format(id))
18
                            .join("&")
19
                    ),
20
                    headers: {
21
                        "Content-Type":
22
                            "application/x-www-form-urlencoded;charset=utf-8",
23
                    },
24
                }),
25
        };
26
    }
27
}
28
29
export default PatronAPIClient;

Return to bug 38993