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

(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsList.vue (+3 lines)
Lines 75-80 export default { Link Here
75
75
76
        const { setConfirmationDialog, setMessage } = inject("mainStore")
76
        const { setConfirmationDialog, setMessage } = inject("mainStore")
77
77
78
        const { authorisedValues } = inject("ERMStore")
79
        console.log(authorisedValues)
80
78
        const table = ref()
81
        const table = ref()
79
82
80
        const filters = reactive({
83
        const filters = reactive({
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/Main.vue (-49 / +7 lines)
Lines 41-64 export default { Link Here
41
    setup() {
41
    setup() {
42
        const vendorStore = inject("vendorStore")
42
        const vendorStore = inject("vendorStore")
43
43
44
        const AVStore = inject("AVStore")
45
46
        const mainStore = inject("mainStore")
44
        const mainStore = inject("mainStore")
47
45
48
        const { loading, loaded, setError } = mainStore
46
        const { loading, loaded, setError, loadAuthorisedValues } = mainStore
49
47
50
        const ERMStore = inject("ERMStore")
48
        const ERMStore = inject("ERMStore")
51
49
52
        const { config } = storeToRefs(ERMStore)
50
        const { config, authorisedValues } = storeToRefs(ERMStore)
53
51
54
        return {
52
        return {
55
            vendorStore,
53
            vendorStore,
56
            AVStore,
57
            ERMStore,
54
            ERMStore,
58
            config,
55
            config,
59
            setError,
56
            setError,
60
            loading,
57
            loading,
61
            loaded,
58
            loaded,
59
            loadAuthorisedValues,
60
            authorisedValues,
62
        }
61
        }
63
    },
62
    },
64
    data() {
63
    data() {
Lines 80-130 export default { Link Here
80
                },
79
                },
81
                error => {}
80
                error => {}
82
            )
81
            )
83
82
            this.loadAuthorisedValues(this.authorisedValues).then(() => {
84
            const av_client = APIClient.authorised_values
83
                this.loaded()
85
            const authorised_values = {
84
                this.initialized = true
86
                av_agreement_statuses: "ERM_AGREEMENT_STATUS",
87
                av_agreement_closure_reasons: "ERM_AGREEMENT_CLOSURE_REASON",
88
                av_agreement_renewal_priorities:
89
                    "ERM_AGREEMENT_RENEWAL_PRIORITY",
90
                av_user_roles: "ERM_USER_ROLES",
91
                av_license_types: "ERM_LICENSE_TYPE",
92
                av_license_statuses: "ERM_LICENSE_STATUS",
93
                av_agreement_license_statuses: "ERM_AGREEMENT_LICENSE_STATUS",
94
                av_agreement_license_location: "ERM_AGREEMENT_LICENSE_LOCATION",
95
                av_package_types: "ERM_PACKAGE_TYPE",
96
                av_package_content_types: "ERM_PACKAGE_CONTENT_TYPE",
97
                av_title_publication_types: "ERM_TITLE_PUBLICATION_TYPE",
98
                av_report_types: "ERM_REPORT_TYPES",
99
                av_platform_reports_metrics: "ERM_PLATFORM_REPORTS_METRICS",
100
                av_database_reports_metrics: "ERM_DATABASE_REPORTS_METRICS",
101
                av_title_reports_metrics: "ERM_TITLE_REPORTS_METRICS",
102
                av_item_reports_metrics: "ERM_ITEM_REPORTS_METRICS",
103
            }
104
105
            let av_cat_array = Object.keys(authorised_values).map(function (
106
                av_cat
107
            ) {
108
                return '"' + authorised_values[av_cat] + '"'
109
            })
85
            })
110
111
            promises.push(
112
                av_client.values
113
                    .getCategoriesWithValues(av_cat_array)
114
                    .then(av_categories => {
115
                        Object.entries(authorised_values).forEach(
116
                            ([av_var, av_cat]) => {
117
                                const av_match = av_categories.find(
118
                                    element => element.category_name == av_cat
119
                                )
120
                                this.AVStore[av_var] =
121
                                    av_match.authorised_values
122
                            }
123
                        )
124
                    })
125
            )
126
127
            return Promise.all(promises)
128
        }
86
        }
129
87
130
        const client = APIClient.erm
88
        const client = APIClient.erm
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/modules/erm.ts (-3 lines)
Lines 21-27 import { routes as routesDef } from "../routes/erm"; Link Here
21
21
22
import { useMainStore } from "../stores/main";
22
import { useMainStore } from "../stores/main";
23
import { useVendorStore } from "../stores/vendors";
23
import { useVendorStore } from "../stores/vendors";
24
import { useAVStore } from "../stores/authorised-values";
25
import { useERMStore } from "../stores/erm";
24
import { useERMStore } from "../stores/erm";
26
import { useNavigationStore } from "../stores/navigation";
25
import { useNavigationStore } from "../stores/navigation";
27
import { useReportsStore } from "../stores/usage-reports";
26
import { useReportsStore } from "../stores/usage-reports";
Lines 30-36 import i18n from "../i18n"; Link Here
30
const pinia = createPinia();
29
const pinia = createPinia();
31
30
32
const mainStore = useMainStore(pinia);
31
const mainStore = useMainStore(pinia);
33
const AVStore = useAVStore(pinia);
34
const navigationStore = useNavigationStore(pinia);
32
const navigationStore = useNavigationStore(pinia);
35
const routes = navigationStore.setRoutes(routesDef);
33
const routes = navigationStore.setRoutes(routesDef);
36
34
Lines 52-58 const rootComponent = app Link Here
52
app.config.unwrapInjectedRef = true;
50
app.config.unwrapInjectedRef = true;
53
app.provide("vendorStore", useVendorStore(pinia));
51
app.provide("vendorStore", useVendorStore(pinia));
54
app.provide("mainStore", mainStore);
52
app.provide("mainStore", mainStore);
55
app.provide("AVStore", AVStore);
56
app.provide("navigationStore", navigationStore);
53
app.provide("navigationStore", navigationStore);
57
const ERMStore = useERMStore(pinia);
54
const ERMStore = useERMStore(pinia);
58
app.provide("ERMStore", ERMStore);
55
app.provide("ERMStore", ERMStore);
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/stores/erm.js (+50 lines)
Lines 8-12 export const useERMStore = defineStore("erm", { Link Here
8
                ERMProviders: [],
8
                ERMProviders: [],
9
            },
9
            },
10
        },
10
        },
11
        authorisedValues: {
12
            av_agreement_statuses: "ERM_AGREEMENT_STATUS",
13
            av_agreement_closure_reasons: "ERM_AGREEMENT_CLOSURE_REASON",
14
            av_agreement_renewal_priorities: "ERM_AGREEMENT_RENEWAL_PRIORITY",
15
            av_user_roles: "ERM_USER_ROLES",
16
            av_license_types: "ERM_LICENSE_TYPE",
17
            av_license_statuses: "ERM_LICENSE_STATUS",
18
            av_agreement_license_statuses: "ERM_AGREEMENT_LICENSE_STATUS",
19
            av_agreement_license_location: "ERM_AGREEMENT_LICENSE_LOCATION",
20
            av_package_types: "ERM_PACKAGE_TYPE",
21
            av_package_content_types: "ERM_PACKAGE_CONTENT_TYPE",
22
            av_title_publication_types: "ERM_TITLE_PUBLICATION_TYPE",
23
            av_report_types: "ERM_REPORT_TYPES",
24
            av_platform_reports_metrics: "ERM_PLATFORM_REPORTS_METRICS",
25
            av_database_reports_metrics: "ERM_DATABASE_REPORTS_METRICS",
26
            av_title_reports_metrics: "ERM_TITLE_REPORTS_METRICS",
27
            av_item_reports_metrics: "ERM_ITEM_REPORTS_METRICS",
28
            av_agreement_relationships: [
29
                { value: "supersedes", description: __("supersedes") },
30
                {
31
                    value: "is-superseded-by",
32
                    description: __("is superseded by"),
33
                },
34
                {
35
                    value: "provides_post-cancellation_access_for",
36
                    description: __("provides post-cancellation access for"),
37
                },
38
                {
39
                    value: "has-post-cancellation-access-in",
40
                    description: __("has post-cancellation access in"),
41
                },
42
                {
43
                    value: "tracks_demand-driven_acquisitions_for",
44
                    description: __("tracks demand-driven acquisitions for"),
45
                },
46
                {
47
                    value: "has-demand-driven-acquisitions-in",
48
                    description: __("has demand-driven acquisitions in"),
49
                },
50
                {
51
                    value: "has_backfile_in",
52
                    description: __("has backfile in"),
53
                },
54
                {
55
                    value: "has_frontfile_in",
56
                    description: __("has frontfile in"),
57
                },
58
                { value: "related_to", description: __("related to") },
59
            ],
60
        },
11
    }),
