Refactor course url handling
This commit is contained in:
parent
41ead1dad4
commit
06d284b1ce
|
|
@ -24,7 +24,7 @@ const { t } = useTranslation();
|
||||||
<div class="flex space-x-8">
|
<div class="flex space-x-8">
|
||||||
<router-link
|
<router-link
|
||||||
data-cy="preview-learn-path-link"
|
data-cy="preview-learn-path-link"
|
||||||
:to="getLearningPathUrl(courseSession)"
|
:to="getLearningPathUrl(courseSession.course.slug)"
|
||||||
class="preview-nav-item"
|
class="preview-nav-item"
|
||||||
:class="{ 'preview-nav-item--active': inLearningPath() }"
|
:class="{ 'preview-nav-item--active': inLearningPath() }"
|
||||||
>
|
>
|
||||||
|
|
@ -33,7 +33,7 @@ const { t } = useTranslation();
|
||||||
|
|
||||||
<router-link
|
<router-link
|
||||||
data-cy="preview-competence-profile-link"
|
data-cy="preview-competence-profile-link"
|
||||||
:to="getCompetenceNaviUrl(courseSession)"
|
:to="getCompetenceNaviUrl(courseSession.course.slug)"
|
||||||
class="preview-nav-item"
|
class="preview-nav-item"
|
||||||
:class="{ 'preview-nav-item--active': inCompetenceProfile() }"
|
:class="{ 'preview-nav-item--active': inCompetenceProfile() }"
|
||||||
>
|
>
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,9 @@ onMounted(() => {
|
||||||
v-if="userStore.loggedIn"
|
v-if="userStore.loggedIn"
|
||||||
:show="state.showMobileNavigationMenu"
|
:show="state.showMobileNavigationMenu"
|
||||||
:course-session="courseSessionsStore.currentCourseSession"
|
:course-session="courseSessionsStore.currentCourseSession"
|
||||||
:media-url="getMediaCenterUrl(courseSessionsStore.currentCourseSession)"
|
:media-url="
|
||||||
|
getMediaCenterUrl(courseSessionsStore.currentCourseSession?.course?.slug)
|
||||||
|
"
|
||||||
:user="userStore"
|
:user="userStore"
|
||||||
@closemodal="state.showMobileNavigationMenu = false"
|
@closemodal="state.showMobileNavigationMenu = false"
|
||||||
@logout="userStore.handleLogout()"
|
@logout="userStore.handleLogout()"
|
||||||
|
|
@ -142,7 +144,11 @@ onMounted(() => {
|
||||||
|
|
||||||
<router-link
|
<router-link
|
||||||
data-cy="navigation-preview-link"
|
data-cy="navigation-preview-link"
|
||||||
:to="getLearningPathUrl(courseSessionsStore.currentCourseSession)"
|
:to="
|
||||||
|
getLearningPathUrl(
|
||||||
|
courseSessionsStore.currentCourseSession.course.slug
|
||||||
|
)
|
||||||
|
"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
class="nav-item"
|
class="nav-item"
|
||||||
>
|
>
|
||||||
|
|
@ -155,7 +161,11 @@ onMounted(() => {
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<router-link
|
<router-link
|
||||||
data-cy="navigation-learning-path-link"
|
data-cy="navigation-learning-path-link"
|
||||||
:to="getLearningPathUrl(courseSessionsStore.currentCourseSession)"
|
:to="
|
||||||
|
getLearningPathUrl(
|
||||||
|
courseSessionsStore.currentCourseSession.course.slug
|
||||||
|
)
|
||||||
|
"
|
||||||
class="nav-item"
|
class="nav-item"
|
||||||
:class="{ 'nav-item--active': inLearningPath() }"
|
:class="{ 'nav-item--active': inLearningPath() }"
|
||||||
>
|
>
|
||||||
|
|
@ -165,7 +175,9 @@ onMounted(() => {
|
||||||
<router-link
|
<router-link
|
||||||
data-cy="navigation-competence-profile-link"
|
data-cy="navigation-competence-profile-link"
|
||||||
:to="
|
:to="
|
||||||
getCompetenceNaviUrl(courseSessionsStore.currentCourseSession)
|
getCompetenceNaviUrl(
|
||||||
|
courseSessionsStore.currentCourseSession.course.slug
|
||||||
|
)
|
||||||
"
|
"
|
||||||
class="nav-item"
|
class="nav-item"
|
||||||
:class="{ 'nav-item--active': inCompetenceProfile() }"
|
:class="{ 'nav-item--active': inCompetenceProfile() }"
|
||||||
|
|
@ -180,7 +192,11 @@ onMounted(() => {
|
||||||
<div class="flex items-stretch justify-start space-x-8">
|
<div class="flex items-stretch justify-start space-x-8">
|
||||||
<router-link
|
<router-link
|
||||||
v-if="inCourse() && courseSessionsStore.currentCourseSession"
|
v-if="inCourse() && courseSessionsStore.currentCourseSession"
|
||||||
:to="getMediaCenterUrl(courseSessionsStore.currentCourseSession)"
|
:to="
|
||||||
|
getMediaCenterUrl(
|
||||||
|
courseSessionsStore.currentCourseSession.course.slug
|
||||||
|
)
|
||||||
|
"
|
||||||
data-cy="medialibrary-link"
|
data-cy="medialibrary-link"
|
||||||
class="nav-item-no-mobile"
|
class="nav-item-no-mobile"
|
||||||
:class="{ 'nav-item--active': inMediaLibrary() }"
|
:class="{ 'nav-item--active': inMediaLibrary() }"
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ const courseSessionsStore = useCourseSessionsStore();
|
||||||
<li class="mb-6">
|
<li class="mb-6">
|
||||||
<button
|
<button
|
||||||
data-cy="navigation-mobile-preview-link"
|
data-cy="navigation-mobile-preview-link"
|
||||||
@click="clickLink(getLearningPathUrl(courseSession))"
|
@click="clickLink(getLearningPathUrl(courseSession.course.slug))"
|
||||||
>
|
>
|
||||||
{{ $t("a.VorschauTeilnehmer") }}
|
{{ $t("a.VorschauTeilnehmer") }}
|
||||||
</button>
|
</button>
|
||||||
|
|
@ -82,7 +82,7 @@ const courseSessionsStore = useCourseSessionsStore();
|
||||||
<li class="mb-6">
|
<li class="mb-6">
|
||||||
<button
|
<button
|
||||||
data-cy="navigation-mobile-learning-path-link"
|
data-cy="navigation-mobile-learning-path-link"
|
||||||
@click="clickLink(getLearningPathUrl(courseSession))"
|
@click="clickLink(getLearningPathUrl(courseSession.course.slug))"
|
||||||
>
|
>
|
||||||
{{ $t("general.learningPath") }}
|
{{ $t("general.learningPath") }}
|
||||||
</button>
|
</button>
|
||||||
|
|
@ -90,7 +90,7 @@ const courseSessionsStore = useCourseSessionsStore();
|
||||||
<li class="mb-6">
|
<li class="mb-6">
|
||||||
<button
|
<button
|
||||||
data-cy="navigation-mobile-competence-profile-link"
|
data-cy="navigation-mobile-competence-profile-link"
|
||||||
@click="clickLink(getCompetenceNaviUrl(courseSession))"
|
@click="clickLink(getCompetenceNaviUrl(courseSession.course.slug))"
|
||||||
>
|
>
|
||||||
{{ $t("competences.title") }}
|
{{ $t("competences.title") }}
|
||||||
</button>
|
</button>
|
||||||
|
|
@ -99,7 +99,7 @@ const courseSessionsStore = useCourseSessionsStore();
|
||||||
<li class="mb-6">
|
<li class="mb-6">
|
||||||
<button
|
<button
|
||||||
data-cy="medialibrary-link"
|
data-cy="medialibrary-link"
|
||||||
@click="clickLink(getMediaCenterUrl(courseSession))"
|
@click="clickLink(getMediaCenterUrl(courseSession.course.slug))"
|
||||||
>
|
>
|
||||||
{{ $t("a.Mediathek") }}
|
{{ $t("a.Mediathek") }}
|
||||||
</button>
|
</button>
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ const getNextStepLink = (courseSession: CourseSession) => {
|
||||||
if (courseSessionsStore.hasCockpit(courseSession)) {
|
if (courseSessionsStore.hasCockpit(courseSession)) {
|
||||||
return `${courseSession.course_url}/cockpit`;
|
return `${courseSession.course_url}/cockpit`;
|
||||||
}
|
}
|
||||||
return getLearningPathUrl(courseSession);
|
return getLearningPathUrl(courseSession.course.slug);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ function userCountStatusForCircle(userId: string) {
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="bg-gray-200">
|
<div class="bg-gray-200">
|
||||||
|
<div v-if="cockpitStore.circles?.length">
|
||||||
<div v-if="cockpitStore.currentCircle" class="container-large">
|
<div v-if="cockpitStore.currentCircle" class="container-large">
|
||||||
<div class="mb-9 flex flex-col lg:flex-row lg:items-center lg:justify-between">
|
<div class="mb-9 flex flex-col lg:flex-row lg:items-center lg:justify-between">
|
||||||
<h1>Cockpit</h1>
|
<h1>Cockpit</h1>
|
||||||
|
|
@ -208,6 +209,7 @@ function userCountStatusForCircle(userId: string) {
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped></style>
|
<style scoped></style>
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ import eventBus from "@/utils/eventBus";
|
||||||
import { useRouteQuery } from "@vueuse/router";
|
import { useRouteQuery } from "@vueuse/router";
|
||||||
import { computed, onUnmounted } from "vue";
|
import { computed, onUnmounted } from "vue";
|
||||||
import { getPreviousRoute } from "@/router/history";
|
import { getPreviousRoute } from "@/router/history";
|
||||||
|
import { getCompetenceNaviUrl } from "@/utils/utils";
|
||||||
|
|
||||||
log.debug("LearningContent.vue setup");
|
log.debug("LearningContent.vue setup");
|
||||||
|
|
||||||
|
|
@ -127,7 +128,7 @@ onUnmounted(() => {
|
||||||
<div class="mt-6 lg:mt-12">
|
<div class="mt-6 lg:mt-12">
|
||||||
{{ $t("selfEvaluation.progressText") }}
|
{{ $t("selfEvaluation.progressText") }}
|
||||||
<router-link
|
<router-link
|
||||||
:to="courseSession.competence_url"
|
:to="getCompetenceNaviUrl(courseSession.course.slug)"
|
||||||
class="text-primary-500 underline"
|
class="text-primary-500 underline"
|
||||||
>
|
>
|
||||||
{{ $t("selfEvaluation.progressLink") }}
|
{{ $t("selfEvaluation.progressLink") }}
|
||||||
|
|
|
||||||
|
|
@ -1,34 +1,31 @@
|
||||||
import type { AssignmentType, CourseSession } from "@/types";
|
import type { AssignmentType } from "@/types";
|
||||||
import { useTranslation } from "i18next-vue";
|
import { useTranslation } from "i18next-vue";
|
||||||
|
|
||||||
export function assertUnreachable(msg: string): never {
|
export function assertUnreachable(msg: string): never {
|
||||||
throw new Error("Didn't expect to get here, " + msg);
|
throw new Error("Didn't expect to get here, " + msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
function createCourseUrl(
|
function createCourseUrl(courseSlug: string | undefined, specificSub: string): string {
|
||||||
courseSession: CourseSession | undefined,
|
if (!courseSlug) {
|
||||||
specificSub: string
|
return "/";
|
||||||
): string {
|
|
||||||
if (!courseSession) {
|
|
||||||
return "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (["learn", "media", "competence"].includes(specificSub)) {
|
if (["learn", "media", "competence"].includes(specificSub)) {
|
||||||
return `${courseSession.course_url}/${specificSub}`;
|
return `/course/${courseSlug}/${specificSub}`;
|
||||||
}
|
}
|
||||||
return courseSession.course_url;
|
return `/course/${courseSlug}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getCompetenceNaviUrl(courseSession: CourseSession | undefined): string {
|
export function getCompetenceNaviUrl(courseSlug: string | undefined): string {
|
||||||
return createCourseUrl(courseSession, "competence");
|
return createCourseUrl(courseSlug, "competence");
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getMediaCenterUrl(courseSession: CourseSession | undefined): string {
|
export function getMediaCenterUrl(courseSlug: string | undefined): string {
|
||||||
return createCourseUrl(courseSession, "media");
|
return createCourseUrl(courseSlug, "media");
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getLearningPathUrl(courseSession: CourseSession | undefined): string {
|
export function getLearningPathUrl(courseSlug: string | undefined): string {
|
||||||
return createCourseUrl(courseSession, "learn");
|
return createCourseUrl(courseSlug, "learn");
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getAssignmentTypeTitle(assignmentType: AssignmentType): string {
|
export function getAssignmentTypeTitle(assignmentType: AssignmentType): string {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue