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

(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsFormAdd.vue (-22 / +22 lines)
Lines 254-267 export default { Link Here
254
    methods: {
254
    methods: {
255
        async getAgreement(agreement_id) {
255
        async getAgreement(agreement_id) {
256
            const client = APIClient.erm
256
            const client = APIClient.erm
257
            try {
257
            client.agreements.get(agreement_id).then(
258
                await client.agreements.get(agreement_id).then(data => {
258
                data => {
259
                    this.agreement = data
259
                    this.agreement = data
260
                    this.initialized = true
260
                    this.initialized = true
261
                })
261
                },
262
            } catch (err) {
262
                error => {}
263
                setError(err.message || err.statusText)
263
            )
264
            }
265
        },
264
        },
266
        checkForm(agreement) {
265
        checkForm(agreement) {
267
            let errors = []
266
            let errors = []
Lines 376-397 export default { Link Here
376
            delete agreement.agreement_packages
375
            delete agreement.agreement_packages
377
376
378
            const client = APIClient.erm
377
            const client = APIClient.erm
379
            ;(async () => {
378
            if (agreement_id) {
380
                try {
379
                client.agreements.update(agreement, agreement_id).then(
381
                    if (agreement_id) {
380
                    success => {
382
                        await client.agreements
381
                        setMessage(this.$__("Agreement updated"))
383
                            .update(agreement, agreement_id)
382
                        this.$router.push("/cgi-bin/koha/erm/agreements")
384
                            .then(setMessage(this.$__("Agreement updated")))
383
                    },
385
                    } else {
384
                    error => {}
386
                        await client.agreements
385
                )
387
                            .create(agreement)
386
            } else {
388
                            .then(setMessage(this.$__("Agreement created")))
387
                client.agreements.create(agreement).then(
389
                    }
388
                    success => {
390
                    this.$router.push("/cgi-bin/koha/erm/agreements")
389
                        setMessage(this.$__("Agreement created"))
391
                } catch (err) {
390
                        this.$router.push("/cgi-bin/koha/erm/agreements")
392
                    setError(err.message || err.statusText)
391
                    },
393
                }
392
                    error => {}
394
            })()
393
                )
394
            }
395
        },
395
        },
396
        onStatusChanged(e) {
396
        onStatusChanged(e) {
397
            if (e.authorised_value != "closed") {
397
            if (e.authorised_value != "closed") {
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsFormConfirmDelete.vue (-18 / +11 lines)
Lines 37-43 Link Here
37
37
38
<script>
38
<script>
39
import { APIClient } from "../../fetch/api-client.js"
39
import { APIClient } from "../../fetch/api-client.js"
40
import { setMessage, setError } from "../../messages"
40
import { setMessage } from "../../messages"
41
41
42
export default {
42
export default {
43
    data() {
43
    data() {
Lines 54-82 export default { Link Here
54
    methods: {
54
    methods: {
55
        async getAgreement(agreement_id) {
55
        async getAgreement(agreement_id) {
56
            const client = APIClient.erm
56
            const client = APIClient.erm
57
            try {
57
            client.agreements.get(agreement_id).then(data => {
58
                await client.agreements.get(agreement_id).then(data => {
58
                this.agreement = data
59
                    this.agreement = data
59
                this.initialized = true
60
                    this.initialized = true
60
            })
61
                })
62
            } catch (err) {
63
                setError(err.message || err.statusText)
64
            }
65
        },
61
        },
66
        onSubmit(e) {
62
        onSubmit(e) {
67
            e.preventDefault()
63
            e.preventDefault()
68
64
69
            const client = APIClient.erm
65
            const client = APIClient.erm
70
            ;(async () => {
66
            client.agreements.delete(this.agreement.agreement_id).then(
71
                try {
67
                success => {
72
                    await client.agreements
68
                    setMessage(this.$__("Agreement deleted"))
73
                        .delete(this.agreement.agreement_id)
74
                        .then(setMessage(this.$__("Agreement deleted")))
75
                    this.$router.push("/cgi-bin/koha/erm/agreements")
69
                    this.$router.push("/cgi-bin/koha/erm/agreements")
76
                } catch (err) {
70
                },
77
                    setError(err)
71
                error => {}
78
                }
72
            )
79
            })()
80
        },
73
        },
81
    },
74
    },
82
    name: "AgreementsFormConfirmDelete",
75
    name: "AgreementsFormConfirmDelete",
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsList.vue (-3 / +7 lines)
Lines 94-102 export default { Link Here
94
    methods: {
94
    methods: {
95
        async getAgreements() {
95
        async getAgreements() {
96
            const client = APIClient.erm
96
            const client = APIClient.erm
97
            const agreements = await client.agreements.getAll()
97
            await client.agreements.getAll().then(
98
            this.agreements = agreements
98
                data => {
99
            this.initialized = true
99
                    this.agreements = data
100
                    this.initialized = true
101
                },
102
                error => {}
103
            )
100
        },
104
        },
101
        show_agreement: function (agreement_id) {
105
        show_agreement: function (agreement_id) {
102
            this.$router.push("/cgi-bin/koha/erm/agreements/" + agreement_id)
106
            this.$router.push("/cgi-bin/koha/erm/agreements/" + agreement_id)
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsShow.vue (-7 / +5 lines)
Lines 301-307 Link Here
301
<script>
301
<script>
302
import { inject } from "vue"
302
import { inject } from "vue"
303
import { APIClient } from "../../fetch/api-client.js"
303
import { APIClient } from "../../fetch/api-client.js"
304
import { setError } from "../../messages"
305
304
306
export default {
305
export default {
307
    setup() {
306
    setup() {
Lines 348-361 export default { Link Here
348
    methods: {
347
    methods: {
349
        async getAgreement(agreement_id) {
348
        async getAgreement(agreement_id) {
350
            const client = APIClient.erm
349
            const client = APIClient.erm
351
            try {
350
            client.agreements.get(agreement_id).then(
352
                await client.agreements.get(agreement_id).then(data => {
351
                data => {
353
                    this.agreement = data
352
                    this.agreement = data
354
                    this.initialized = true
353
                    this.initialized = true
355
                })
354
                },
356
            } catch (err) {
355
                error => {}
357
                setError(err.message || err.statusText)
356
            )
358
            }
359
        },
357
        },
360
    },
358
    },
361
    name: "AgreementsShow",
359
    name: "AgreementsShow",
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/http-client.js (-6 / +10 lines)
Lines 14-20 class HttpClient { Link Here
14
        options = {},
14
        options = {},
15
        return_response = false
15
        return_response = false
16
    ) {
16
    ) {
17
        let res;
17
        let res, error;
18
        await fetch(this._baseURL + endpoint, {
18
        await fetch(this._baseURL + endpoint, {
19
            ...options,
19
            ...options,
20
            headers: { ...this._headers, ...headers },
20
            headers: { ...this._headers, ...headers },
Lines 24-36 class HttpClient { Link Here
24
                (result) => {
24
                (result) => {
25
                    res = result;
25
                    res = result;
26
                },
26
                },
27
                (error) => {
27
                (err) => {
28
                    setError(error.toString());
28
                    error = err;
29
                    setError(err.toString());
29
                }
30
                }
30
            )
31
            )
31
            .catch((error) => {
32
            .catch((err) => {
32
                setError(error);
33
                error = err;
34
                setError(err);
33
            });
35
            });
36
37
        if (error) throw Error(error);
38
34
        return res;
39
        return res;
35
    }
40
    }
36
41
37
- 

Return to bug 32939