61
    }),
12
});
62
});
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/stores/main.js (-1 / +55 lines)
Lines 1-4 Link Here
1
import { defineStore } from "pinia";
1
import { defineStore } from "pinia";
2
import { APIClient } from "../fetch/api-client.js";
2
3
3
export const useMainStore = defineStore("main", {
4
export const useMainStore = defineStore("main", {
4
    state: () => ({
5
    state: () => ({
Lines 90-95 export const useMainStore = defineStore("main", { Link Here
90
        loaded() {
91
        loaded() {
91
            this._is_loading = false;
92
            this._is_loading = false;
92
        },
93
        },
94
        get_lib_from_av(arr_name, av) {
95
            if (this[arr_name] === undefined) {
96
                console.warn(
97
                    "The authorised value category for '%s' is not defined.".format(
98
                        arr_name
99
                    )
100
                );
101
                return;
102
            }
103
            let o = this[arr_name].find(e => e.value == av);
104
            return o ? o.description : av;
105
        },
106
        map_av_dt_filter(arr_name) {
107
            return this[arr_name].map(e => {
108
                e["_id"] = e["value"];
109
                e["_str"] = e["description"];
110
                return e;
111
            });
112
        },
113
        async loadAuthorisedValues(authorisedValues) {
114
            console.log(authorisedValues);
115
            const AVsToFetch = Object.keys(authorisedValues).reduce(
116
                (acc, avKey) => {
117
                    if (Array.isArray(authorisedValues[avKey])) return acc;
118
                    acc[avKey] = authorisedValues[avKey];
119
                    return acc;
120
                },
121
                {}
122
            );
123
124
            const AVCatArray = Object.keys(AVsToFetch).map(avCat => {
125
                return '"' + AVsToFetch[avCat] + '"';
126
            });
127
128
            const promises = [];
129
            const AVClient = APIClient.authorised_values;
130
            promises.push(
131
                AVClient.values
132
                    .getCategoriesWithValues(AVCatArray)
133
                    .then(AVCategories => {
134
                        Object.entries(AVsToFetch).forEach(
135
                            ([AVName, AVCat]) => {
136
                                const AVMatch = AVCategories.find(
137
                                    element => element.category_name == AVCat
138
                                );
139
                                authorisedValues[AVName] =
140
                                    AVMatch.authorised_values;
141
                            }
142
                        );
143
                    })
144
            );
145
146
            return Promise.all(promises);
147
        },
93
    },
148
    },
94
    getters: {
149
    getters: {
95
        error() {
150
        error() {
96
- 

Return to bug 37930