Url handling
This commit is contained in:
parent
5aa73e4997
commit
0adf734846
|
|
@ -39,6 +39,11 @@ function inCourse() {
|
||||||
return route.path.startsWith("/course/");
|
return route.path.startsWith("/course/");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function inCockpit() {
|
||||||
|
const regex = new RegExp("/course/[^/]+/cockpit");
|
||||||
|
return regex.test(route.path);
|
||||||
|
}
|
||||||
|
|
||||||
function inLearningPath() {
|
function inLearningPath() {
|
||||||
const regex = new RegExp("/course/[^/]+/learn");
|
const regex = new RegExp("/course/[^/]+/learn");
|
||||||
return regex.test(route.path);
|
return regex.test(route.path);
|
||||||
|
|
@ -154,6 +159,15 @@ const profileDropdownData: DropdownListItem[] = [
|
||||||
:class="state.showMenu ? 'flex' : 'hidden'"
|
:class="state.showMenu ? 'flex' : 'hidden'"
|
||||||
class="flex-auto mt-8 lg:flex lg:space-y-0 lg:flex-row lg:items-center lg:space-x-10 lg:mt-0"
|
class="flex-auto mt-8 lg:flex lg:space-y-0 lg:flex-row lg:items-center lg:space-x-10 lg:mt-0"
|
||||||
>
|
>
|
||||||
|
<!-- <router-link-->
|
||||||
|
<!-- v-if="inCourse() && courseSessionsStore.courseSessionForRoute"-->
|
||||||
|
<!-- :to="`${courseSessionsStore.courseSessionForRoute.course_url}/cockpit`"-->
|
||||||
|
<!-- class="nav-item"-->
|
||||||
|
<!-- :class="{ 'nav-item--active': inCockpit() }"-->
|
||||||
|
<!-- >-->
|
||||||
|
<!-- Cockpit-->
|
||||||
|
<!-- </router-link>-->
|
||||||
|
|
||||||
<router-link
|
<router-link
|
||||||
v-if="inCourse() && courseSessionsStore.courseSessionForRoute"
|
v-if="inCourse() && courseSessionsStore.courseSessionForRoute"
|
||||||
:to="courseSessionsStore.courseSessionForRoute.learning_path_url"
|
:to="courseSessionsStore.courseSessionForRoute.learning_path_url"
|
||||||
|
|
|
||||||
|
|
@ -22,10 +22,7 @@ export const useCourseSessionsStore = defineStore({
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const routePath = decodeURI(route.path);
|
const routePath = decodeURI(route.path);
|
||||||
return state.courseSessions?.find((cs) => {
|
return state.courseSessions?.find((cs) => {
|
||||||
return (
|
return routePath.startsWith(cs.course_url);
|
||||||
routePath.startsWith(cs.learning_path_url) ||
|
|
||||||
routePath.startsWith(cs.competence_url)
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
coursesFromCourseSessions: (state) => {
|
coursesFromCourseSessions: (state) => {
|
||||||
|
|
|
||||||
|
|
@ -322,6 +322,7 @@ export interface CourseSession {
|
||||||
end_date: string;
|
end_date: string;
|
||||||
learning_path_url: string;
|
learning_path_url: string;
|
||||||
competence_url: string;
|
competence_url: string;
|
||||||
|
course_url: string;
|
||||||
media_library_url: string;
|
media_library_url: string;
|
||||||
additional_json_data: unknown;
|
additional_json_data: unknown;
|
||||||
experts: CircleExpert[];
|
experts: CircleExpert[];
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,9 @@ class Course(models.Model):
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = _("Lehrgang")
|
verbose_name = _("Lehrgang")
|
||||||
|
|
||||||
|
def get_course_url(self):
|
||||||
|
return f'/course/{self.slug}'
|
||||||
|
|
||||||
def get_learning_path_url(self):
|
def get_learning_path_url(self):
|
||||||
from vbv_lernwelt.learnpath.models import LearningPath
|
from vbv_lernwelt.learnpath.models import LearningPath
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -44,15 +44,19 @@ class CourseCompletionSerializer(serializers.ModelSerializer):
|
||||||
|
|
||||||
|
|
||||||
class CourseSessionSerializer(serializers.ModelSerializer):
|
class CourseSessionSerializer(serializers.ModelSerializer):
|
||||||
|
course = serializers.SerializerMethodField()
|
||||||
|
course_url = serializers.SerializerMethodField()
|
||||||
learning_path_url = serializers.SerializerMethodField()
|
learning_path_url = serializers.SerializerMethodField()
|
||||||
competence_url = serializers.SerializerMethodField()
|
competence_url = serializers.SerializerMethodField()
|
||||||
media_library_url = serializers.SerializerMethodField()
|
media_library_url = serializers.SerializerMethodField()
|
||||||
course = serializers.SerializerMethodField()
|
|
||||||
experts = serializers.SerializerMethodField()
|
experts = serializers.SerializerMethodField()
|
||||||
|
|
||||||
def get_course(self, obj):
|
def get_course(self, obj):
|
||||||
return CourseSerializer(obj.course).data
|
return CourseSerializer(obj.course).data
|
||||||
|
|
||||||
|
def get_course_url(self, obj):
|
||||||
|
return obj.course.get_course_url()
|
||||||
|
|
||||||
def get_learning_path_url(self, obj):
|
def get_learning_path_url(self, obj):
|
||||||
return obj.course.get_learning_path_url()
|
return obj.course.get_learning_path_url()
|
||||||
|
|
||||||
|
|
@ -96,5 +100,6 @@ class CourseSessionSerializer(serializers.ModelSerializer):
|
||||||
"learning_path_url",
|
"learning_path_url",
|
||||||
"competence_url",
|
"competence_url",
|
||||||
"media_library_url",
|
"media_library_url",
|
||||||
|
"course_url",
|
||||||
"experts",
|
"experts",
|
||||||
]
|
]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue