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

(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsEBSCOPackagesShow.vue (-18 / +8 lines)
Lines 170-195 export default { Link Here
170
        },
170
        },
171
        edit_selected(is_selected) {
171
        edit_selected(is_selected) {
172
            this.updating_is_selected = true
172
            this.updating_is_selected = true
173
            fetch(
173
            const client = APIClient.erm
174
                "/api/v1/erm/eholdings/ebsco/packages/" +
174
            client.EBSCOPackages.patch(this.erm_package.package_id, {
175
                    this.erm_package.package_id,
175
                is_selected,
176
                {
176
            }).then(
177
                    method: "PATCH",
177
                result => {
178
                    body: JSON.stringify({ is_selected }),
179
                    headers: {
180
                        Accept: "application/json",
181
                        "Content-Type": "application/json",
182
                    },
183
                }
184
            )
185
                .then(checkError)
186
                .then(result => {
187
                    // Refresh the page. We should not need that actually.
178
                    // Refresh the page. We should not need that actually.
188
                    this.getPackage(this.erm_package.package_id)
179
                    this.getPackage(this.erm_package.package_id)
189
                })
180
                },
190
                .catch(error => {
181
                error => {}
191
                    setError(error)
182
            )
192
                })
193
        },
183
        },
194
        add_to_holdings() {
184
        add_to_holdings() {
195
            this.edit_selected(true)
185
            this.edit_selected(true)
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsEBSCOResourcesShow.vue (-19 / +8 lines)
Lines 116-122 Link Here
116
<script>
116
<script>
117
import { inject } from "vue"
117
import { inject } from "vue"
118
import { storeToRefs } from "pinia"
118
import { storeToRefs } from "pinia"
119
import { checkError } from "../../fetch/erm.js"
120
import { APIClient } from "../../fetch/api-client.js"
119
import { APIClient } from "../../fetch/api-client.js"
121
120
122
export default {
121
export default {
Lines 169-194 export default { Link Here
169
        },
168
        },
170
        edit_selected(is_selected) {
169
        edit_selected(is_selected) {
171
            this.updating_is_selected = true
170
            this.updating_is_selected = true
172
            fetch(
171
            const client = APIClient.erm
173
                "/api/v1/erm/eholdings/ebsco/resources/" +
172
            client.EBSCOResources.patch(this.resource.resource_id, {
174
                    this.resource.resource_id,
173
                is_selected,
175
                {
174
            }).then(
176
                    method: "PATCH",
175
                result => {
177
                    body: JSON.stringify({ is_selected }),
178
                    headers: {
179
                        Accept: "application/json",
180
                        "Content-Type": "application/json",
181
                    },
182
                }
183
            )
184
                .then(checkError)
185
                .then(result => {
186
                    // Refresh the page. We should not need that actually.
176
                    // Refresh the page. We should not need that actually.
187
                    this.getResource(this.resource.resource_id)
177
                    this.getResource(this.resource.resource_id)
188
                })
178
                },
189
                .catch(error => {
179
                error => {}
190
                    setError(error)
180
            )
191
                })
192
        },
181
        },
193
        add_to_holdings() {
182
        add_to_holdings() {
194
            this.edit_selected(true)
183
            this.edit_selected(true)
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalTitlesFormImport.vue (-12 / +4 lines)
Lines 65-86 export default { Link Here
65
                return
65
                return
66
            }
66
            }
67
            if (!list_id) return
67
            if (!list_id) return
68
            await fetch("/api/v1/erm/eholdings/local/titles/import", {
68
            const client = APIClient.erm
69
                method: "POST",
69
            client.localTitles
70
                body: JSON.stringify({ list_id, package_id: this.package_id }),
70
                .import({ list_id, package_id: this.package_id })
71
                headers: {
72
                    Accept: "application/json",
73
                    "Content-Type": "application/json",
74
                },
75
            })
76
                .then(checkError)
77
                .then(
71
                .then(
78
                    result => {
72
                    result => {
79
                        this.job_id = result.job_id
73
                        this.job_id = result.job_id
80
                    },
74
                    },
81
                    error => {
75
                    error => {}
82
                        setError(error)
83
                    }
84
                )
76
                )
85
        },
77
        },
86
        build_datatable: function () {
78
        build_datatable: function () {
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/erm-api-client.js (-1 / +15 lines)
Lines 155-160 export class ERMAPIClient extends HttpClient { Link Here
155
                            ...(query && { q: JSON.stringify(query) }),
155
                            ...(query && { q: JSON.stringify(query) }),
156
                        }),
156
                        }),
157
                }),
