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

(-)a/koha-tmpl/intranet-tmpl/prog/js/fetch/api-client.js (+1 lines)
Lines 1-3 Link Here
1
/* keep tidy */
1
import ArticleRequestAPIClient from "./article-request-api-client.js";
2
import ArticleRequestAPIClient from "./article-request-api-client.js";
2
import AVAPIClient from "./authorised-value-api-client.js";
3
import AVAPIClient from "./authorised-value-api-client.js";
3
import CataloguingAPIClient from "./cataloguing-api-client.js";
4
import CataloguingAPIClient from "./cataloguing-api-client.js";
(-)a/koha-tmpl/intranet-tmpl/prog/js/fetch/article-request-api-client.js (+1 lines)
Lines 1-3 Link Here
1
/* keep tidy */
1
import HttpClient from "./http-client.js";
2
import HttpClient from "./http-client.js";
2
3
3
export class ArticleRequestAPIClient extends HttpClient {
4
export class ArticleRequestAPIClient extends HttpClient {
(-)a/koha-tmpl/intranet-tmpl/prog/js/fetch/authorised-value-api-client.js (-1 / +2 lines)
Lines 1-3 Link Here
1
/* keep tidy */
1
import HttpClient from "./http-client.js";
2
import HttpClient from "./http-client.js";
2
3
3
export class AVAPIClient extends HttpClient {
4
export class AVAPIClient extends HttpClient {
Lines 20-26 export class AVAPIClient extends HttpClient { Link Here
20
                        encodeURIComponent(value.category),
21
                        encodeURIComponent(value.category),
21
                        encodeURIComponent(value.value),
22
                        encodeURIComponent(value.value),
22
                        encodeURIComponent(value.description),
23
                        encodeURIComponent(value.description),
23
                        encodeURIComponent(value.opac_description),
24
                        encodeURIComponent(value.opac_description)
24
                    ),
25
                    ),
25
                }),
26
                }),
26
        };
27
        };
