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

(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Dialog.vue (-10 / +43 lines)
Lines 3-16 Link Here
3
    <div class="dialog alert" v-if="error" v-html="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
        <span v-html="warning"></span>
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
        >
14
        <a
6
        <a
15
            id="close_modal"
7
            id="close_modal"
16
            class="btn btn-default btn-xs"
8
            class="btn btn-default btn-xs"
Lines 19-24 Link Here
19
            >{{ $__("Close") }}</a
11
            >{{ $__("Close") }}</a
20
        >
12
        >
21
    </div>
13
    </div>
14
    <div class="modal_centered" v-if="confirmation">
15
        <div class="dialog alert confirmation">
16
            <span v-html="confirmation"></span>
17
            <a
18
                v-if="accept"
19
                id="close_modal"
20
                class="btn btn-primary btn-xs"
21
                role="button"
22
                @click="accept"
23
                >{{ $__("Accept") }}</a
24
            >
25
            <a
26
                id="close_modal"
27
                class="btn btn-default btn-xs"
28
                role="button"
29
                @click="removeMessages"
30
                >{{ $__("Close") }}</a
31
            >
32
        </div>
33
    </div>
22
    <!-- Must be styled differently -->
34
    <!-- Must be styled differently -->
23
35
24
    <div class="modal_centered" v-if="is_submitting">
36
    <div class="modal_centered" v-if="is_submitting">
Lines 35-47 import { storeToRefs } from "pinia" Link Here
35
export default {
47
export default {
36
    setup() {
48
    setup() {
37
        const mainStore = inject("mainStore")
49
        const mainStore = inject("mainStore")
38
        const { message, error, warning, accept, is_submitting, is_loading } =
50
        const {
39
            storeToRefs(mainStore)
51
            message,
52
            error,
53
            warning,
54
            confirmation,
55
            accept,
56
            is_submitting,
57
            is_loading,
58
        } = storeToRefs(mainStore)
40
        const { removeMessages } = mainStore
59
        const { removeMessages } = mainStore
41
        return {
60
        return {
42
            message,
61
            message,
43
            error,
62
            error,
44
            warning,
63
            warning,
64
            confirmation,
45
            accept,
65
            accept,
46
            is_submitting,
66
            is_submitting,
47
            is_loading,
67
            is_loading,
Lines 84-87 export default { Link Here
84
    left: 40%;
104
    left: 40%;
85
    width: 10%;
105
    width: 10%;
86
}
106
}
107
108
.confirmation {
109
    position: absolute;
110
    top: 25%;
111
    left: 40%;
112
113
    display: flex;
114
    width: 50%;
115
    min-height: 10%;
116
    margin: auto;
117
    align-items: center;
118
    justify-content: center;
119
}
87
</style>
120
</style>
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsList.vue (-13 / +16 lines)
Lines 49-55 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")
52
        const { setConfirmation, setMessage } = inject("mainStore")
53
53
54
        const table_id = "agreement_list"
54
        const table_id = "agreement_list"
55
        useDataTable(table_id)
55
        useDataTable(table_id)
Lines 59-65 export default { Link Here
59
            get_lib_from_av,
59
            get_lib_from_av,
60
            map_av_dt_filter,
60
            map_av_dt_filter,
61
            table_id,
61
            table_id,
62
            setWarning,
62
            setConfirmation,
63
            setMessage,
63
            setMessage,
64
        }
64
        }
65
    },
65
    },
Lines 115-136 export default { Link Here
115
            )
115
            )
116
        },
116
        },
117
        delete_agreement: function (agreement_id) {
117
        delete_agreement: function (agreement_id) {
118
            this.setWarning(this.$__("Are you sure you want to remove this agreement?"), () => {
118
            this.setConfirmation(
119
                const client = APIClient.erm
119
                this.$__("Are you sure you want to remove this agreement?"),
120
                client.agreements.delete(agreement_id).then(
120
                () => {
121
                    success => {
121
                    const client = APIClient.erm
122
                        this.setMessage(this.$__("Agreement deleted"))
122
                    client.agreements.delete(agreement_id).then(
123
                        this.refresh_table()
123
                        success => {
124
                    },
124
                            this.setMessage(this.$__("Agreement deleted"))
125
                    error => {}
125
                            this.refresh_table()
126
                )
126
                        },
127
            })
127
                        error => {}
128
                    )
129
                }
130
            )
128
        },
131
        },
