Bugzilla – Attachment 154258 Details for
Bug 34417
ERM's breadcrumb (Vue) does not display the entity's name
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 34417: Add routeClass to routes and api call
Bug-34417-Add-routeClass-to-routes-and-api-call.patch (text/plain), 5.73 KB, created by
Matt Blenkinsop
on 2023-08-04 11:58:28 UTC
(
hide
)
Description:
Bug 34417: Add routeClass to routes and api call
Filename:
MIME Type:
Creator:
Matt Blenkinsop
Created:
2023-08-04 11:58:28 UTC
Size:
5.73 KB
patch
obsolete
>From d2ac478c7245c48bd26a747a15bf0c878d53952b Mon Sep 17 00:00:00 2001 >From: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com> >Date: Fri, 4 Aug 2023 11:55:59 +0000 >Subject: [PATCH] Bug 34417: Add routeClass to routes and api call > >This patch adds a class to match the route to the API call and ensure that no items with the same property (e.g. license.name and agreement.name) can lead to incorrect breadcrumbs. > >Code is also moved into the get() request function to reduce the number of times it is called >--- > .../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(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/erm-api-client.js b/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/erm-api-client.js >index 0acdcac5a4..d918e6c1d6 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/erm-api-client.js >+++ b/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({ >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/http-client.js b/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/http-client.js >index 807db61039..74436dda18 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/http-client.js >+++ b/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 = {}) { >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/modules/erm.ts b/koha-tmpl/intranet-tmpl/prog/js/vue/modules/erm.ts >index f8391a091f..5141b0ff51 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/modules/erm.ts >+++ b/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<Object>, routeClass: string) => { >+ const classedRoutes = routes.map(route => { >+ return { >+ ...route, >+ routeClass >+ } >+ }) >+ return classedRoutes >+} >-- >2.37.1 (Apple Git-137.1)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 34417
:
153914
|
153958
|
153959
|
153960
| 154258 |
154263