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

(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Preservation/Main.vue (-33 / +21 lines)
Lines 36-57 import { storeToRefs } from "pinia"; Link Here
36
36
37
export default {
37
export default {
38
    setup() {
38
    setup() {
39
        const AVStore = inject("AVStore");
40
41
        const mainStore = inject("mainStore");
39
        const mainStore = inject("mainStore");
42
40
43
        const { loading, loaded, setError } = mainStore;
41
        const { loading, loaded, setError } = mainStore;
44
42
45
        const PreservationStore = inject("PreservationStore");
43
        const PreservationStore = inject("PreservationStore");
46
44
47
        const { config } = storeToRefs(PreservationStore);
45
        const { config, authorisedValues } = storeToRefs(PreservationStore);
46
        const { loadAuthorisedValues } = PreservationStore;
48
47
49
        return {
48
        return {
50
            AVStore,
51
            loading,
49
            loading,
52
            loaded,
50
            loaded,
53
            config,
51
            config,
54
            setError,
52
            setError,
53
            authorisedValues,
54
            loadAuthorisedValues,
55
            PreservationStore,
55
        };
56
        };
56
    },
57
    },
57
    data() {
58
    data() {
Lines 62-100 export default { Link Here
62
    beforeCreate() {
63
    beforeCreate() {
63
        this.loading();
64
        this.loading();
64
65
65
        const fetch_additional_config = () => {
66
            let promises = [];
67
            const av_client = APIClient.authorised_values;
68
            promises.push(
69
                av_client.values.get("NOT_LOAN").then(
70
                    values => {
71
                        this.AVStore.av_notforloan = values;
72
                    },
73
                    error => {}
74
                )
75
            );
76
            return Promise.all(promises);
77
        };
78
79
        const client = APIClient.preservation;
66
        const client = APIClient.preservation;
80
        client.config
67
        client.config.get().then(config => {
81
            .get()
68
            this.config = config;
82
            .then(config => {
69
            if (this.config.settings.enabled != 1) {
83
                this.config = config;
70
                this.loaded();
84
                if (this.config.settings.enabled != 1) {
71
                return this.setError(
85
                    return this.setError(
72
                    this.$__(
86
                        this.$__(
73
                        'The preservation module is disabled, turn on <a href="/cgi-bin/koha/admin/preferences.pl?tab=&op=search&searchfield=PreservationModule">PreservationModule</a> to use it'
87
                            'The preservation module is disabled, turn on <a href="/cgi-bin/koha/admin/preferences.pl?tab=&op=search&searchfield=PreservationModule">PreservationModule</a> to use it'
74
                    ),
88
                        ),
75
                    false
89
                        false
76
                );
90
                    );
77
            }
91
                }
78
            this.loadAuthorisedValues(
92
                return fetch_additional_config();
79
                this.authorisedValues,
93
            })
80
                this.PreservationStore
94
            .then(() => {
81
            ).then(() => {
95
                this.loaded();
82
                this.loaded();
96
                this.initialized = true;
83
                this.initialized = true;
97
            });
84
            });
85
        });
98
    },
86
    },
99
87
100
    components: {
88
    components: {
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Preservation/Settings.vue (-8 / +6 lines)
Lines 29-35 Link Here
29
                                "
29
                                "
30
                                label="description"
30
                                label="description"
31
                                :reduce="av => av.value"
31
                                :reduce="av => av.value"
32
                                :options="av_notforloan"
32
                                :options="authorisedValues.av_notforloan"
33
                            >
33
                            >
34
                                <template #search="{ attributes, events }">
34
                                <template #search="{ attributes, events }">
35
                                    <input
35
                                    <input
Lines 60-66 Link Here
60
                                "
60
                                "
61
                                label="description"
61
                                label="description"
62
                                :reduce="av => av.value"
62
                                :reduce="av => av.value"
63
                                :options="av_notforloan"
63
                                :options="authorisedValues.av_notforloan"
64
                            />
64
                            />
65
                        </li>
65
                        </li>
66
                    </ol>
66
                    </ol>
Lines 124-139 import SettingsProcessings from "./SettingsProcessings.vue"; Link Here
124
124
125
export default {
125
export default {
126
    setup() {
126
    setup() {
127
        const AVStore = inject("AVStore");
127
        const PreservationStore = inject("PreservationStore");
128
        const { av_notforloan } = storeToRefs(AVStore);
128
        const { authorisedValues } = storeToRefs(PreservationStore);
129
        const { get_lib_from_av } = AVStore;
129
        const { get_lib_from_av, config } = PreservationStore;
130
130
131
        const { setMessage, setWarning } = inject("mainStore");
131
        const { setMessage, setWarning } = inject("mainStore");
132
        const PreservationStore = inject("PreservationStore");
133
        const { config } = PreservationStore;
134
132
135
        return {
133
        return {
136
            av_notforloan,
134
            authorisedValues,
137
            get_lib_from_av,
135
            get_lib_from_av,
138
            setMessage,
136
            setMessage,
139
            setWarning,
137
            setWarning,
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Preservation/SettingsProcessingsFormAdd.vue (-3 lines)
Lines 204-212 import { storeToRefs } from "pinia"; Link Here
204
204
205
export default {
205
export default {
206
    setup() {
206
    setup() {
207
        const AVStore = inject("AVStore");
208
        const {} = storeToRefs(AVStore);
209
210
        const { setMessage, setWarning } = inject("mainStore");
207
        const { setMessage, setWarning } = inject("mainStore");
211
208
212
        const db_column_options = Object.keys(db_columns).map(function (c) {
209
        const db_column_options = Object.keys(db_columns).map(function (c) {
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Preservation/TrainsFormAdd.vue (-7 / +5 lines)
Lines 47-53 Link Here
47
                                v-model="train.not_for_loan"
47
                                v-model="train.not_for_loan"
48
                                label="description"
48
                                label="description"
49
                                :reduce="av => av.value"
49
                                :reduce="av => av.value"
50
                                :options="av_notforloan"
50
                                :options="authorisedValues.av_notforloan"
51
                            />
51
                            />
52
                        </li>
52
                        </li>
53
                        <li>
53
                        <li>
Lines 101-115 import { APIClient } from "../../fetch/api-client.js"; Link Here
101
101
102
export default {
102
export default {
103
    setup() {
103
    setup() {
104
        const AVStore = inject("AVStore");
105
        const { av_notforloan } = storeToRefs(AVStore);
106
107
        const { setMessage, setWarning } = inject("mainStore");
108
109
        const PreservationStore = inject("PreservationStore");
104
        const PreservationStore = inject("PreservationStore");
105
        const { authorisedValues } = storeToRefs(PreservationStore);
110
        const { config } = PreservationStore;
106
        const { config } = PreservationStore;
111
107
112
        return { av_notforloan, setMessage, setWarning, config };
108
        const { setMessage, setWarning } = inject("mainStore");
109
110
        return { authorisedValues, setMessage, setWarning, config };
113
    },
111
    },
114
    data() {
112
    data() {
115
        return {
113
        return {
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Preservation/TrainsList.vue (-2 / +2 lines)
Lines 69-76 import KohaTable from "../KohaTable.vue"; Link Here
69
69
70
export default {
70
export default {
71
    setup() {
71
    setup() {
72
        const AVStore = inject("AVStore");
72
        const PreservationStore = inject("PreservationStore");
73
        const { get_lib_from_av, map_av_dt_filter } = AVStore;
73
        const { get_lib_from_av, map_av_dt_filter } = PreservationStore;
74
        const { setConfirmationDialog, setMessage, setWarning } =
74
        const { setConfirmationDialog, setMessage, setWarning } =
75
            inject("mainStore");
75
            inject("mainStore");
76
        const table = ref();
76
        const table = ref();
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Preservation/TrainsShow.vue (-2 / +2 lines)
Lines 291-298 export default { Link Here
291
    setup() {
291
    setup() {
292
        const format_date = $date;
292
        const format_date = $date;
293
293
294
        const AVStore = inject("AVStore");
294
        const PreservationStore = inject("PreservationStore");
295
        const { get_lib_from_av } = AVStore;
295
        const { get_lib_from_av } = PreservationStore;
296
296
297
        const { setConfirmationDialog, setMessage, setWarning } =
297
        const { setConfirmationDialog, setMessage, setWarning } =
298
            inject("mainStore");
298
            inject("mainStore");
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/stores/preservation.js (+7 lines)
Lines 1-5 Link Here
1
import { defineStore } from "pinia";
1
import { defineStore } from "pinia";
2
import { reactive, toRefs } from "vue";
2
import { reactive, toRefs } from "vue";
3
import { withAuthorisedValueActions } from "../composables/authorisedValues";
3
4
4
export const usePreservationStore = defineStore("preservation", () => {
5
export const usePreservationStore = defineStore("preservation", () => {
5
    const store = reactive({
6
    const store = reactive({
Lines 10-18 export const usePreservationStore = defineStore("preservation", () => { Link Here
10
                not_for_loan_default_train_in: 0,
11
                not_for_loan_default_train_in: 0,
11
            },
12
            },
12
        },
13
        },
14
        authorisedValues: {
15
            av_notforloan: "NOT_LOAN",
16
        },
13
    });
17
    });
14
18
19
    const sharedActions = withAuthorisedValueActions(store);
20
15
    return {
21
    return {
16
        ...toRefs(store),
22
        ...toRefs(store),
23
        ...sharedActions,
17
    };
24
    };
18
});
25
});
(-)a/t/cypress/integration/Preservation/Settings.ts (-36 / +39 lines)
Lines 42-83 describe("Processings", () => { Link Here
42
            '{"permissions":{"manage_sysprefs":"1"},"settings":{"enabled":"1","not_for_loan_default_train_in":"42","not_for_loan_waiting_list_in": "24"}}'
42
            '{"permissions":{"manage_sysprefs":"1"},"settings":{"enabled":"1","not_for_loan_default_train_in":"42","not_for_loan_waiting_list_in": "24"}}'
43
        );
43
        );
44
44
45
        cy.intercept(
45
        cy.intercept("GET", "/api/v1/authorised_value_categories?q=*", [
46
            "GET",
46
            {
47
            "/api/v1/authorised_value_categories/NOT_LOAN/authorised_values",
47
                authorised_values: [
48
            [
48
                    {
49
                {
49
                        category_name: "NOT_LOAN",
50
                    category_name: "NOT_LOAN",
50
                        description: "Ordered",
51
                    description: "Ordered",
51
                        value: "-1",
52
                    value: "-1",
52
                    },
53
                },
53
                    {
54
                {
54
                        category_name: "NOT_LOAN",
55
                    category_name: "NOT_LOAN",
55
                        description: "Not for loan",
56
                    description: "Not for loan",
56
                        value: "1",
57
                    value: "1",
57
                    },
58
                },
58
                    {
59
                {
59
                        category_name: "NOT_LOAN",
60
                    category_name: "NOT_LOAN",
60
                        description: "Staff collection",
61
                    description: "Staff collection",
61
                        value: "2",
62
                    value: "2",
62
                    },
63
                },
63
                    {
64
                {
64
                        category_name: "NOT_LOAN",
65
                    category_name: "NOT_LOAN",
65
                        description: "Added to bundle",
66
                    description: "Added to bundle",
66
                        value: "3",
67
                    value: "3",
67
                    },
68
                },
68
                    {
69
                {
69
                        category_name: "NOT_LOAN",
70
                    category_name: "NOT_LOAN",
70
                        description: "In preservation",
71
                    description: "In preservation",
71
                        value: "24",
72
                    value: "24",
72
                    },
73
                },
73
                    {
74
                {
74
                        category_name: "NOT_LOAN",
75
                    category_name: "NOT_LOAN",
75
                        description: "In preservation external",
76
                    description: "In preservation external",
76
                        value: "42",
77
                    value: "42",
77
                    },
78
                },
78
                ],
79
            ]
79
                category_name: "NOT_LOAN",
80
        );
80
                is_integer_only: false,
81
                is_system: true,
82
            },
83
        ]);
81
    });
84
    });
82
85
83
    it("Settings", () => {
86
    it("Settings", () => {
(-)a/t/cypress/integration/Preservation/Trains.ts (-42 / +52 lines)
Lines 212-258 describe("Trains", () => { Link Here
212
            '{"permissions":{"manage_sysprefs":"1"},"settings":{"enabled":"1","not_for_loan_default_train_in":"42","not_for_loan_waiting_list_in": "24"}}'
212
            '{"permissions":{"manage_sysprefs":"1"},"settings":{"enabled":"1","not_for_loan_default_train_in":"42","not_for_loan_waiting_list_in": "24"}}'
213
        );
213
        );
214
214
215
        cy.intercept(
215
        cy.intercept("GET", "/api/v1/authorised_value_categories?q=*", [
216
            "GET",
216
            {
217
            "/api/v1/authorised_value_categories/NOT_LOAN/authorised_values",
217
                authorised_values: [
218
            [
218
                    {
219
                {
219
                        category_name: "NOT_LOAN",
220
                    category_name: "NOT_LOAN",
220
                        description: "Ordered",
221
                    description: "Ordered",
221
                        value: "-1",
222
                    value: "-1",
222
                    },
223
                },
223
                    {
224
                {
224
                        category_name: "NOT_LOAN",
225
                    category_name: "NOT_LOAN",
225
                        description: "Not for loan",
226
                    description: "Not for loan",
226
                        value: "1",
227
                    value: "1",
227
                    },
228
                },
228
                    {
229
                {
229
                        category_name: "NOT_LOAN",
230
                    category_name: "NOT_LOAN",
230
                        description: "Staff collection",
231
                    description: "Staff collection",
231
                        value: "2",
232
                    value: "2",
232
                    },
233
                },
233
                    {
234
                {
234
                        category_name: "NOT_LOAN",
235
                    category_name: "NOT_LOAN",
235
                        description: "Added to bundle",
236
                    description: "Added to bundle",
236
                        value: "3",
237
                    value: "3",
237
                    },
238
                },
238
                    {
239
                {
239
                        category_name: "NOT_LOAN",
240
                    category_name: "NOT_LOAN",
240
                        description: "In preservation",
241
                    description: "In preservation",
241
                        value: "24",
242
                    value: "24",
242
                    },
243
                },
243
                    {
244
                {
244
                        category_name: "NOT_LOAN",
245
                    category_name: "NOT_LOAN",
245
                        description: "In preservation external",
246
                    description: "In preservation external",
246
                        value: "42",
247
                    value: "42",
247
                    },
248
                },
248
                    {
249
                {
249
                        category_name: "NOT_LOAN",
250
                    category_name: "NOT_LOAN",
250
                        description: "In preservation other",
251
                    description: "In preservation other",
251
                        value: "43",
252
                    value: "43",
252
                    },
253
                },
253
                ],
254
            ]
254
                category_name: "NOT_LOAN",
255
        );
255
                is_integer_only: false,
256
                is_system: true,
257
            },
258
        ]);
256
    });
259
    });
257
260
258
    it("List trains", () => {
261
    it("List trains", () => {
Lines 668-673 describe("Trains", () => { Link Here
668
                });
671
                });
669
            }
672
            }
670
        );
673
        );
674
        cy.intercept("GET", "/api/v1/authorised_value_categories?q=*", [
675
            {
676
                authorised_values: [],
677
                category_name: "COUNTRY",
678
                is_integer_only: false,
679
                is_system: false,
680
            },
681
        ]);
671
        cy.get("#add_to_train .approve").click();
682
        cy.get("#add_to_train .approve").click();
672
        train.items = get_train_items().filter(
683
        train.items = get_train_items().filter(
673
            train_item => train_item.item_id == 1 || train_item.item_id == 2
684
            train_item => train_item.item_id == 1 || train_item.item_id == 2
674
- 

Return to bug 37930