From 04b179aa523ecdf893bad160cca995793b0bd4b3 Mon Sep 17 00:00:00 2001 From: Daniel Egger Date: Tue, 9 May 2023 18:13:09 +0200 Subject: [PATCH] Add query url and clickable navigation --- client/src/components/FeedbackForm.vue | 210 +++++++++--------- .../components/ui/ItNavigationProgress.vue | 13 +- .../assignment/AssignmentView.vue | 44 ++-- .../layouts/LearningContentMultiLayout.vue | 4 +- 4 files changed, 138 insertions(+), 133 deletions(-) diff --git a/client/src/components/FeedbackForm.vue b/client/src/components/FeedbackForm.vue index 6e455817..facbb4dd 100644 --- a/client/src/components/FeedbackForm.vue +++ b/client/src/components/FeedbackForm.vue @@ -1,106 +1,3 @@ - - + + diff --git a/client/src/components/ui/ItNavigationProgress.vue b/client/src/components/ui/ItNavigationProgress.vue index ebd9e595..03b06ca5 100644 --- a/client/src/components/ui/ItNavigationProgress.vue +++ b/client/src/components/ui/ItNavigationProgress.vue @@ -9,14 +9,14 @@ export interface Props { startBadgeText?: string; endBadgeText?: string; baseUrl?: string; - queryParam?: string; + stepQueryParam?: string; } const props = withDefaults(defineProps(), { startBadgeText: undefined, endBadgeText: undefined, baseUrl: undefined, - queryParam: "page", + stepQueryParam: "step", }); const hasStartBadge = computed(() => typeof props.startBadgeText !== "undefined"); @@ -67,7 +67,10 @@ function calcStepIndex(step: number) { :class="startBadgeClasses" data-cy="nav-progress-step-start" > - + {{ props.startBadgeText }} {{ props.startBadgeText }} @@ -84,7 +87,7 @@ function calcStepIndex(step: number) { > {{ step + 1 }} @@ -100,7 +103,7 @@ function calcStepIndex(step: number) { > {{ props.endBadgeText }} diff --git a/client/src/pages/learningPath/learningContentPage/assignment/AssignmentView.vue b/client/src/pages/learningPath/learningContentPage/assignment/AssignmentView.vue index 27123bb0..9b1eb527 100644 --- a/client/src/pages/learningPath/learningContentPage/assignment/AssignmentView.vue +++ b/client/src/pages/learningPath/learningContentPage/assignment/AssignmentView.vue @@ -41,7 +41,7 @@ const props = defineProps<{ }>(); // 0 = introduction, 1 - n = tasks, n+1 = submission -const pageIndex = useRouteQuery("page", "0", { transform: Number, mode: "push" }); +const stepIndex = useRouteQuery("step", "0", { transform: Number, mode: "push" }); const assignmentCompletion = computed(() => assignmentStore.assignmentCompletion); const completionStatus = computed(() => { @@ -64,10 +64,10 @@ onMounted(async () => { ); if ( - pageIndex.value === 0 && + stepIndex.value === 0 && (completionStatus.value ?? "in_progress") !== "in_progress" ) { - pageIndex.value = numPages.value - 1; + stepIndex.value = numPages.value - 1; } } catch (error) { log.error(error); @@ -76,9 +76,9 @@ onMounted(async () => { const numTasks = computed(() => state.assignment?.tasks?.length ?? 0); const numPages = computed(() => numTasks.value + 2); -const showPreviousButton = computed(() => pageIndex.value != 0); -const showNextButton = computed(() => pageIndex.value + 1 < numPages.value); -const showExitButton = computed(() => numPages.value === pageIndex.value + 1); +const showPreviousButton = computed(() => stepIndex.value != 0); +const showNextButton = computed(() => stepIndex.value + 1 < numPages.value); +const showExitButton = computed(() => numPages.value === stepIndex.value + 1); const dueDate = computed(() => dayjs(state.courseSessionAssignmentDetails?.submissionDeadlineDateTimeUtc) ); @@ -86,41 +86,41 @@ const courseSessionId = computed( () => courseSessionsStore.currentCourseSession?.id ?? 0 ); const currentTask = computed(() => { - if (pageIndex.value > 0 && pageIndex.value <= numTasks.value) { - return state.assignment?.tasks[pageIndex.value - 1]; + if (stepIndex.value > 0 && stepIndex.value <= numTasks.value) { + return state.assignment?.tasks[stepIndex.value - 1]; } return undefined; }); const handleBack = () => { log.debug("handleBack"); - if (pageIndex.value > 0) { - pageIndex.value -= 1; + if (stepIndex.value > 0) { + stepIndex.value -= 1; } - log.debug(`pageIndex: ${pageIndex.value}`); + log.debug(`pageIndex: ${stepIndex.value}`); }; const handleContinue = () => { log.debug("handleContinue"); - if (pageIndex.value + 1 < numPages.value) { - pageIndex.value += 1; + if (stepIndex.value + 1 < numPages.value) { + stepIndex.value += 1; } - log.debug(`pageIndex: ${pageIndex.value}`); + log.debug(`pageIndex: ${stepIndex.value}`); }; const jumpToTask = (task: AssignmentTask) => { log.debug("jumpToTask", task); const index = state.assignment?.tasks.findIndex((t) => t.id === task.id); if (index && index >= 0) { - pageIndex.value = index + 1; + stepIndex.value = index + 1; } - log.debug(`pageIndex: ${pageIndex.value}`); + log.debug(`pageIndex: ${stepIndex.value}`); }; const getTitle = () => { - if (0 === pageIndex.value) { + if (0 === stepIndex.value) { return t("general.introduction"); - } else if (pageIndex.value === numPages.value - 1) { + } else if (stepIndex.value === numPages.value - 1) { return t("general.submission"); } return currentTask?.value?.value.title ?? "Unknown"; @@ -137,7 +137,7 @@ const assignmentUser = computed(() => {
{ :show-start-button="false" :show-previous-button="showPreviousButton" :base-url="props.learningContent.frontend_url" - query-param="page" + step-query-param="step" start-badge-text="Einleitung" end-badge-text="Abgabe" close-button-variant="close" @@ -157,7 +157,7 @@ const assignmentUser = computed(() => {
@@ -167,7 +167,7 @@ const assignmentUser = computed(() => { :assignment-id="props.assignmentId" > (), { @@ -58,7 +58,7 @@ const emit = defineEmits(["previous", "next", "exit"]); :steps="stepsCount" :end-badge-text="props.endBadgeText" :base-url="props.baseUrl" - :query-param="props.queryParam" + :query-param="props.stepQueryParam" class="overflow-hidden pb-12" >