@@ -, +, @@ --- .../prog/js/vue/fetch/erm-api-client.js | 4 +++ .../prog/js/vue/fetch/http-client.js | 32 +++++++++++-------- .../intranet-tmpl/prog/js/vue/modules/erm.ts | 22 ++++++++++++- 3 files changed, 43 insertions(+), 15 deletions(-) --- a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/erm-api-client.js +++ a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/erm-api-client.js @@ -25,6 +25,7 @@ export class ERMAPIClient extends HttpClient { "x-koha-embed": "periods,user_roles,user_roles.patron,agreement_licenses,agreement_licenses.license,agreement_relationships,agreement_relationships.related_agreement,documents,agreement_packages,agreement_packages.package,vendor", }, + class: 'agreement' }), getAll: query => this.getAll({ @@ -67,6 +68,7 @@ export class ERMAPIClient extends HttpClient { "x-koha-embed": "user_roles,user_roles.patron,vendor,documents", }, + class: 'license' }), getAll: query => this.getAll({ @@ -112,6 +114,7 @@ export class ERMAPIClient extends HttpClient { "x-koha-embed": "package_agreements,package_agreements.agreement,resources+count,vendor", }, + class: 'local_package' }), getAll: query => this.getAll({ @@ -156,6 +159,7 @@ export class ERMAPIClient extends HttpClient { headers: { "x-koha-embed": "resources,resources.package", }, + class: 'local_title' }), delete: id => this.delete({ --- a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/http-client.js +++ a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/http-client.js @@ -42,26 +42,30 @@ class HttpClient { if (error) throw Error(error); - const navigationStore = useNavigationStore() - const { current } = navigationStore - current.forEach(route => { - const { title, path } = route.meta.self - if(title && title.dynamic && res[title.identifier]) { - navigationStore.setBreadcrumbParameter({ - breadcrumbText: res[title.identifier], - path: path - }) - } - }) - return res; } - get(params = {}) { - return this._fetchJSON(params.endpoint, params.headers, { + async get(params = {}) { + const res = await this._fetchJSON(params.endpoint, params.headers, { ...params.options, method: "GET", }); + + const navigationStore = useNavigationStore() + const { current } = navigationStore + if(current && current.slice(-1)[0].routeClass === params.class) { + current.forEach(route => { + const { title, path } = route.meta.self + if(title && title.dynamic && res[title.identifier]) { + navigationStore.setBreadcrumbParameter({ + breadcrumbText: res[title.identifier], + path: path + }) + } + }) + } + + return res } getAll(params = {}) { --- a/koha-tmpl/intranet-tmpl/prog/js/vue/modules/erm.ts +++ a/koha-tmpl/intranet-tmpl/prog/js/vue/modules/erm.ts @@ -60,7 +60,17 @@ app.mount("#erm"); const { removeMessages } = mainStore; router.beforeEach((to, from) => { - navigationStore.setCurrent(to.matched) + let matchedRoutes = [] + if (to.path.match(/\/erm\/agreements/)) { + matchedRoutes = _setRouteClass(to.matched, 'agreement') + } else if (to.path.match(/\/erm\/licenses/)) { + matchedRoutes = _setRouteClass(to.matched, 'license') + } else if (to.path.match(/\/erm\/eholdings\/local\/packages/)) { + matchedRoutes = _setRouteClass(to.matched, 'local_package') + } else if (to.path.match(/\/erm\/eholdings\/local\/titles/)) { + matchedRoutes = _setRouteClass(to.matched, 'local_title') + } + navigationStore.setCurrent(matchedRoutes) navigationStore.setParams(to.params || {}) navigationStore.setBreadcrumbParameter({}) removeMessages(); // This will actually flag the messages as displayed already @@ -81,3 +91,13 @@ router.afterEach((to, from) => { node.click(); } }); + +const _setRouteClass = (routes: Array, routeClass: string) => { + const classedRoutes = routes.map(route => { + return { + ...route, + routeClass + } + }) + return classedRoutes +} --