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 294-300 Link Here
294
        function patronListAdd(){
294
        function patronListAdd(){
295
            var borrowernumbers = JSON.parse( localStorage.getItem("patron_search_selections") ) || [];
295
            var borrowernumbers = JSON.parse( localStorage.getItem("patron_search_selections") ) || [];
296
            if ( borrowernumbers.length > 0 ){
296
            if ( borrowernumbers.length > 0 ){
297
                const client = APIClient.patron;
297
                const client = APIClient.patron_list;
298
                client.lists.add_patrons({patron_ids: borrowernumbers, new_list_name: $("#new_patron_list").val(), list_id: $("#add_to_patron_list").val()}).then(
298
                client.lists.add_patrons({patron_ids: borrowernumbers, new_list_name: $("#new_patron_list").val(), list_id: $("#add_to_patron_list").val()}).then(
299
                    success => {
299
                    success => {
300
                        $("#patron_list_dialog").show();
300
                        $("#patron_list_dialog").show();
(-)a/koha-tmpl/intranet-tmpl/prog/js/fetch/api-client.js (+2 lines)
Lines 9-14 import ClubAPIClient from "./club-api-client.js"; Link Here
9
import CoverImageAPIClient from "./cover-image-api-client.js";
9
import CoverImageAPIClient from "./cover-image-api-client.js";
10
import LocalizationAPIClient from "./localization-api-client.js";
10
import LocalizationAPIClient from "./localization-api-client.js";
11
import PatronAPIClient from "./patron-api-client.js";
11
import PatronAPIClient from "./patron-api-client.js";
12
import PatronListAPIClient from "./patron-list-api-client.js";
12
import RecallAPIClient from "./recall-api-client.js";
13
import RecallAPIClient from "./recall-api-client.js";
13
import SysprefAPIClient from "./system-preferences-api-client.js";
14
import SysprefAPIClient from "./system-preferences-api-client.js";
14
import TicketAPIClient from "./ticket-api-client.js";
15
import TicketAPIClient from "./ticket-api-client.js";
Lines 22-27 export const APIClient = { Link Here
22
    cover_image: new CoverImageAPIClient(HttpClient),
23
    cover_image: new CoverImageAPIClient(HttpClient),
23
    localization: new LocalizationAPIClient(HttpClient),
24
    localization: new LocalizationAPIClient(HttpClient),
24
    patron: new PatronAPIClient(HttpClient),
25
    patron: new PatronAPIClient(HttpClient),
26
    patron_list: new PatronListAPIClient(HttpClient),
25
    recall: new RecallAPIClient(HttpClient),
27
    recall: new RecallAPIClient(HttpClient),
26
    sysprefs: new SysprefAPIClient(HttpClient),
28
    sysprefs: new SysprefAPIClient(HttpClient),
27
    ticket: new TicketAPIClient(HttpClient),
29
    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