Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,35 +49,44 @@ import { MenuItem } from 'primevue/menuitem'
import { computed } from 'vue'
import { useRoute } from 'vue-router'

import { useLayoutStore } from '../store'

type EnhancedMenuItem = MenuItem & { path: string; active?: boolean }

const layoutStore = useLayoutStore()
const route = useRoute()
// Merge all matched meta.breadcrumps with current route breadcrumps

const items = computed(() =>
[
...route.matched.reduce<EnhancedMenuItem[]>((acc, curr) => {
if (curr.name === route.name) return acc
layoutStore.breadcrumps?.length
? layoutStore.breadcrumps?.map((item, index, items) => ({
label: item.title,
path: item.path,
active: index === items.length - 1
}))
: [
...route.matched.reduce<EnhancedMenuItem[]>((acc, curr) => {
if (curr.name === route.name) return acc

return [
...acc,
...(curr.meta?.breadcrump ?? []).map((item) => ({
return [
...acc,
...(curr.meta?.breadcrump ?? []).map((item) => ({
label: item.title,
path: item.path
}))
]
}, []),
// adding current route wich is not in matched meta
...(route.meta.breadcrump ?? []).map((item) => ({
label: item.title,
path: item.path
}))
]
}, []),
// adding current route wich is not in matched meta
...(route.meta.breadcrump ?? []).map((item) => ({
label: item.title,
path: item.path
}))
]
// last will be active
.map((item, index, items) => ({
...item,
active: index === items.length - 1
}))
// last will be active
.map((item, index, items) => ({
...item,
active: index === items.length - 1
}))
)
</script>

Expand Down
4 changes: 3 additions & 1 deletion web-app/packages/lib/src/modules/layout/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface LayoutState {
isUnderOverlayBreakpoint: boolean
/** Parsed closed elements from local storage and pushed back to local storage */
closedElements: string[]
breadcrumps: { title: string; path: string }[]
}

const CLOSED_ELEMENTS_KEY = 'mm-closed-elements'
Expand All @@ -20,7 +21,8 @@ export const useLayoutStore = defineStore('layoutModule', {
overlayBreakpoint: 1200,
drawer: false,
isUnderOverlayBreakpoint: false,
closedElements: []
closedElements: [],
breadcrumps: []
}),
getters: {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,8 @@ export default defineComponent({
*/
tabClick(index: number) {
this.$router.push({
name: this.tabs[index].route
name: this.tabs[index].route,
query: {}
})
}
}
Expand Down
Loading