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

(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch.js (-28 / +26 lines)
Lines 1-9 Link Here
1
import { setError } from "./messages";
1
import { setError } from "./messages";
2
2
3
export const fetchAgreement = async function (agreement_id) {
3
export const fetchAgreement = function (agreement_id) {
4
    if (!agreement_id) return;
4
    if (!agreement_id) return;
5
    const apiUrl = "/api/v1/erm/agreements/" + agreement_id;
5
    const apiUrl = "/api/v1/erm/agreements/" + agreement_id;
6
    return await myFetch(apiUrl, {
6
    return myFetch(apiUrl, {
7
        headers: {
7
        headers: {
8
            "x-koha-embed":
8
            "x-koha-embed":
9
                "periods,user_roles,user_roles.patron,agreement_licenses,agreement_licenses.license,agreement_relationships,agreement_relationships.related_agreement,documents,agreement_packages,agreement_packages.package,vendor",
9
                "periods,user_roles,user_roles.patron,agreement_licenses,agreement_licenses.license,agreement_relationships,agreement_relationships.related_agreement,documents,agreement_packages,agreement_packages.package,vendor",
Lines 11-52 export const fetchAgreement = async function (agreement_id) { Link Here
11
    });
11
    });
12
};
12
};
13
13
14
export const fetchAgreements = async function () {
14
export const fetchAgreements = function () {
15
    const apiUrl = "/api/v1/erm/agreements?_per_page=-1";
15
    const apiUrl = "/api/v1/erm/agreements?_per_page=-1";
16
    return await myFetch(apiUrl);
16
    return myFetch(apiUrl);
17
};
17
};
18
18
19
export const fetchLicense = async function (license_id) {
19
export const fetchLicense = function (license_id) {
20
    if (!license_id) return;
20
    if (!license_id) return;
21
    const apiUrl = "/api/v1/erm/licenses/" + license_id;
21
    const apiUrl = "/api/v1/erm/licenses/" + license_id;
22
    return await myFetch(apiUrl, {
22
    return myFetch(apiUrl, {
23
        headers: {
23
        headers: {
24
            "x-koha-embed": "user_roles,user_roles.patron,vendor,documents",
24
            "x-koha-embed": "user_roles,user_roles.patron,vendor,documents",
25
        },
25
        },
26
    });
26
    });
27
};
27
};
28
28
29
export const fetchLicenses = async function () {
29
export const fetchLicenses = function () {
30
    const apiUrl = "/api/v1/erm/licenses?_per_page=-1";
30
    const apiUrl = "/api/v1/erm/licenses?_per_page=-1";
31
    return await myFetch(apiUrl, {
31
    return myFetch(apiUrl, {
32
        headers: {
32
        headers: {
33
            "x-koha-embed": "vendor.name",
33
            "x-koha-embed": "vendor.name",
34
        },
34
        },
35
    });
35
    });
36
};
36
};
37
37
38
export const fetchPatron = async function (patron_id) {
38
export const fetchPatron = function (patron_id) {
39
    if (!patron_id) return;
39
    if (!patron_id) return;
40
    const apiUrl = "/api/v1/patrons/" + patron_id;
40
    const apiUrl = "/api/v1/patrons/" + patron_id;
41
    return await myFetch(apiUrl);
41
    return myFetch(apiUrl);
42
};
42
};
43
43
44
export const fetchVendors = async function () {
44
export const fetchVendors = function () {
45
    const apiUrl = "/api/v1/acquisitions/vendors?_per_page=-1";
45
    const apiUrl = "/api/v1/acquisitions/vendors?_per_page=-1";
46
    return await myFetch(apiUrl);
46
    return myFetch(apiUrl);
47
};
47
};
48
48
49
const _createEditPackage = async function (method, erm_package) {
49
const _createEditPackage = function (method, erm_package) {
50
    let apiUrl = "/api/v1/erm/eholdings/local/packages";
50
    let apiUrl = "/api/v1/erm/eholdings/local/packages";
51
51
52
    if (method == "PUT") {
52
    if (method == "PUT") {
Lines 70-76 const _createEditPackage = async function (method, erm_package) { Link Here
70
        },
70
        },
71
    };
71
    };
72
72
73
    return await myFetch(apiUrl, options, 1);
73
    return myFetch(apiUrl, options, 1);
74
};
74
};
75
75
76
export const createPackage = function (erm_package) {
76
export const createPackage = function (erm_package) {
Lines 80-88 export const editPackage = function (erm_package) { Link Here
80
    return _createEditPackage("PUT", erm_package);
80
    return _createEditPackage("PUT", erm_package);
81
};
81
};
82
82
83
const _fetchPackage = async function (apiUrl, package_id) {
83
const _fetchPackage = function (apiUrl, package_id) {
84
    if (!package_id) return;
84
    if (!package_id) return;
85
    return await myFetch(apiUrl, {
85
    return myFetch(apiUrl, {
86
        headers: {
86
        headers: {
87
            "x-koha-embed":
87
            "x-koha-embed":
88
                "package_agreements,package_agreements.agreement,resources+count,vendor",
88
                "package_agreements,package_agreements.agreement,resources+count,vendor",
Lines 98-106 export const fetchEBSCOPackage = function (package_id) { Link Here
98
    return _fetchPackage(apiUrl, package_id);
98
    return _fetchPackage(apiUrl, package_id);
99
};
99
};
100
100
101
export const _fetchPackages = async function (apiUrl) {
101
export const _fetchPackages = function (apiUrl) {
102
    let packages;
102
    return myFetch(apiUrl, {
103
    return await myFetch(apiUrl, {
104
        headers: {
103
        headers: {
105
            "x-koha-embed": "resources+count,vendor.name",
104
            "x-koha-embed": "resources+count,vendor.name",
106
        },
105
        },
Lines 115-121 export const fetchEBSCOPackages = function () { Link Here
115
    return _fetchPackages(apiUrl);
114
    return _fetchPackages(apiUrl);
116
};
115
};
117
116
118
export const fetchLocalPackageCount = async function (filters) {
117
export const fetchLocalPackageCount = function (filters) {
119
    const q = filters
118
    const q = filters
120
        ? {
119
        ? {
121
              "me.name": { like: "%" + filters.package_name + "%" },
120
              "me.name": { like: "%" + filters.package_name + "%" },
Lines 131-142 export const fetchLocalPackageCount = async function (filters) { Link Here
131
        q: JSON.stringify(q),
130
        q: JSON.stringify(q),
132
    };
131
    };
133
    var apiUrl = "/api/v1/erm/eholdings/local/packages";
132
    var apiUrl = "/api/v1/erm/eholdings/local/packages";
134
    return await myFetchTotal(apiUrl + "?" + new URLSearchParams(params));
133
    return myFetchTotal(apiUrl + "?" + new URLSearchParams(params));
135
};
134
};
136
135
137
export const _fetchTitle = async function (apiUrl, title_id) {
136
export const _fetchTitle = function (apiUrl, title_id) {
138
    if (!title_id) return;
137
    if (!title_id) return;
139
    return await myFetch(apiUrl, {
138
    return myFetch(apiUrl, {
140
        headers: {
139
        headers: {
141
            "x-koha-embed": "resources,resources.package",
140
            "x-koha-embed": "resources,resources.package",
142
        },
141
        },
Lines 151-157 export const fetchEBSCOTitle = function (title_id) { Link Here
151
    return _fetchTitle(apiUrl, title_id);
150
    return _fetchTitle(apiUrl, title_id);
152
};
151
};
153
152
154
export const fetchLocalTitleCount = async function (filters) {
153
export const fetchLocalTitleCount = function (filters) {
155
    const q = filters
154
    const q = filters
156
        ? {
155
        ? {
157
              ...(filters.publication_title
156
              ...(filters.publication_title
Lines 172-183 export const fetchLocalTitleCount = async function (filters) { Link Here
172
        ...(q ? { q: JSON.stringify(q) } : {}),
171
        ...(q ? { q: JSON.stringify(q) } : {}),
173
    };
172
    };
174
    var apiUrl = "/api/v1/erm/eholdings/local/titles";
173
    var apiUrl = "/api/v1/erm/eholdings/local/titles";
175
    return await myFetchTotal(apiUrl + "?" + new URLSearchParams(params));
174
    return myFetchTotal(apiUrl + "?" + new URLSearchParams(params));
176
};
175
};
177
176
178
export const _fetchResource = async function (apiUrl, resource_id) {
177
export const _fetchResource = function (apiUrl, resource_id) {
179
    if (!resource_id) return;
178
    if (!resource_id) return;
180
    return await myFetch(apiUrl, {
179
    return myFetch(apiUrl, {
181
        headers: {
180
        headers: {
182
            "x-koha-embed": "title,package,vendor",
181
            "x-koha-embed": "title,package,vendor",
183
        },
182
        },
184
- 

Return to bug 32923