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

(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsFormAdd.vue (-17 / +11 lines)
Lines 198-203 import { Link Here
198
    submitted,
198
    submitted,
199
} from "../../messages"
199
} from "../../messages"
200
import { fetchAgreement } from "../../fetch/erm.js"
200
import { fetchAgreement } from "../../fetch/erm.js"
201
import { submitToAPI } from "../../fetch/fetch.js"
201
import { storeToRefs } from "pinia"
202
import { storeToRefs } from "pinia"
202
203
203
export default {
204
export default {
Lines 390-412 export default { Link Here
390
                },
391
                },
391
            }
392
            }
392
393
393
            isSubmitting()
394
            submitToAPI(
394
            fetch(apiUrl, options)
395
                {
395
                .then(response => {
396
                    apiUrl: apiUrl,
396
                    if (response.status == 200) {
397
                    options: options,
397
                        this.$router.push("/cgi-bin/koha/erm/agreements")
398
                    success_redirect: '/cgi-bin/koha/erm/agreements',
398
                        setMessage(this.$__("Agreement updated"))
399
                    created_message: this.$__("Agreement created"),
399
                    } else if (response.status == 201) {
400
                    updated_message: this.$__("Agreement updated"),
400
                        this.$router.push("/cgi-bin/koha/erm/agreements")
401
                    router: this.$router
401
                        setMessage(this.$__("Agreement created"))
402
                }
402
                    } else {
403
            )
403
                        setError(response.message || response.statusText)
404
                    }
405
                })
406
                .catch(error => {
407
                    setError(error)
408
                })
409
                .then(() => submitted())
410
        },
404
        },
411
        onStatusChanged(e) {
405
        onStatusChanged(e) {
412
            if (e.authorised_value != "closed") {
406
            if (e.authorised_value != "closed") {
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/fetch.js (-1 / +26 lines)
Line 0 Link Here
0
- 
1
import {
2
    setMessage,
3
    setError,
4
    isSubmitting,
5
    submitted,
6
} from "../messages"
7
8
export const submitToAPI = async function (args) {
9
    isSubmitting()
10
    await fetch(args.apiUrl, args.options)
11
        .then(response => {
12
            if (response.status == 200) {
13
                args.router.push(args.success_redirect)
14
                setMessage(args.updated_message)
15
            } else if (response.status == 201) {
16
                args.router.push(args.success_redirect)
17
                setMessage(args.created_message)
18
            } else {
19
                setError(response.message || response.statusText)
20
            }
21
        })
22
        .catch(error => {
23
            setError(error)
24
        })
25
        .then(() => submitted())
26
};

Return to bug 32939