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 (-32 / +12 lines)
Lines 60-86 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
                        children: [
65
                            {
66
                                path: "items",
67
                                title: { dynamic: false, text: $__("")},
68
                                children: [
69
                                    {
70
                                        path: "add",
71
                                        name: "TestChildTwo",
72
                                        component: markRaw(EHoldingsLocalTitlesFormAdd),
73
                                        title: { dynamic: false, text: $__("Add item to train")},
74
                                    },
75
                                    {
76
                                        path: "add/:item_ids",
77
                                        name: "TestChildThree",
78
                                        component: markRaw(EHoldingsLocalPackagesFormAdd),
79
                                        title: { dynamic: false, text: $__("Add items to train")},
80
                                    },
81
                                ]
82
                            },
83
                        ]
84
                    },
64
                    },
85
                    {
65
                    {
86
                        path: "add",
66
                        path: "add",
Lines 92-98 export const routes = [ Link Here
92
                        path: "edit/:agreement_id",
72
                        path: "edit/:agreement_id",
93
                        name: "AgreementsFormAddEdit",
73
                        name: "AgreementsFormAddEdit",
94
                        component: markRaw(AgreementsFormAdd),
74
                        component: markRaw(AgreementsFormAdd),
95
                        title: { dynamic: true, text: $__("Edit agreement")},
75
                        title: { dynamic: true, identifier: "name", text: $__("Edit agreement")},
96
                    },
76
                    },
97
                ],
77
                ],
98
            },
78
            },
Lines 111-117 export const routes = [ Link Here
111
                        path: ":license_id",
91
                        path: ":license_id",
112
                        name: "LicensesShow",
92
                        name: "LicensesShow",
113
                        component: markRaw(LicensesShow),
93
                        component: markRaw(LicensesShow),
114
                        title: { dynamic: true, text: $__("Show license")}
94
                        title: { dynamic: true, identifier: "name", text: $__("Show license")}
115
                    },
95
                    },
116
                    {
96
                    {
117
                        path: "add",
97
                        path: "add",
Lines 123-129 export const routes = [ Link Here
123
                        path: "edit/:license_id",
103
                        path: "edit/:license_id",
124
                        name: "LicensesFormAddEdit",
104
                        name: "LicensesFormAddEdit",
125
                        component: markRaw(LicensesFormAdd),
105
                        component: markRaw(LicensesFormAdd),
126
                        title: { dynamic: true, text: $__("Edit license")}
106
                        title: { dynamic: true, identifier: 'name', text: $__("Edit license")}
127
                    },
107
                    },
128
                ],
108
                ],
129
            },
109
            },
Lines 158-164 export const routes = [ Link Here
158
                                        component: markRaw(
138
                                        component: markRaw(
159
                                            EHoldingsLocalPackagesShow
139
                                            EHoldingsLocalPackagesShow
160
                                        ),
140
                                        ),
161
                                        title: { dynamic: true, text: $__("Show package")}
141
                                        title: { dynamic: true, identifier: 'name', text: $__("Show package")}
162
                                    },
142
                                    },
163
                                    {
143
                                    {
164
                                        path: "add",
144
                                        path: "add",
Lines 174-180 export const routes = [ Link Here
174
                                        component: markRaw(
154
                                        component: markRaw(
175
                                            EHoldingsLocalPackagesFormAdd
155
                                            EHoldingsLocalPackagesFormAdd
176
                                        ),
156
                                        ),
177
                                        title: { dynamic: true, text: $__("Edit package")}
157
                                        title: { dynamic: true, identifier: 'name', text: $__("Edit package")}
178
                                    },
158
                                    },
179
                                ],
159
                                ],
180
                            },
160
                            },
Lines 197-203 export const routes = [ Link Here
197
                                        component: markRaw(
177
                                        component: markRaw(
198
                                            EHoldingsLocalTitlesShow
178
                                            EHoldingsLocalTitlesShow
199
                                        ),
179
                                        ),
200
                                        title: { dynamic: true, text: $__("Show title")}
180
                                        title: { dynamic: true, identifier: 'publication_title', text: $__("Show title")}
201
                                    },
181
                                    },
202
                                    {
182
                                    {
203
                                        path: "add",
183
                                        path: "add",
Lines 213-219 export const routes = [ Link Here
213
                                        component: markRaw(
193
                                        component: markRaw(
214
                                            EHoldingsLocalTitlesFormAdd
194
                                            EHoldingsLocalTitlesFormAdd
215
                                        ),
195
                                        ),
216
                                        title: { dynamic: true, text: $__("Edit title")}
196
                                        title: { dynamic: true, identifier: 'publication_title', text: $__("Edit title")}
217
                                    },
197
                                    },
218
                                    {
198
                                    {
219
                                        path: "import",
199
                                        path: "import",
Lines 229-235 export const routes = [ Link Here
229
                                        component: markRaw(
209
                                        component: markRaw(
230
                                            EHoldingsLocalResourcesShow
210
                                            EHoldingsLocalResourcesShow
231
                                        ),
211
                                        ),
232
                                        title: { dynamic: true, text: $__("Resource")}
212
                                        title: { dynamic: false, text: $__("Resource")}
233
                                    },
213
                                    },
234
                                ],
214
                                ],
235
                            },
215
                            },
