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

(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/UserRoles.vue (-2 / +3 lines)
Lines 64-70 Link Here
64
</template>
64
</template>
65
65
66
<script>
66
<script>
67
import { fetchPatron } from "../../fetch/erm.js"
67
import { APIClient } from "../../fetch/api-client.js"
68
68
69
export default {
69
export default {
70
    name: "UserRoles",
70
    name: "UserRoles",
Lines 110-117 export default { Link Here
110
            let selected_patron_id =
110
            let selected_patron_id =
111
                document.getElementById("selected_patron_id").value
111
                document.getElementById("selected_patron_id").value
112
            let patron
112
            let patron
113
            const client = APIClient.patron
113
            // FIXME We are missing a "loading..."
114
            // FIXME We are missing a "loading..."
114
            fetchPatron(selected_patron_id).then(p => {
115
            client.patrons.get(selected_patron_id).then(p => {
115
                patron = p
116
                patron = p
116
                this.user_roles[c].patron = patron
117
                this.user_roles[c].patron = patron
117
                this.user_roles[c].patron_str = $patron_to_html(patron)
118
                this.user_roles[c].patron_str = $patron_to_html(patron)
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/api-client.js (+2 lines)
Lines 1-5 Link Here
1
import ERMAPIClient from "./erm-api-client";
1
import ERMAPIClient from "./erm-api-client";
2
import PatronAPIClient from "./patron-api-client";
2
3
3
export const APIClient = {
4
export const APIClient = {
4
    erm: new ERMAPIClient(),
5
    erm: new ERMAPIClient(),
6
    patron: new PatronAPIClient(),
5
};
7
};
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/erm.js (-6 lines)
Lines 2-13 import { setError } from "../messages"; Link Here
2
2
3
//TODO: all of these functions should be deleted and reimplemented in the components using ERMAPIClient
3
//TODO: all of these functions should be deleted and reimplemented in the components using ERMAPIClient
4
4
5
export const fetchPatron = function (patron_id) {
6
    if (!patron_id) return;
7
    const apiUrl = "/api/v1/patrons/" + patron_id;
8
    return myFetch(apiUrl);
9
};
10
11
export const fetchVendors = function () {
5
export const fetchVendors = function () {
12
    const apiUrl = "/api/v1/acquisitions/vendors?_per_page=-1";
6
    const apiUrl = "/api/v1/acquisitions/vendors?_per_page=-1";
13
    return myFetch(apiUrl);
7
    return myFetch(apiUrl);
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/patron-api-client.js (-1 / +20 lines)
Line 0 Link Here
0
- 
1
import HttpClient from "./http-client";
2
3
export class PatronAPIClient extends HttpClient {
4
    constructor() {
5
        super({
6
            baseURL: "/api/v1/",
7
        });
8
    }
9
10
    get patrons() {
11
        return {
12
            get: (id) =>
13
                this.get({
14
                    endpoint: "patrons/" + id,
15
                }),
16
        };
17
    }
18
}
19
20
export default PatronAPIClient;

Return to bug 32939