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

(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Breadcrumbs.vue (-1 / +1 lines)
Lines 31-37 export default { Link Here
31
    setup: () => {
31
    setup: () => {
32
        const navigationStore = inject("navigationStore")
32
        const navigationStore = inject("navigationStore")
33
        const { breadcrumbs } = storeToRefs(navigationStore)
33
        const { breadcrumbs } = storeToRefs(navigationStore)
34
        const { params } = navigationStore
34
        const { params } = storeToRefs(navigationStore)
35
        return {
35
        return {
36
            breadcrumbs,
36
            breadcrumbs,
37
            params,
37
            params,
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsShow.vue (-1 lines)
Lines 390-396 export default { Link Here
390
            client.agreements.get(agreement_id).then(
390
            client.agreements.get(agreement_id).then(
391
                agreement => {
391
                agreement => {
392
                    this.agreement = agreement
392
                    this.agreement = agreement
393
                    this.navigationStore.setBreadcrumbParameter(agreement.name)
394
                    this.initialized = true
393
                    this.initialized = true
395
                },
394
                },
396
                error => {}
395
                error => {}
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/LicensesShow.vue (-1 lines)
Lines 197-203 export default { Link Here
197
            client.licenses.get(license_id).then(
197
            client.licenses.get(license_id).then(
198
                license => {
198
                license => {
199
                    this.license = license
199
                    this.license = license
200
                    this.navigationStore.setBreadcrumbParameter(license.name)
201
                    this.initialized = true
200
                    this.initialized = true
202
                },
201
                },
203
                error => {}
202
                error => {}
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/http-client.js (+13 lines)
Lines 1-4 Link Here
1
import { setError, submitting, submitted } from "../messages";
1
import { setError, submitting, submitted } from "../messages";
2
import { useNavigationStore } from "../stores/navigation";
2
3
3
class HttpClient {
4
class HttpClient {
4
    constructor(options = {}) {
5
    constructor(options = {}) {
Lines 41-46 class HttpClient { Link Here
41
42
42
        if (error) throw Error(error);
43
        if (error) throw Error(error);
43
44
45
        const navigationStore = useNavigationStore()
46
        const { current } = navigationStore
47
        current.forEach(route => {
48
            const { title, path } = route.meta.self
49
            if(title && title.dynamic && res[title.identifier]) {
50
                navigationStore.setBreadcrumbParameter({
51
                    breadcrumbText: res[title.identifier],
52
                    path: path
53
                })
54
            }
55
        })
56
44
        return res;
57
        return res;
45
    }
58
    }
46
59
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/modules/erm.ts (-1 / +3 lines)
Lines 60-66 app.mount("#erm"); Link Here
60
60
61
const { removeMessages } = mainStore;
61
const { removeMessages } = mainStore;
62
router.beforeEach((to, from) => {
62
router.beforeEach((to, from) => {
63
    navigationStore.$patch({ current: to.matched, params: to.params || {} });
63
    navigationStore.setCurrent(to.matched)
64
    navigationStore.setParams(to.params || {})
65
    navigationStore.setBreadcrumbParameter({})
64
    removeMessages(); // This will actually flag the messages as displayed already
66
    removeMessages(); // This will actually flag the messages as displayed already
65
});
67
});
66
router.afterEach((to, from) => {
68
router.afterEach((to, from) => {
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/routes/erm.js (-36 / +12 lines)
Lines 60-66 export const routes = [ Link Here
60
                        path: ":agreement_id",
60
                        path: ":agreement_id",
61
                        name: "AgreementsShow",
61
                        name: "AgreementsShow",
62
                        component: markRaw(AgreementsShow),
62
                        component: markRaw(AgreementsShow),
63
                        title: { dynamic: true, text: $__("Show agreement") },
63
                        title: { dynamic: true, identifier: "name", text: $__("Show agreement")},
64
                    },
64
                    },
65
                    {
65
                    {
66
                        path: "add",
66
                        path: "add",
Lines 72-78 export const routes = [ Link Here
72
                        path: "edit/:agreement_id",
72
                        path: "edit/:agreement_id",
73
                        name: "AgreementsFormAddEdit",
73
                        name: "AgreementsFormAddEdit",
74
                        component: markRaw(AgreementsFormAdd),
74
                        component: markRaw(AgreementsFormAdd),
75
                        title: { dynamic: true, text: $__("Edit agreement") },
75
                        title: { dynamic: true, identifier: "name", text: $__("Edit agreement")},
76
                    },
76
                    },
77
                ],
77
                ],
78
            },
78
            },
Lines 91-97 export const routes = [ Link Here
91
                        path: ":license_id",
91
                        path: ":license_id",
92
                        name: "LicensesShow",
92
                        name: "LicensesShow",
93
                        component: markRaw(LicensesShow),
93
                        component: markRaw(LicensesShow),
94
                        title: { dynamic: true, text: $__("Show license") },
94
                        title: { dynamic: true, identifier: "name", text: $__("Show license")}
95
                    },
95
                    },
96
                    {
96
                    {
97
                        path: "add",
97
                        path: "add",
Lines 103-109 export const routes = [ Link Here
103
                        path: "edit/:license_id",
103
                        path: "edit/:license_id",
104
                        name: "LicensesFormAddEdit",
104
                        name: "LicensesFormAddEdit",
105
                        component: markRaw(LicensesFormAdd),
105
                        component: markRaw(LicensesFormAdd),
106
                        title: { dynamic: true, text: $__("Edit license") },
106
                        title: { dynamic: true, identifier: 'name', text: $__("Edit license")}
107
                    },
107
                    },
108
                ],
108
                ],
109
            },
109
            },
Lines 141-150 export const routes = [ Link Here
141
                                        component: markRaw(
141
                                        component: markRaw(
142
                                            EHoldingsLocalPackagesShow
142
                                            EHoldingsLocalPackagesShow
143
                                        ),
143
                                        ),
144
                                        title: {
144
                                        title: { dynamic: true, identifier: 'name', text: $__("Show package")}
145
                                            dynamic: true,
146
                                            text: $__("Show package"),
147
                                        },
148
                                    },
145
                                    },
149
                                    {
146
                                    {
150
                                        path: "add",
147
                                        path: "add",
Lines 163-172 export const routes = [ Link Here
163
                                        component: markRaw(
160
                                        component: markRaw(
164
                                            EHoldingsLocalPackagesFormAdd
161
                                            EHoldingsLocalPackagesFormAdd
165
                                        ),
162
                                        ),
166
                                        title: {
163
                                        title: { dynamic: true, identifier: 'name', text: $__("Edit package")}
167
                                            dynamic: true,
168
                                            text: $__("Edit package"),
169
                                        },
170
                                    },
164
                                    },
171
                                ],
165
                                ],
172
                            },
166
                            },
Lines 189-198 export const routes = [ Link Here
189
                                        component: markRaw(
183
                                        component: markRaw(
190
                                            EHoldingsLocalTitlesShow
184
                                            EHoldingsLocalTitlesShow
191
                                        ),
185
                                        ),
192
                                        title: {
186
                                        title: { dynamic: true, identifier: 'publication_title', text: $__("Show title")}
193
                                            dynamic: true,
194
                                            text: $__("Show title"),
195
                                        },
196
                                    },
187
                                    },
197
                                    {
188
                                    {
198
                                        path: "add",
189
                                        path: "add",
Lines 211-220 export const routes = [ Link Here
211
                                        component: markRaw(
202
                                        component: markRaw(
212
                                            EHoldingsLocalTitlesFormAdd
203
                                            EHoldingsLocalTitlesFormAdd
213
                                        ),
204
                                        ),
214
                                        title: {
205
                                        title: { dynamic: true, identifier: 'publication_title', text: $__("Edit title")}
215
                                            dynamic: true,
216
                                            text: $__("Edit title"),
217
                                        },
218
                                    },
206
                                    },
219
                                    {
207
                                    {
220
                                        path: "import",
208
                                        path: "import",
Lines 233-242 export const routes = [ Link Here
233
                                        component: markRaw(
221
                                        component: markRaw(
234
                                            EHoldingsLocalResourcesShow
222
                                            EHoldingsLocalResourcesShow
235
                                        ),
223
                                        ),
236
                                        title: {
224
                                        title: { dynamic: false, text: $__("Resource")}
237
                                            dynamic: true,
238
                                            text: $__("Resource"),
239
                                        },
240
                                    },
225
                                    },
241
                                ],
226
                                ],
242
                            },
227
                            },
Lines 270-279 export const routes = [ Link Here
270
                                        component: markRaw(
255
                                        component: markRaw(
271
                                            EHoldingsEBSCOPackagesShow
256
                                            EHoldingsEBSCOPackagesShow
272
                                        ),
257
                                        ),
273
                                        title: {
258
                                        title: { dynamic: true, identifier: 'name', text: $__("Show package")}
274
                                            dynamic: true,
275
                                            text: $__("Show package"),
276
                                        },
277
                                    },
259
                                    },
278
                                ],
260
                                ],
279
                            },
