feat: added preview bar

This commit is contained in:
Livio Bieri 2023-09-20 16:38:45 +02:00
parent 326e42c99f
commit 5e8554acda
4 changed files with 44 additions and 38 deletions

View File

@ -16,10 +16,9 @@ const { t } = useTranslation();
<div <div
class="relative flex h-16 w-full flex-col items-center justify-end space-x-8 lg:flex-row lg:items-stretch lg:justify-center" class="relative flex h-16 w-full flex-col items-center justify-end space-x-8 lg:flex-row lg:items-stretch lg:justify-center"
> >
<strong class="flex items-center px-1 pt-1 text-black"> <span class="flex items-center px-1 pt-1 font-bold text-black">
<!-- TODO: @livioso i18n --> {{ t("a.VorschauTeilnehmer") }} ({{ courseSession.title }})
Vorschau: Teilnehmer ({{ courseSession.title }}) </span>
</strong>
<div class="flex space-x-8"> <div class="flex space-x-8">
<router-link <router-link

View File

@ -42,21 +42,13 @@ const selectedCourseSessionTitle = computed(() => {
return courseSessionsStore.currentCourseSession?.title; return courseSessionsStore.currentCourseSession?.title;
}); });
const isTrainerInCourseSessionPreview = computed(() => {
// todo wip @livioso check if this is correct?
const isTrainer =
courseSessionsStore.currentCourseSession &&
courseSessionsStore.currentCourseSessionHasCockpit;
return isTrainer && !inCockpit();
});
onMounted(() => { onMounted(() => {
log.debug("MainNavigationBar mounted"); log.debug("MainNavigationBar mounted");
}); });
</script> </script>
<template> <template>
<CoursePreviewBar v-if="isTrainerInCourseSessionPreview" /> <CoursePreviewBar v-if="courseSessionsStore.hasCourseSessionPreview" />
<div v-else> <div v-else>
<Teleport to="body"> <Teleport to="body">
<MobileMenu <MobileMenu
@ -114,9 +106,8 @@ onMounted(() => {
<!-- Navigation Links Desktop --> <!-- Navigation Links Desktop -->
<router-link <router-link
v-if=" v-if="
inCourse() && courseSessionsStore.hasExpertNavigation &&
courseSessionsStore.currentCourseSession && courseSessionsStore.currentCourseSession
courseSessionsStore.currentCourseSessionHasCockpit
" "
:to="`${courseSessionsStore.currentCourseSession.course_url}/cockpit`" :to="`${courseSessionsStore.currentCourseSession.course_url}/cockpit`"
class="nav-item" class="nav-item"
@ -127,23 +118,23 @@ onMounted(() => {
<router-link <router-link
v-if=" v-if="
inCourse() && courseSessionsStore.hasExpertNavigation &&
courseSessionsStore.currentCourseSession && courseSessionsStore.currentCourseSession
inCockpit()
" "
:to="courseSessionsStore.currentCourseSession.learning_path_url" :to="courseSessionsStore.currentCourseSession.learning_path_url"
target="_blank" target="_blank"
class="nav-item" class="nav-item"
:class="{ 'nav-item--active': inLearningPath() }"
> >
{{ t("general.preview") }} <div class="flex items-center">
<span>{{ t("a.VorschauTeilnehmer") }}</span>
<it-icon-external-link class="ml-2" />
</div>
</router-link> </router-link>
<router-link <router-link
v-if=" v-if="
inCourse() && courseSessionsStore.hasMemberNavigation &&
courseSessionsStore.currentCourseSession && courseSessionsStore.currentCourseSession
!courseSessionsStore.currentCourseSessionHasCockpit
" "
:to="courseSessionsStore.currentCourseSession.learning_path_url" :to="courseSessionsStore.currentCourseSession.learning_path_url"
class="nav-item" class="nav-item"
@ -154,9 +145,8 @@ onMounted(() => {
<router-link <router-link
v-if=" v-if="
inCourse() && courseSessionsStore.hasMemberNavigation &&
courseSessionsStore.currentCourseSession && courseSessionsStore.currentCourseSession
!courseSessionsStore.currentCourseSessionHasCockpit
" "
:to="courseSessionsStore.currentCourseSession.competence_url" :to="courseSessionsStore.currentCourseSession.competence_url"
class="nav-item" class="nav-item"
@ -255,15 +245,4 @@ onMounted(() => {
.nav-item--active { .nav-item--active {
@apply border-sky-500; @apply border-sky-500;
} }
.nav-enter-active,
.nav-leave-active {
transition: opacity 0.3s ease, transform 0.3s ease;
}
.nav-enter-from,
.nav-leave-to {
opacity: 0;
transform: translateY(-80px);
}
</style> </style>

View File

@ -1,5 +1,9 @@
<script setup lang="ts"> <script setup lang="ts">
import * as log from "loglevel"; import * as log from "loglevel";
import CoursePreviewBar from "@/components/header/CoursePreviewBar.vue";
import { useCourseSessionsStore } from "@/stores/courseSessions";
const courseSessionsStore = useCourseSessionsStore();
log.debug("LearningContentContainer.vue setup"); log.debug("LearningContentContainer.vue setup");
@ -9,6 +13,7 @@ defineEmits(["exit"]);
<template> <template>
<div> <div>
<div class="absolute bottom-0 top-0 w-full bg-white"> <div class="absolute bottom-0 top-0 w-full bg-white">
<CoursePreviewBar v-if="courseSessionsStore.hasCourseSessionPreview" />
<div class="h-content overflow-y-auto"> <div class="h-content overflow-y-auto">
<header <header
class="relative flex h-12 w-full items-center justify-between bg-white px-4 lg:h-16 lg:px-8" class="relative flex h-12 w-full items-center justify-between bg-white px-4 lg:h-16 lg:px-8"

View File

@ -10,6 +10,7 @@ import type {
ExpertSessionUser, ExpertSessionUser,
} from "@/types"; } from "@/types";
import eventBus from "@/utils/eventBus"; import eventBus from "@/utils/eventBus";
import { useRouteLookups } from "@/utils/route";
import { useLocalStorage } from "@vueuse/core"; import { useLocalStorage } from "@vueuse/core";
import dayjs from "dayjs"; import dayjs from "dayjs";
import uniqBy from "lodash/uniqBy"; import uniqBy from "lodash/uniqBy";
@ -24,6 +25,7 @@ const SELECTED_COURSE_SESSIONS_KEY = "selectedCourseSessionMap";
export const useCourseSessionsStore = defineStore("courseSessions", () => { export const useCourseSessionsStore = defineStore("courseSessions", () => {
const loaded = ref(false); const loaded = ref(false);
const allCourseSessions = ref<CourseSession[]>([]); const allCourseSessions = ref<CourseSession[]>([]);
const { inCompetenceProfile, inLearningPath, inCourse } = useRouteLookups();
async function loadCourseSessionsData(reload = false) { async function loadCourseSessionsData(reload = false) {
log.debug("loadCourseSessionsData called"); log.debug("loadCourseSessionsData called");
@ -138,6 +140,24 @@ export const useCourseSessionsStore = defineStore("courseSessions", () => {
return false; return false;
}); });
const hasCourseSessionPreview = computed(() => {
const isCourseExpert =
currentCourseSession.value && currentCourseSessionHasCockpit.value;
return isCourseExpert && (inLearningPath() || inCompetenceProfile());
});
const hasMemberNavigation = computed(() => {
return (
inCourse() && currentCourseSession.value && !currentCourseSessionHasCockpit.value
);
});
const hasExpertNavigation = computed(() => {
return (
inCourse() && currentCourseSession.value && currentCourseSessionHasCockpit.value
);
});
const circleExperts = computed(() => { const circleExperts = computed(() => {
const circleStore = useCircleStore(); const circleStore = useCircleStore();
const circleTranslationKey = circleStore.circle?.translation_key; const circleTranslationKey = circleStore.circle?.translation_key;
@ -266,6 +286,9 @@ export const useCourseSessionsStore = defineStore("courseSessions", () => {
courseSessionForCourse, courseSessionForCourse,
switchCourseSession, switchCourseSession,
hasCockpit, hasCockpit,
hasCourseSessionPreview,
hasMemberNavigation,
hasExpertNavigation,
currentCourseSessionHasCockpit, currentCourseSessionHasCockpit,
canUploadCircleDocuments, canUploadCircleDocuments,
circleDocuments, circleDocuments,