(-)a/koha-tmpl/intranet-tmpl/prog/js/fetch/cataloguing-api-client.js (+1 lines)
Lines 1-3 Link Here
1
/* keep tidy */
1
import HttpClient from "./http-client.js";
2
import HttpClient from "./http-client.js";
2
3
3
export class CataloguingAPIClient extends HttpClient {
4
export class CataloguingAPIClient extends HttpClient {
(-)a/koha-tmpl/intranet-tmpl/prog/js/fetch/circulation-api-client.js (-4 / +13 lines)
Lines 1-3 Link Here
1
/* keep tidy */
1
import HttpClient from "./http-client.js";
2
import HttpClient from "./http-client.js";
2
3
3
export class CirculationAPIClient extends HttpClient {
4
export class CirculationAPIClient extends HttpClient {
Lines 32-38 export class CirculationAPIClient extends HttpClient { Link Here
32
            renew: checkout =>
33
            renew: checkout =>
33
                this.post({
34
                this.post({
34
                    endpoint: "renew",
35
                    endpoint: "renew",
35
                    body: "itemnumber=%s&borrowernumber=%s&branchcode=%s&override_limit=%s".format(checkout.item_id, checkout.patron_id, checkout.library_id, checkout.override_limit),
36
                    body: "itemnumber=%s&borrowernumber=%s&branchcode=%s&override_limit=%s".format(
37
                        checkout.item_id,
38
                        checkout.patron_id,
39
                        checkout.library_id,
40
                        checkout.override_limit
41
                    ),
36
                    //+ ( checkout.seen !== undefined ? "&seen=%s".format(checkout.seen) : "" ) + (checkout.date_due !== undefined ? "&date_due=%s".format(checkout.date_due) : ""),
42
                    //+ ( checkout.seen !== undefined ? "&seen=%s".format(checkout.seen) : "" ) + (checkout.date_due !== undefined ? "&date_due=%s".format(checkout.date_due) : ""),
37
                    headers: {
43
                    headers: {
38
                        "Content-Type":
44
                        "Content-Type":
Lines 51-63 export class CirculationAPIClient extends HttpClient { Link Here
51
            mark_as_not_seen: checkout_id =>
57
            mark_as_not_seen: checkout_id =>
52
                this.post({
58
                this.post({
53
                    endpoint: "checkout_notes",
59
                    endpoint: "checkout_notes",
54
                    body: "issue_id=%s&op=%s".format(checkout_id, "cud-notseen"),
60
                    body: "issue_id=%s&op=%s".format(
61
                        checkout_id,
62
                        "cud-notseen"
63
                    ),
55
                    headers: {
64
                    headers: {
56
                        "Content-Type":
65
                        "Content-Type":
57
                            "application/x-www-form-urlencoded;charset=utf-8",
66
                            "application/x-www-form-urlencoded;charset=utf-8",
58
                    },
67
                    },
59
                })
68
                }),
60
        }
69
        };
61
    }
70
    }
62
}
71
}
63
72
(-)a/koha-tmpl/intranet-tmpl/prog/js/fetch/club-api-client.js (+1 lines)
Lines 1-3 Link Here
1
/* keep tidy */
1
import HttpClient from "./http-client.js";
2
import HttpClient from "./http-client.js";
2
3
3
export class ClubAPIClient extends HttpClient {
4
export class ClubAPIClient extends HttpClient {
(-)a/koha-tmpl/intranet-tmpl/prog/js/fetch/cover-image-api-client.js (+1 lines)
Lines 1-3 Link Here
1
/* keep tidy */
1
import HttpClient from "./http-client.js";
2
import HttpClient from "./http-client.js";
2
3
3
export class CoverImageAPIClient extends HttpClient {
4
export class CoverImageAPIClient extends HttpClient {
(-)a/koha-tmpl/intranet-tmpl/prog/js/fetch/http-client.js (-5 / +8 lines)
Lines 1-3 Link Here
1
/* keep tidy */
1
class Dialog {
2
class Dialog {
2
    constructor(options = {}) {}
3
    constructor(options = {}) {}
3
4
Lines 17-25 class Dialog { Link Here
17
class HttpClient {
18
class HttpClient {
18
    constructor(options = {}) {
19
    constructor(options = {}) {
19
        this._baseURL = options.baseURL || "";
20
        this._baseURL = options.baseURL || "";
20
        this._headers = options.headers || { // FIXME we actually need to merge the headers
21
        this._headers = options.headers || {
22
            // FIXME we actually need to merge the headers
21
            "Content-Type": "application/json;charset=utf-8",
23
            "Content-Type": "application/json;charset=utf-8",
22
            "X-Requested-With": "XMLHttpRequest"
24
            "X-Requested-With": "XMLHttpRequest",
23
        };
25
        };
24
        this.csrf_token = $('meta[name="csrf-token"]').attr("content");
26
        this.csrf_token = $('meta[name="csrf-token"]').attr("content");
25
    }
27
    }
Lines 38-44 class HttpClient { Link Here
38
            headers: { ...this._headers, ...headers },
40
            headers: { ...this._headers, ...headers },
39
        })
41
        })
40
            .then(response => {
42
            .then(response => {
41
                const is_json = response.headers.get("content-type")?.includes("application/json");
43
                const is_json = response.headers
44
                    .get("content-type")
45
                    ?.includes("application/json");
42
                if (!response.ok) {
46
                if (!response.ok) {
43
                    return response.text().then(text => {
47
                    return response.text().then(text => {
44
                        let message;
48
                        let message;
Lines 54-60 class HttpClient { Link Here
54
                        throw new Error(message);
58
                        throw new Error(message);
55
                    });
59
                    });
56
                }
60
                }
57
                if ( return_response || !is_json ) {
61
                if (return_response || !is_json) {
58
                    return response;
62
                    return response;
59
                }
63
                }
60
                return response.json();
64
                return response.json();
Lines 133-139 class HttpClient { Link Here
133
            true
137
            true
134
        );
138
        );
135
    }
139
    }
136
137
}
140
}
138
141
139
export default HttpClient;
142
export default HttpClient;
(-)a/koha-tmpl/intranet-tmpl/prog/js/fetch/localization-api-client.js (+1 lines)
Lines 1-3 Link Here
1
/* keep tidy */
1
import HttpClient from "./http-client.js";
2
import HttpClient from "./http-client.js";
2
3
3
export class LocalizationAPIClient extends HttpClient {
4
export class LocalizationAPIClient extends HttpClient {
(-)a/koha-tmpl/intranet-tmpl/prog/js/fetch/patron-api-client.js (+1 lines)
Lines 1-3 Link Here
1
/* keep tidy */
1
import HttpClient from "./http-client.js";
2
import HttpClient from "./http-client.js";
2
3
3
export class PatronAPIClient extends HttpClient {
4
export class PatronAPIClient extends HttpClient {
(-)a/koha-tmpl/intranet-tmpl/prog/js/fetch/recall-api-client.js (+1 lines)
Lines 1-3 Link Here
1
/* keep tidy */
1
import HttpClient from "./http-client.js";
2
import HttpClient from "./http-client.js";
2
3
3
export class RecallAPIClient extends HttpClient {
4
export class RecallAPIClient extends HttpClient {
(-)a/koha-tmpl/intranet-tmpl/prog/js/fetch/system-preferences-api-client.js (-1 / +5 lines)
Lines 1-3 Link Here
1
/* keep tidy */
1
import HttpClient from "./http-client.js";
2
import HttpClient from "./http-client.js";
2
3
3
export class SysprefAPIClient extends HttpClient {
4
export class SysprefAPIClient extends HttpClient {
Lines 32-38 export class SysprefAPIClient extends HttpClient { Link Here
32
                        .map(variable =>
33
                        .map(variable =>
33
                            sysprefs[variable].length
34
                            sysprefs[variable].length
34
                                ? sysprefs[variable].map(value =>
35
                                ? sysprefs[variable].map(value =>
35
                                      "%s=%s".format(variable, encodeURIComponent(value))
36
                                      "%s=%s".format(
37
                                          variable,
38
                                          encodeURIComponent(value)
39
                                      )
36
                                  )
40
                                  )
37
                                : "%s=".format(variable)
41
                                : "%s=".format(variable)
38
                        )
42
                        )
(-)a/koha-tmpl/intranet-tmpl/prog/js/fetch/ticket-api-client.js (-3 / +3 lines)
Lines 1-3 Link Here
1
/* keep tidy */
1
import HttpClient from "./http-client.js";
2
import HttpClient from "./http-client.js";
2
3
3
export class TicketAPIClient extends HttpClient {
4
export class TicketAPIClient extends HttpClient {
Lines 7-13 export class TicketAPIClient extends HttpClient { Link Here
7
        });
8
        });
8
    }
9
    }
9
10
10
    get tickets () {
11
    get tickets() {
11
        return {
12
        return {
12
            mark_as_viewed: ticket_id =>
13
            mark_as_viewed: ticket_id =>
13
                this.post({
14
                this.post({
Lines 36-42 export class TicketAPIClient extends HttpClient { Link Here
36
                            "application/x-www-form-urlencoded;charset=utf-8",
37
                            "application/x-www-form-urlencoded;charset=utf-8",
37
                    },
38
                    },
38
                }),
39
                }),
39
        }
40
        };
40
    }
41
    }
41
}
42
}
42
43
43
- 

Return to bug 36374