261
                            },
Lines 296-305 export const routes = [ Link Here
296
                                        component: markRaw(
278
                                        component: markRaw(
297
                                            EHoldingsEBSCOTitlesShow
279
                                            EHoldingsEBSCOTitlesShow
298
                                        ),
280
                                        ),
299
                                        title: {
281
                                        title: { dynamic: true, identifier: 'publication_title', text: $__("Show title")}
300
                                            dynamic: true,
301
                                            text: $__("Show title"),
302
                                        },
303
                                    },
282
                                    },
304
                                    {
283
                                    {
305
                                        path: "/cgi-bin/koha/erm/eholdings/ebsco/resources/:resource_id",
284
                                        path: "/cgi-bin/koha/erm/eholdings/ebsco/resources/:resource_id",
Lines 307-316 export const routes = [ Link Here
307
                                        component: markRaw(
286
                                        component: markRaw(
308
                                            EHoldingsEBSCOResourcesShow
287
                                            EHoldingsEBSCOResourcesShow
309
                                        ),
288
                                        ),
310
                                        title: {
289
                                        title: { dynamic: false, text: $__("Resource")},
311
                                            dynamic: true,
312
                                            text: $__("Resource"),
313
                                        },
314
                                        is_navigation_item: false,
290
                                        is_navigation_item: false,
315
                                    },
291
                                    },
316
                                ],
