Skip to content

Commit 3c8c709

Browse files
Merge pull request #6320 from christianbeeznest/ofaj-20950-3
Course: Improve hierarchy and navigation consistency across tools - refs BT#20950
2 parents 94326ec + 23e305f commit 3c8c709

File tree

7 files changed

+42
-10
lines changed

7 files changed

+42
-10
lines changed

assets/vue/components/Breadcrumb.vue

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,10 @@ function watchResourceNodeLoader() {
129129
const currentRouteName = route.name || ""
130130
const isAssignmentRoute = currentRouteName.startsWith("Assignment")
131131
const isAttendanceRoute = currentRouteName.startsWith("Attendance")
132+
const isDocumentRoute = currentRouteName.startsWith("Documents")
132133
const nodeId = route.params.node || route.query.node
133134
134-
if ((isAssignmentRoute || isAttendanceRoute) && nodeId) {
135+
if ((isAssignmentRoute || isAttendanceRoute || isDocumentRoute) && nodeId) {
135136
try {
136137
store.commit("resourcenode/setResourceNode", null)
137138
const resourceApiId = nodeId.startsWith("/api/") ? nodeId : `/api/resource_nodes/${nodeId}`
@@ -172,6 +173,19 @@ function addDocumentBreadcrumb() {
172173
route: { name: "DocumentsList", params: { node: folder.nodeId }, query: route.query },
173174
})
174175
})
176+
177+
const currentMatched = route.matched.find((r) => r.name === route.name)
178+
const label = currentMatched.meta?.breadcrumb
179+
if (label !== "") {
180+
const finalLabel = label || formatToolName(currentMatched.name)
181+
const alreadyShown = itemList.value.some((item) => item.label === finalLabel)
182+
if (!alreadyShown) {
183+
itemList.value.push({
184+
label: t(finalLabel),
185+
route: { name: currentMatched.name, params: route.params, query: route.query },
186+
})
187+
}
188+
}
175189
}
176190
177191
// Watch route changes to dynamically rebuild the breadcrumb trail

assets/vue/components/attendance/AttendanceForm.vue

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,9 @@ const submitForm = async () => {
199199
} else {
200200
const created = await attendanceService.createAttendance(postData)
201201
router.push({
202-
name: "AddCalendarEvent",
202+
name: "AttendanceAddCalendarEvent",
203203
params: {
204-
node: parentResourceNodeId.value,
204+
node: getNodeId(created.resourceNode),
205205
id: created.id,
206206
},
207207
query: {
@@ -215,4 +215,10 @@ const submitForm = async () => {
215215
console.error("Error submitting attendance:", error)
216216
}
217217
}
218+
219+
function getNodeId(resourceNode) {
220+
if (!resourceNode || !resourceNode["@id"]) return 0
221+
const parts = resourceNode["@id"].split("/")
222+
return parseInt(parts[parts.length - 1])
223+
}
218224
</script>

assets/vue/router/attendance.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,28 @@ export default {
1616
component: () => import("../views/attendance/AttendanceCreate.vue"),
1717
},
1818
{
19-
name: "EditAttendance",
19+
name: "AttendanceEditAttendance",
2020
path: "edit/:id",
2121
component: () => import("../views/attendance/AttendanceEdit.vue"),
22+
meta: { breadcrumb: "Edit attendance" },
2223
},
2324
{
2425
name: "AttendanceSheetList",
2526
path: ":id?/sheet-list",
2627
component: () => import("../views/attendance/AttendanceSheetList.vue"),
28+
meta: { breadcrumb: "Sheet list" },
2729
},
2830
{
2931
name: "AttendanceCalendarList",
3032
path: ":id?/calendar",
3133
component: () => import("../views/attendance/AttendanceCalendarList.vue"),
34+
meta: { breadcrumb: "Calendar" },
3235
},
3336
{
34-
name: "AddCalendarEvent",
37+
name: "AttendanceAddCalendarEvent",
3538
path: ":id?/calendar/create",
3639
component: () => import("../views/attendance/AttendanceCalendarAdd.vue"),
40+
meta: { breadcrumb: "Add calendar" },
3741
},
3842
{
3943
name: "ExportToPdf",

assets/vue/router/documents.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ export default {
99
name: "DocumentsList",
1010
path: "",
1111
component: () => import("../views/documents/DocumentsList.vue"),
12+
meta: { breadcrumb: "" },
1213
},
1314
{
1415
name: "DocumentsCreate",
1516
path: "new",
1617
component: () => import("../views/documents/Create.vue"),
18+
meta: { breadcrumb: "Create file" },
1719
},
1820
{
1921
name: "DocumentsCreateFile",

assets/vue/views/attendance/AttendanceCalendarList.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,8 @@ const redirectToAttendanceSheet = () => {
228228
229229
const redirectToAddCalendarEvent = () => {
230230
router.push({
231-
name: "AddCalendarEvent",
232-
params: { id: route.params.id },
231+
name: "AttendanceAddCalendarEvent",
232+
params: { node: route.params.node, id: route.params.id },
233233
query: { cid: route.query.cid, sid: route.query.sid, gid: route.query.gid },
234234
})
235235
}

assets/vue/views/attendance/AttendanceList.vue

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ const redirectToCreateAttendance = () => {
6464
6565
const redirectToEditAttendance = (attendance) => {
6666
router.push({
67-
name: "EditAttendance",
68-
params: { id: attendance.id },
67+
name: "AttendanceEditAttendance",
68+
params: { node: getNodeId(attendance.resourceNode), id: attendance.id },
6969
query: { cid, sid, gid },
7070
})
7171
}
@@ -136,5 +136,11 @@ const fetchAttendances = async ({ page = 1, rows = 10 } = {}) => {
136136
}
137137
}
138138
139+
function getNodeId(resourceNode) {
140+
if (!resourceNode || !resourceNode["@id"]) return 0
141+
const parts = resourceNode["@id"].split("/")
142+
return parseInt(parts[parts.length - 1])
143+
}
144+
139145
onMounted(fetchAttendances)
140146
</script>

assets/vue/views/attendance/AttendanceSheetList.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ const qrImageUrl = ref("")
567567
const redirectToCalendarList = () => {
568568
router.push({
569569
name: "AttendanceCalendarList",
570-
params: { id: route.params.id },
570+
params: { node: route.params.node, id: route.params.id },
571571
query: { sid, cid, gid },
572572
})
573573
}

0 commit comments

Comments
 (0)