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 57-62 export default { Link Here
57
        const AVStore = inject("AVStore")
57
        const AVStore = inject("AVStore")
58
        const { get_lib_from_av, map_av_dt_filter } = AVStore
58
        const { get_lib_from_av, map_av_dt_filter } = AVStore
59
59
60
        const { setWarning, setMessage } = inject("mainStore")
61
60
        const table_id = "agreement_list"
62
        const table_id = "agreement_list"
61
        useDataTable(table_id)
63
        useDataTable(table_id)
62
64
Lines 66-71 export default { Link Here
66
            map_av_dt_filter,
68
            map_av_dt_filter,
67
            table_id,
69
            table_id,
68
            logged_in_user,
70
            logged_in_user,
71
            setWarning,
72
            setMessage,
69
        }
73
        }
70
    },
74
    },
71
    data: function () {
75
    data: function () {
Lines 121-134 export default { Link Here
121
            )
125
            )
122
        },
126
        },
123
        delete_agreement: function (agreement_id) {
127
        delete_agreement: function (agreement_id) {
124
            this.$router.push(
128
            this.setWarning(this.$__("Are you sure you want to remove this agreement?"), () => {
125
                "/cgi-bin/koha/erm/agreements/delete/" + agreement_id
129
                const client = APIClient.erm
126
            )
130
                client.agreements.delete(agreement_id).then(
131
                    success => {
132
                        this.setMessage(this.$__("Agreement deleted"))
133
                        this.refresh_table()
134
                    },
135
                    error => {}
136
                )
137
            })
127
        },
138
        },
128
        select_agreement: function (agreement_id) {
139
        select_agreement: function (agreement_id) {
129
            this.$emit("select-agreement", agreement_id)
140
            this.$emit("select-agreement", agreement_id)
130
            this.$emit("close")
141
            this.$emit("close")
131
        },
142
        },
143
        refresh_table: function(){
144
            $("#" + this.table_id)
145
                .DataTable()
146
                .ajax.url(this.datatable_url)
147
                .draw()
148
        },
132
        filter_table: async function () {
149
        filter_table: async function () {
133
            if (this.before_route_entered) {
150
            if (this.before_route_entered) {
134
                let new_route = build_url(
151
                let new_route = build_url(
Lines 143-152 export default { Link Here
143
                        .toISOString()
160
                        .toISOString()
144
                        .substring(0, 10)
161
                        .substring(0, 10)
145
            }
162
            }
146
            $("#" + this.table_id)
163
            this.refresh_table()
147
                .DataTable()
148
                .ajax.url(this.datatable_url)
149
                .draw()
150
        },
164
        },
151
        table_url: function () {},
165
        table_url: function () {},
152
        build_datatable: function () {
166
        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 200-206 export default { Link Here
200
                    }
200
                    }
201
                )
201
                )
202
            })
202
            })
203
            .then(() => (this.mainStore.is_loading = false))
203
            .then(() => (this.mainStore._is_loading = false))
204
    },
204
    },
205
    components: {
205
    components: {
206
        Breadcrumb,
206
        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