292
                                ],
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/stores/navigation.js (-19 / +21 lines)
Lines 11-17 export const useNavigationStore = defineStore("navigation", { Link Here
11
        },
11
        },
12
        current: null,
12
        current: null,
13
        params: {},
13
        params: {},
14
        breadcrumbParameter: null,
14
        breadcrumbParameters: {}
15
    }),
15
    }),
16
    actions: {
16
    actions: {
17
        setRoutes(routesDef) {
17
        setRoutes(routesDef) {
Lines 70-86 export const useNavigationStore = defineStore("navigation", { Link Here
70
            }
70
            }
71
        },
71
        },
72
        setBreadcrumbParameter(param) {
72
        setBreadcrumbParameter(param) {
73
            this.breadcrumbParameter = param;
73
            if(param.hasOwnProperty('path') && param.hasOwnProperty('breadcrumbText')) {
74
                this.breadcrumbParameters[param.path] = param.breadcrumbText
75
            } else {
76
                this.breadcrumbParameters = {}
77
            }
78
        },
79
        setCurrent(routes) {
80
            this.current = routes
74
        },
81
        },
82
        setParams(params) {
83
            this.params = params
84
        }
75
    },
85
    },
76
    getters: {
86
    getters: {
77
        breadcrumbs() {
87
        breadcrumbs() {
78
            if (this.current)
88
            if (this.current)
79
                return _buildFromCurrentMatches(
89
                return _buildFromCurrentMatches(this.current, this.routeState, this.breadcrumbParameters);
80
                    this.current,
81
                    this.routeState,
82
                    this.breadcrumbParameter
83
                );
84
90
85
            return _getBaseElements(this.routeState);
91
            return _getBaseElements(this.routeState);
86
92
Lines 108-125 export const useNavigationStore = defineStore("navigation", { Link Here
108
                );
114
                );
109
            }
115
            }
110
116
111
            function _buildFromCurrentMatches(
117
            function _buildFromCurrentMatches(currentMatches, routeState, params) {
112
                currentMatches,
113
                routeState,
114
                param
115
            ) {
116
                return [
118
                return [
117
                    {
119
                    {
118
                        ...routeState,
120
                        ...routeState,
119
                        icon: null,
121
                        icon: null,
120
                        children: null,
122
                        children: null,
121
                    },
123
                    },
122
                    ..._mapMatches(currentMatches, param),
124
                    ..._mapMatches(currentMatches, params),
123
                ];
125
                ];
124
            }
126
            }
125
127
Lines 127-147 export const useNavigationStore = defineStore("navigation", { Link Here
127
                return child.is_base || (child.path && child.path !== "");
129
                return child.is_base || (child.path && child.path !== "");
128
            }
130
            }
129
131
130
            function _mapMatches(currentMatches, param) {
132
            function _mapMatches(currentMatches, params) {
131
                return currentMatches
133
                return currentMatches
132
                    .filter(match => _isBaseOrNotStub(match.meta.self))
134
                    .filter(match => _isBaseOrNotStub(match.meta.self))
133
                    .map(match => ({
135
                    .map(match => ({
134
                        ...match.meta.self,
136
                        ...match.meta.self,
135
                        title: _setTitle(match.meta.self, param),
137
                        title: _setTitle(match.meta.self, params),
136
                        icon: null,
138
                        icon: null,
137
                        path: match.path,
139
                        path: match.path,
138
                        children: null,
140
                        children: null,
139
                    }));
141
                    }));
140
            }
142
            }
141
143
142
            function _setTitle(self, param) {
144
            function _setTitle(self, params) {
143
                const title = self.title.dynamic ? param : self.title.text;
145
                const dynamicValue = params[self.path] ? params[self.path] : self.title.text
144
                return { dynamic: self.title.dynamic, text: title };
146
                const title = self.title.dynamic ? dynamicValue : self.title.text
147
                return { dynamic: self.title.dynamic, text: title }
145
            }
148
            }
146
        },
149
        },
147
        leftNavigation() {
150
        leftNavigation() {
148
- 

Return to bug 34417