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

(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Dialog.vue (-4 / +13 lines)
Lines 1-8 Link Here
1
<template>
1
<template>
2
    <div class="dialog message" v-if="message">{{ message }}</div>
2
    <div class="dialog message" v-if="message" v-html="message"></div>
3
    <div class="dialog alert" v-if="error">{{ error }}</div>
3
    <div class="dialog alert" v-if="error" v-html="error"></div>
4
    <div class="dialog alert modal" v-if="warning">
4
    <div class="dialog alert modal" v-if="warning">
5
        {{ warning }}
5
        <span v-html="warning"></span>
6
        <a
7
            v-if="accept"
8
            id="close_modal"
9
            class="btn btn-primary btn-xs"
10
            role="button"
11
            @click="accept"
12
            >{{ $__("Accept") }}</a
13
        >
6
        <a
14
        <a
7
            id="close_modal"
15
            id="close_modal"
8
            class="btn btn-default btn-xs"
16
            class="btn btn-default btn-xs"
Lines 27-39 import { storeToRefs } from "pinia" Link Here
27
export default {
35
export default {
28
    setup() {
36
    setup() {
29
        const mainStore = inject("mainStore")
37
        const mainStore = inject("mainStore")
30
        const { message, error, warning, is_submitting, is_loading } =
38
        const { message, error, warning, accept, is_submitting, is_loading } =
31
            storeToRefs(mainStore)
39
            storeToRefs(mainStore)
32
        const { removeMessages } = mainStore
40
        const { removeMessages } = mainStore
33
        return {
41
        return {
34
            message,
42
            message,
35
            error,
43
            error,
36
            warning,
44
            warning,
45
            accept,
37
            is_submitting,
46
            is_submitting,
38
            is_loading,
47
            is_loading,
39
            removeMessages,
48
            removeMessages,
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsList.vue (-7 / +21 lines)
Lines 49-54 export default { Link Here
49
        const AVStore = inject("AVStore")
49
        const AVStore = inject("AVStore")
50
        const { get_lib_from_av, map_av_dt_filter } = AVStore
50
        const { get_lib_from_av, map_av_dt_filter } = AVStore
51
51
52
        const { setWarning, setMessage } = inject("mainStore")
53
52
        const table_id = "agreement_list"
54
        const table_id = "agreement_list"
53
        useDataTable(table_id)
55
        useDataTable(table_id)
54
56
Lines 57-62 export default { Link Here
57
            get_lib_from_av,
59
            get_lib_from_av,
58
            map_av_dt_filter,
60
            map_av_dt_filter,
59
            table_id,
61
            table_id,
62
            setWarning,
63
            setMessage,
60
        }
64
        }
61
    },
65
    },
62
    data: function () {
66
    data: function () {
Lines 111-124 export default { Link Here
111
            )
115
            )
112
        },
116
        },
113
        delete_agreement: function (agreement_id) {
117
        delete_agreement: function (agreement_id) {
114
            this.$router.push(
118
            this.setWarning(this.$__("Are you sure you want to remove this agreement?"), () => {
115
                "/cgi-bin/koha/erm/agreements/delete/" + agreement_id
119
                const client = APIClient.erm
116
            )
120
                client.agreements.delete(agreement_id).then(
121
                    success => {
122
                        this.setMessage(this.$__("Agreement deleted"))
123
                        this.refresh_table()
124
                    },
125
                    error => {}
126
                )
127
            })
117
        },
128
        },
118
        select_agreement: function (agreement_id) {
129
        select_agreement: function (agreement_id) {
119
            this.$emit("select-agreement", agreement_id)
130
            this.$emit("select-agreement", agreement_id)
120
            this.$emit("close")
131
            this.$emit("close")
121
        },
132
        },
133
        refresh_table: function(){
134
            $("#" + this.table_id)
135
                .DataTable()
136
                .ajax.url(this.datatable_url)
137
                .draw()
138
        },
122
        filter_table: async function () {
139
        filter_table: async function () {
123
            if (this.before_route_entered) {
140
            if (this.before_route_entered) {
124
                let new_route = build_url(
141
                let new_route = build_url(
Lines 133-142 export default { Link Here
133
                        .toISOString()
150
                        .toISOString()
134
                        .substring(0, 10)
151
                        .substring(0, 10)
135
            }
152
            }
136
            $("#" + this.table_id)
153
            this.refresh_table()
137
                .DataTable()
138
                .ajax.url(this.datatable_url)
139
                .draw()
140
        },
154
        },
141
        table_url: function () {},
155
        table_url: function () {},
142
        build_datatable: function () {
156
        build_datatable: function () {
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/Main.vue (-5 / +5 lines)
Lines 1-5 Link Here
1
<template>
1
<template>
2
    <div v-if="is_loading">
2
    <div v-if="_is_loading">
3
        <Dialog />
3
        <Dialog />
4
    </div>
4
    </div>
5
    <div v-else-if="ERMModule">
5
    <div v-else-if="ERMModule">
Lines 139-145 export default { Link Here
139
139
140
        // Note that we cannot use loading and loaded from messages
140
        // Note that we cannot use loading and loaded from messages
141
        // Pinia is not initiated yet there
141
        // Pinia is not initiated yet there
142
        const { is_loading } = storeToRefs(mainStore)
142
        const { _is_loading } = storeToRefs(mainStore)
143
143
144
        return {
144
        return {
145
            vendorStore,
145
            vendorStore,
Lines 147-153 export default { Link Here
147
            mainStore,
147
            mainStore,
148
            erm_providers,
148
            erm_providers,
149
            ERMModule,
149
            ERMModule,
150
            is_loading,
150
            _is_loading,
151
        }
151
        }
152
    },
152
    },
153
    data() {
153
    data() {
Lines 156-162 export default { Link Here
156
        }
156
        }
157
    },
157
    },
158
    beforeCreate() {
158
    beforeCreate() {
159
        this.mainStore.is_loading = true
159
        this.mainStore._is_loading = true
160
160
161
        const acq_client = APIClient.acquisition
161
        const acq_client = APIClient.acquisition
162
        acq_client.vendors.getAll().then(
162
        acq_client.vendors.getAll().then(
Lines 189-195 export default { Link Here
189
                })
189
                })
190
            )
190
            )
191
        })
191
        })
192
        Promise.all(promises).then(() => (this.mainStore.is_loading = false))
192
        Promise.all(promises).then(() => (this.mainStore._is_loading = false))
193
    },
193
    },
194
    components: {
194
    components: {
195
        Breadcrumb,
195
        Breadcrumb,
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/stores/main.js (-28 / +55 lines)
Lines 2-52 import { defineStore } from "pinia"; Link Here
2
2
3
export const useMainStore = defineStore("main", {
3
export const useMainStore = defineStore("main", {
4
    state: () => ({
4
    state: () => ({
5
        message: null,
5
        _message: null,
6
        error: null,
6
        _error: null,
7
        warning: null,
7
        _warning: null,
8
        _accept: null,
8
        previousMessage: null,
9
        previousMessage: null,
9
        previousError: null,
10
        previousError: null,
10
        displayed_already: false,
11
        displayed_already: false,
11
        is_submitting: false,
12
        _is_submitting: false,
12
        is_loading: false,
13
        _is_loading: false,
13
    }),
14
    }),
14
    actions: {
15
    actions: {
15
        setMessage(message) {
16
        setMessage(message, displayed = false) {
16
            this.error = null;
17
            this._error = null;
17
            this.warning = null;
18
            this._warning = null;
18
            this.message = message;
19
            this._message = message;
19
            this.displayed_already = false; /* Will be displayed on the next view */
20
            this.displayed_already = displayed; /* Will be displayed on the next view */
20
        },
21
        },
21
        setError(error) {
22
        setError(error, displayed = true) {
22
            this.error = error;
23
            this._error = error;
23
            this.message = null;
24
            this._message = null;
24
            this.displayed_already = true; /* Is displayed on the current view */
25
            this.displayed_already = displayed; /* Is displayed on the current view */
25
        },
26
        },
26
        setWarning(warning) {
27
        setWarning(warning, accept, displayed = true) {
27
            this.warning = warning;
28
            if(accept) {
28
            this.message = null;
29
                this._accept = async () => {
29
            this.displayed_already = true; /* Is displayed on the current view */
30
                    await accept()
31
                    this.removeMessages()
32
                }
33
            }
34
            this._warning = warning;
35
            this._message = null;
36
            this.displayed_already = displayed; /* Is displayed on the current view */
30
        },
37
        },
31
        removeMessages() {
38
        removeMessages() {
32
            if (this.displayed_already) {
39
            if (this.displayed_already) {
33
                this.error = null;
40
                this._accept = null;
34
                this.warning = null;
41
                this._error = null;
35
                this.message = null;
42
                this._warning = null;
43
                this._message = null;
36
            }
44
            }
37
            this.displayed_already = true;
45
            this.displayed_already = true;
38
        },
46
        },
39
        submitting(){
47
        submitting(){
40
            this.is_submitting = true;
48
            this._is_submitting = true;
41
        },
49
        },
42
        submitted(){
50
        submitted(){
43
            this.is_submitting = false;
51
            this._is_submitting = false;
44
        },
52
        },
45
        loading(){
53
        loading(){
46
            this.is_loading = true;
54
            this._is_loading = true;
47
        },
55
        },
48
        loaded(){
56
        loaded(){
49
            this.is_loading = false;
57
            this._is_loading = false;
58
        },
59
    },
60
    getters: {
61
        error() {
62
            return this._error
63
        },
64
        warning() {
65
            return this._warning
66
        },
67
        message() {
68
            return this._message
69
        },
70
        accept() {
71
            return this._accept
72
        },
73
        is_submitting(){
74
            return this._is_submitting
75
        },
76
        is_loading(){
77
            return this._is_loading
50
        },
78
        },
51
    },
79
    },
52
});
80
});
53
- 

Return to bug 32991