workaround: disable due date links for experts

This commit is contained in:
Livio Bieri 2023-09-20 16:39:12 +02:00
parent 5e8554acda
commit fa22f5a18e
2 changed files with 22 additions and 7 deletions

View File

@ -1,11 +1,26 @@
<script lang="ts" setup>
import { formatDate } from "@/components/dueDates/dueDatesUtils";
import type { DueDate } from "@/types";
import type { CourseSession, DueDate } from "@/types";
import { useCourseSessionsStore } from "@/stores/courseSessions";
const props = defineProps<{
dueDate: DueDate;
singleLine?: boolean;
}>();
/* FIXME @livioso 19.09.23: This is a temporary workaround to have a ship-able / deployable
version of the preview feature (VBV-516). The plan is to tackle the role-based
due dates calendar next (VBV-524) which will touch all usage of this component.
For now, just disable links for trainer / expert -> to reduce level of confusion ;)
*/
const courseSessionsStore = useCourseSessionsStore();
const courseSession = courseSessionsStore.allCourseSessions.find(
(cs: CourseSession) => cs.id === props.dueDate.course_session
);
const disableLink = courseSession
? !courseSessionsStore.hasCockpit(courseSession)
: false;
</script>
<template>
@ -13,11 +28,14 @@ const props = defineProps<{
class="flex justify-between py-4"
:class="{ 'flex-col': props.singleLine, 'items-center': !props.singleLine }"
>
<div class="space-y-1">
<div class="text-bold space-y-1">
<div>
<a class="text-bold underline" :href="props.dueDate.url">
<a v-if="disableLink" class="underline" :href="props.dueDate.url">
{{ props.dueDate.title }}
</a>
<template v-else>
{{ props.dueDate.title }}
</template>
</div>
<div class="text-small text-gray-900">
<div v-if="props.dueDate.date_type_translation_key">

View File

@ -14,11 +14,8 @@ const dueDates = courseSession.value.due_dates.slice(0, 2);
:key="dueDate.id"
class="border-t border-gray-500 pt-2"
>
<DueDateSingle :due-date="dueDate" :single-line="true"></DueDateSingle>
<DueDateSingle :due-date="dueDate" single-line></DueDateSingle>
</div>
<div v-if="dueDates.length === 0">{{ $t("dueDates.noDueDatesAvailable") }}</div>
<a class="border-t border-gray-500 pt-8 underline" href="">
{{ $t("dueDates.showAllDueDates") }}
</a>
</div>
</template>