157
                }),
158
            import: (body) =>
159
                this.post({
160
                    endpoint: "eholdings/local/titles/import",
161
                    body,
162
                }),
158
        };
163
        };
159
    }
164
    }
160
165
Lines 170-176 export class ERMAPIClient extends HttpClient { Link Here
170
        };
175
        };
171
    }
176
    }
172
177
173
174
    get EBSCOPackages() {
178
    get EBSCOPackages() {
175
        return {
179
        return {
176
            get: (id) =>
180
            get: (id) =>
Lines 191-196 export class ERMAPIClient extends HttpClient { Link Here
191
                        "x-koha-embed": "resources+count,vendor.name",
195
                        "x-koha-embed": "resources+count,vendor.name",
192
                    },
196
                    },
193
                }),
197
                }),
198
            patch: (id, body) =>
199
                this.patch({
200
                    endpoint: "eholdings/ebsco/packages/" + id,
201
                    body,
202
                }),
194
        };
203
        };
195
    }
204
    }
196
205
Lines 220-225 export class ERMAPIClient extends HttpClient { Link Here
220
                        "x-koha-embed": "title,package,vendor",
229
                        "x-koha-embed": "title,package,vendor",
221
                    },
230
                    },
222
                }),
231
                }),
232
            patch: (id, body) =>
233
                this.patch({
234
                    endpoint: "eholdings/ebsco/packages/" + id,
235
                    body,
236
                }),
223
        };
237
        };
224
    }
238
    }
225
}
239
}
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/http-client.js (-8 / +35 lines)
Lines 47-73 class HttpClient { Link Here
47
    }
47
    }
48
48
49
    post(params = {}) {
49
    post(params = {}) {
50
        const body = params.body
51
            ? typeof str === "string"
52
                ? params.body
53
                : JSON.stringify(params.body)
54
            : undefined;
50
        return this._fetchJSON(params.endpoint, params.headers, {
55
        return this._fetchJSON(params.endpoint, params.headers, {
51
            ...params.options,
56
            ...params.options,
52
            body: params.body ? JSON.stringify(params.body) : undefined,
57
            body,
53
            method: "POST",
58
            method: "POST",
54
        });
59
        });
55
    }
60
    }
56
61
57
    put(params = {}) {
62
    put(params = {}) {
63
        const body = params.body
64
            ? typeof str === "string"
65
                ? params.body
66
                : JSON.stringify(params.body)
67
            : undefined;
58
        return this._fetchJSON(params.endpoint, params.headers, {
68
        return this._fetchJSON(params.endpoint, params.headers, {
59
            ...params.options,
69
            ...params.options,
60
            body: params.body ? JSON.stringify(params.body) : undefined,
70
            body,
61
            method: "PUT",
71
            method: "PUT",
62
        });
72
        });
63
    }
73
    }
64
74
65
    delete(params = {}) {
75
    delete(params = {}) {
66
        return this._fetchJSON(params.endpoint, params.headers, {
76
        return this._fetchJSON(
67
            parseResponse: false,
77
            params.endpoint,
68
            ...params.options,
78
            params.headers,
69
            method: "DELETE",
79
            {
70
        }, true);
80
                parseResponse: false,
81
                ...params.options,
82
                method: "DELETE",
83
            },
84
            true
85
        );
71
    }
86
    }
72
87
73
    count(params = {}) {
88
    count(params = {}) {
Lines 84-89 class HttpClient { Link Here
84
        );
99
        );
85
    }
100
    }
86
101
102
    patch(params = {}) {
103
        const body = params.body
104
            ? typeof str === "string"
105
                ? params.body
106
                : JSON.stringify(params.body)
107
            : undefined;
108
        return this._fetchJSON(params.endpoint, params.headers, {
109
            ...params.options,
110
            body,
111
            method: "PATCH",
112
        });
113
    }
114
87
    checkError(response, return_response = 0) {
115
    checkError(response, return_response = 0) {
88
        if (response.status >= 200 && response.status <= 299) {
116
        if (response.status >= 200 && response.status <= 299) {
89
            return return_response ? response : response.json();
117
            return return_response ? response : response.json();
90
- 

Return to bug 32939