Lines 260-266 export const routes = [ Link Here
260
                                        component: markRaw(
240
                                        component: markRaw(
261
                                            EHoldingsEBSCOPackagesShow
241
                                            EHoldingsEBSCOPackagesShow
262
                                        ),
242
                                        ),
263
                                        title: { dynamic: true, text: $__("Show package")}
243
                                        title: { dynamic: true, identifier: 'name', text: $__("Show package")}
264
                                    },
244
                                    },
265
                                ],
245
                                ],
266
                            },
246
                            },
Lines 283-289 export const routes = [ Link Here
283
                                        component: markRaw(
263
                                        component: markRaw(
284
                                            EHoldingsEBSCOTitlesShow
264
                                            EHoldingsEBSCOTitlesShow
285
                                        ),
265
                                        ),
286
                                        title: { dynamic: true, text: $__("Show title")}
266
                                        title: { dynamic: true, identifier: 'publication_title', text: $__("Show title")}
287
                                    },
267
                                    },
288
                                    {
268
                                    {
289
                                        path: "/cgi-bin/koha/erm/eholdings/ebsco/resources/:resource_id",
269
                                        path: "/cgi-bin/koha/erm/eholdings/ebsco/resources/:resource_id",
Lines 291-297 export const routes = [ Link Here
291
                                        component: markRaw(
271
                                        component: markRaw(
292
                                            EHoldingsEBSCOResourcesShow
272
                                            EHoldingsEBSCOResourcesShow
293
                                        ),
273
                                        ),
294
                                        title: { dynamic: true, text: $__("Resource")},
274
                                        title: { dynamic: false, text: $__("Resource")},
295
                                        is_navigation_item: false,
275
                                        is_navigation_item: false,
296
                                    },
276
                                    },
297
                                ],
277
                                ],
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/stores/navigation.js (-10 / +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-82 export const useNavigationStore = defineStore("navigation", { Link Here
70
            }
70
            }
71
        },
71
        },
72
        setBreadcrumbParameter(param) {
72
        setBreadcrumbParameter(param) {
73
            this.breadcrumbParameter = param
73
            // console.log(param)
74
            if(param.hasOwnProperty('path') && param.hasOwnProperty('breadcrumbText')) {
75
                this.breadcrumbParameters[param.path] = param.breadcrumbText
76
            } else {
77
                this.breadcrumbParameters = {}
78
            }
79
        },
80
        setCurrent(routes) {
81
            this.current = routes
82
        },
83
        setParams(params) {
84
            this.params = params
74
        }
85
        }
75
    },
86
    },
76
    getters: {
87
    getters: {
77
        breadcrumbs() {
88
        breadcrumbs() {
78
            if (this.current)
89
            if (this.current)
79
                return _buildFromCurrentMatches(this.current, this.routeState, this.breadcrumbParameter);
90
                return _buildFromCurrentMatches(this.current, this.routeState, this.breadcrumbParameters);
80
91
81
            return _getBaseElements(this.routeState);
92
            return _getBaseElements(this.routeState);
82
93
Lines 104-117 export const useNavigationStore = defineStore("navigation", { Link Here
104
                );
115
                );
105
            }
116
            }
106
117
107
            function _buildFromCurrentMatches(currentMatches, routeState, param) {
118
            function _buildFromCurrentMatches(currentMatches, routeState, params) {
108
                return [
119
                return [
109
                    {
120
                    {
110
                        ...routeState,
121
                        ...routeState,
111
                        icon: null,
122
                        icon: null,
112
                        children: null,
123
                        children: null,
113
                    },
124
                    },
114
                    ..._mapMatches(currentMatches, param),
125
                    ..._mapMatches(currentMatches, params),
115
                ];
126
                ];
116
            }
127
            }
117
128
Lines 119-130 export const useNavigationStore = defineStore("navigation", { Link Here
119
                return child.is_base || (child.path && child.path !== "");
130
                return child.is_base || (child.path && child.path !== "");
120
            }
131
            }
121
132
122
            function _mapMatches(currentMatches, param) {
133
            function _mapMatches(currentMatches, params) {
123
                return currentMatches
134
                return currentMatches
124
                    .filter(match => _isBaseOrNotStub(match.meta.self))
135
                    .filter(match => _isBaseOrNotStub(match.meta.self))
125
                    .map(match => ({
136
                    .map(match => ({
126
                        ...match.meta.self,
137
                        ...match.meta.self,
127
                        title: _setTitle(match.meta.self, param),
138
                        title: _setTitle(match.meta.self, params),
128
                        icon: null,
139
                        icon: null,
129
                        path: match.path,
140
                        path: match.path,
130
                        children: null,
141
                        children: null,
Lines 132-139 export const useNavigationStore = defineStore("navigation", { Link Here
132
                    .filter(match => match.title.text);
143
                    .filter(match => match.title.text);
133
            }
144
            }
134
145
135
            function _setTitle(self, param) {
146
            function _setTitle(self, params) {
136
                const title = self.title.dynamic ? param : self.title.text
147
                const dynamicValue = params[self.path] ? params[self.path] : self.title.text
148
                const title = self.title.dynamic ? dynamicValue : self.title.text
137
                return { dynamic: self.title.dynamic, text: title }
149
                return { dynamic: self.title.dynamic, text: title }
138
            }
150
            }
139
        },
151
        },
140
- 

Return to bug 34417