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

(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/stores/main.js (-60 / +44 lines)
Lines 1-40 Link Here
1
import { defineStore } from "pinia";
1
import { defineStore } from "pinia";
2
import { reactive, toRefs } from "vue";
2
3
3
export const useMainStore = defineStore("main", {
4
export const useMainStore = defineStore("main", () => {
4
    state: () => ({
5
    const store = reactive({
5
        _message: null,
6
        message: null,
6
        _error: null,
7
        error: null,
7
        _warning: null,
8
        warning: null,
8
        _confirmation: null,
9
        confirmation: null,
9
        _accept_callback: null,
10
        accept_callback: null,
10
        previousMessage: null,
11
        previousMessage: null,
11
        previousError: null,
12
        previousError: null,
12
        displayed_already: false,
13
        displayed_already: false,
13
        _is_submitting: false,
14
        is_submitting: false,
14
        _is_loading: false,
15
        is_loading: false,
15
    }),
16
    });
16
    actions: {
17
18
    const actions = {
17
        setMessage(message, displayed = false) {
19
        setMessage(message, displayed = false) {
18
            this._error = null;
20
            this.error = null;
19
            this._warning = null;
21
            this.warning = null;
20
            this._message = message;
22
            this.message = message;
21
            this._confirmation = null;
23
            this.confirmation = null;
22
            this.displayed_already =
24
            this.displayed_already =
23
                displayed; /* Will be displayed on the next view */
25
                displayed; /* Will be displayed on the next view */
24
        },
26
        },
25
        setError(error, displayed = true) {
27
        setError(error, displayed = true) {
26
            this._error = error;
28
            this.error = error;
27
            this._warning = null;
29
            this.warning = null;
28
            this._message = null;
30
            this.message = null;
29
            this._confirmation = null;
31
            this.confirmation = null;
30
            this.displayed_already =
32
            this.displayed_already =
31
                displayed; /* Is displayed on the current view */
33
                displayed; /* Is displayed on the current view */
32
        },
34
        },
33
        setWarning(warning, displayed = true) {
35
        setWarning(warning, displayed = true) {
34
            this._error = null;
36
            this.error = null;
35
            this._warning = warning;
37
            this.warning = warning;
36
            this._message = null;
38
            this.message = null;
37
            this._confirmation = null;
39
            this.confirmation = null;
38
            this.displayed_already =
40
            this.displayed_already =
39
                displayed; /* Is displayed on the current view */
41
                displayed; /* Is displayed on the current view */
40
        },
42
        },
Lines 55-117 export const useMainStore = defineStore("main", { Link Here
55
         */
57
         */
56
        setConfirmationDialog(confirmation, accept_callback, displayed = true) {
58
        setConfirmationDialog(confirmation, accept_callback, displayed = true) {
57
            if (accept_callback) {
59
            if (accept_callback) {
58
                this._accept_callback = async () => {
60
                this.accept_callback = async () => {
59
                    await accept_callback(confirmation);
61
                    await accept_callback(confirmation);
60
                    this.removeConfirmationMessages();
62
                    this.removeConfirmationMessages();
61
                };
63
                };
62
            }
64
            }
63
            this._confirmation = confirmation;
65
            this.confirmation = confirmation;
64
            this.displayed_already =
66
            this.displayed_already =
65
                displayed; /* Is displayed on the current view */
67
                displayed; /* Is displayed on the current view */
66
        },
68
        },
67
        removeMessages() {
69
        removeMessages() {
68
            if (this.displayed_already) {
70
            if (this.displayed_already) {
69
                this._error = null;
71
                this.error = null;
70
                this._warning = null;
72
                this.warning = null;
71
                this._message = null;
73
                this.message = null;
72
                this._confirmation = null;
74
                this.confirmation = null;
73
                this._accept_callback = null;
75
                this.accept_callback = null;
74
            }
76
            }
75
            this.displayed_already = true;
77
            this.displayed_already = true;
76
        },
78
        },
77
        removeConfirmationMessages() {
79
        removeConfirmationMessages() {
78
            this._confirmation = null;
80
            this.confirmation = null;
79
            this._accept_callback = null;
81
            this.accept_callback = null;
80
        },
82
        },
81
        submitting() {
83
        submitting() {
82
            this._is_submitting = true;
84
            this.is_submitting = true;
83
        },
85
        },
84
        submitted() {
86
        submitted() {
85
            this._is_submitting = false;
87
            this.is_submitting = false;
86
        },
88
        },
87
        loading() {
89
        loading() {
88
            this._is_loading = true;
90
            this.is_loading = true;
89
        },
91
        },
90
        loaded() {
92
        loaded() {
91
            this._is_loading = false;
93
            this.is_loading = false;
92
        },
93
    },
94
    getters: {
95
        error() {
96
            return this._error;
97
        },
98
        warning() {
99
            return this._warning;
100
        },
101
        message() {
102
            return this._message;
103
        },
104
        confirmation() {
105
            return this._confirmation;
106
        },
94
        },
107
        accept_callback() {
95
    };
108
            return this._accept_callback;
96
109
        },
97
    return {
110
        is_submitting() {
98
        ...toRefs(store),
111
            return this._is_submitting;
99
        ...actions,
112
        },
100
    };
113
        is_loading() {
114
            return this._is_loading;
115
        },
116
    },
117
});
101
});
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/stores/navigation.js (-20 / +28 lines)
Lines 1-7 Link Here
1
import { defineStore } from "pinia";
1
import { defineStore } from "pinia";
2
import { reactive, toRefs, computed } from "vue";
2
3
3
export const useNavigationStore = defineStore("navigation", {
4
export const useNavigationStore = defineStore("navigation", () => {
4
    state: () => ({
5
    const store = reactive({
5
        routeState: {
6
        routeState: {
6
            alt: "Home",
7
            alt: "Home",
7
            href: "/cgi-bin/koha/mainpage.pl",
8
            href: "/cgi-bin/koha/mainpage.pl",
Lines 11-18 export const useNavigationStore = defineStore("navigation", { Link Here
11
        },
12
        },
12
        current: null,
13
        current: null,
13
        params: {},
14
        params: {},
14
    }),
15
    });
15
    actions: {
16
    const actions = {
16
        setRoutes(routesDef) {
17
        setRoutes(routesDef) {
17
            if (!Array.isArray(routesDef)) {
18
            if (!Array.isArray(routesDef)) {
18
                routesDef = [routesDef];
19
                routesDef = [routesDef];
Lines 68-84 export const useNavigationStore = defineStore("navigation", { Link Here
68
                child.meta.self = child;
69
                child.meta.self = child;
69
            }
70
            }
70
        },
71
        },
71
    },
72
    };
72
    getters: {
73
73
        breadcrumbs() {
74
    const getters = {
74
            if (this.current)
75
        breadcrumbs: computed(() => {
76
            if (store.current)
75
                return _buildFromCurrentMatches(
77
                return _buildFromCurrentMatches(
76
                    this.current,
78
                    store.current,
77
                    this.routeState,
79
                    store.routeState,
78
                    this.params
80
                    store.params
79
                );
81
                );
80
82
81
            return _getBaseElements(this.routeState);
83
            return _getBaseElements(store.routeState);
82
84
83
            // Function declarations
85
            // Function declarations
84
86
Lines 150-158 export const useNavigationStore = defineStore("navigation", { Link Here
150
                        };
152
                        };
151
                    });
153
                    });
152
            }
154
            }
153
        },
155
        }),
154
        leftNavigation() {
156
        leftNavigation: computed(() => {
155
            return _getNavigationElements(this.routeState);
157
            return _getNavigationElements(store.routeState);
156
158
157
            // Function declarations
159
            // Function declarations
158
160
Lines 203-211 export const useNavigationStore = defineStore("navigation", { Link Here
203
                    (!parent.children || !parent.children.length)
205
                    (!parent.children || !parent.children.length)
204
                );
206
                );
205
            }
207
            }
206
        },
208
        }),
207
        navigationRoutes() {
209
        navigationRoutes: computed(() => {
208
            let routes = _toRoute(this.routeState);
210
            let routes = _toRoute(store.routeState);
209
            return Array.isArray(routes) ? routes : [routes];
211
            return Array.isArray(routes) ? routes : [routes];
210
212
211
            // Function declarations
213
            // Function declarations
Lines 220-227 export const useNavigationStore = defineStore("navigation", { Link Here
220
                    .map(child => _toRoute(child))
222
                    .map(child => _toRoute(child))
221
                    .flat(Infinity);
223
                    .flat(Infinity);
222
            }
224
            }
223
        },
225
        }),
224
    },
226
    };
227
228
    return {
229
        ...toRefs(store),
230
        ...actions,
231
        ...getters,
232
    };
225
});
233
});
226
234
227
function addSlashIfNotPresent(path) {
235
function addSlashIfNotPresent(path) {
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/stores/preservation.js (-3 / +8 lines)
Lines 1-7 Link Here
1
import { defineStore } from "pinia";
1
import { defineStore } from "pinia";
2
import { reactive, toRefs } from "vue";
2
3
3
export const usePreservationStore = defineStore("preservation", {
4
export const usePreservationStore = defineStore("preservation", () => {
4
    state: () => ({
5
    const store = reactive({
5
        config: {
6
        config: {
6
            settings: {
7
            settings: {
7
                enabled: 0,
8
                enabled: 0,
Lines 9-13 export const usePreservationStore = defineStore("preservation", { Link Here
9
                not_for_loan_default_train_in: 0,
10
                not_for_loan_default_train_in: 0,
10
            },
11
            },
11
        },
12
        },
12
    }),
13
    });
14
15
    return {
16
        ...toRefs(store),
17
    };
13
});
18
});
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/stores/usage-reports.js (-5 / +8 lines)
Lines 1-7 Link Here
1
import { defineStore } from "pinia";
1
import { defineStore } from "pinia";
2
import { reactive, toRefs } from "vue";
2
3
3
export const useReportsStore = defineStore("reports", {
4
export const useReportsStore = defineStore("reports", () => {
4
    state: () => ({
5
    const store = reactive({
5
        months_data: [
6
        months_data: [
6
            { short: "Jan", description: "January", value: 1, active: true },
7
            { short: "Jan", description: "January", value: 1, active: true },
7
            { short: "Feb", description: "February", value: 2, active: true },
8
            { short: "Feb", description: "February", value: 2, active: true },
Lines 122-129 export const useReportsStore = defineStore("reports", { Link Here
122
            TR_J3: ["Access_Type"],
123
            TR_J3: ["Access_Type"],
123
            TR_J4: ["YOP"],
124
            TR_J4: ["YOP"],
124
        },
125
        },
125
    }),
126
    });
126
    actions: {
127
    const actions = {
127
        getMonthsData() {
128
        getMonthsData() {
128
            return this.months_data;
129
            return this.months_data;
129
        },
130
        },
Lines 134-138 export const useReportsStore = defineStore("reports", { Link Here
134
            if (!this.report_type_map.hasOwnProperty(report_type)) return false;
135
            if (!this.report_type_map.hasOwnProperty(report_type)) return false;
135
            return this.report_type_map[report_type].includes(column);
136
            return this.report_type_map[report_type].includes(column);
136
        },
137
        },
137
    },
138
    };
139
140
    return { ...toRefs(store), ...actions };
138
});
141
});
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/stores/vendors.js (-4 / +8 lines)
Lines 1-7 Link Here
1
import { defineStore } from "pinia";
1
import { defineStore } from "pinia";
2
import { reactive, toRefs } from "vue";
2
3
3
export const useVendorStore = defineStore("vendors", {
4
export const useVendorStore = defineStore("vendors", () => {
4
    state: () => ({
5
    const store = reactive({
5
        vendors: [],
6
        vendors: [],
6
    }),
7
    });
8
9
    return {
10
        ...toRefs(store),
11
    };
7
});
12
});
8
- 

Return to bug 37930