129
        select_agreement: function (agreement_id) {
132
        select_agreement: function (agreement_id) {
130
            this.$emit("select-agreement", agreement_id)
133
            this.$emit("select-agreement", agreement_id)
131
            this.$emit("close")
134
            this.$emit("close")
132
        },
135
        },
133
        refresh_table: function(){
136
        refresh_table: function () {
134
            $("#" + this.table_id)
137
            $("#" + this.table_id)
135
                .DataTable()
138
                .DataTable()
136
                .ajax.url(this.datatable_url)
139
                .ajax.url(this.datatable_url)
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/stores/main.js (-3 / +19 lines)
Lines 5-10 export const useMainStore = defineStore("main", { Link Here
5
        _message: null,
5
        _message: null,
6
        _error: null,
6
        _error: null,
7
        _warning: null,
7
        _warning: null,
8
        _confirmation: null,
8
        _accept: null,
9
        _accept: null,
9
        previousMessage: null,
10
        previousMessage: null,
10
        previousError: null,
11
        previousError: null,
Lines 17-46 export const useMainStore = defineStore("main", { Link Here
17
            this._error = null;
18
            this._error = null;
18
            this._warning = null;
19
            this._warning = null;
19
            this._message = message;
20
            this._message = message;
21
            this._confirmation = null;
20
            this.displayed_already = displayed; /* Will be displayed on the next view */
22
            this.displayed_already = displayed; /* Will be displayed on the next view */
21
        },
23
        },
22
        setError(error, displayed = true) {
24
        setError(error, displayed = true) {
23
            this._error = error;
25
            this._error = error;
26
            this._warning = null;
24
            this._message = null;
27
            this._message = null;
28
            this._confirmation = null;
25
            this.displayed_already = displayed; /* Is displayed on the current view */
29
            this.displayed_already = displayed; /* Is displayed on the current view */
26
        },
30
        },
27
        setWarning(warning, accept, displayed = true) {
31
        setWarning(warning, accept, displayed = true) {
32
            this._error = null;
33
            this._warning = warning;
34
            this._message = null;
35
            this._confirmation = null;
36
            this.displayed_already = displayed; /* Is displayed on the current view */
37
        },
38
        setConfirmation(confirmation, accept, displayed = true){
28
            if(accept) {
39
            if(accept) {
29
                this._accept = async () => {
40
                this._accept = async () => {
30
                    await accept()
41
                    await accept()
31
                    this.removeMessages()
42
                    this.removeMessages()
32
                }
43
                }
33
            }
44
            }
34
            this._warning = warning;
45
            this._error = null;
46
            this._warning = null;
35
            this._message = null;
47
            this._message = null;
48
            this._confirmation = confirmation;
36
            this.displayed_already = displayed; /* Is displayed on the current view */
49
            this.displayed_already = displayed; /* Is displayed on the current view */
37
        },
50
        },
38
        removeMessages() {
51
        removeMessages() {
39
            if (this.displayed_already) {
52
            if (this.displayed_already) {
40
                this._accept = null;
41
                this._error = null;
53
                this._error = null;
42
                this._warning = null;
54
                this._warning = null;
43
                this._message = null;
55
                this._message = null;
56
                this._confirmation = null;
57
                this._accept = null;
44
            }
58
            }
45
            this.displayed_already = true;
59
            this.displayed_already = true;
46
        },
60
        },
Lines 67-72 export const useMainStore = defineStore("main", { Link Here
67
        message() {
81
        message() {
68
            return this._message
82
            return this._message
69
        },
83
        },
84
        confirmation() {
85
            return this._confirmation
86
        },
70
        accept() {
87
        accept() {
71
            return this._accept
88
            return this._accept
72
        },
89
        },
73
- 

Return to bug 32991