chore: styling
This commit is contained in:
parent
4068a3d365
commit
fd885d7b5e
|
|
@ -10,6 +10,7 @@ interface Props {
|
||||||
name: string;
|
name: string;
|
||||||
};
|
};
|
||||||
items?: DropdownSelectable[];
|
items?: DropdownSelectable[];
|
||||||
|
borderless?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
|
|
@ -36,7 +37,11 @@ const dropdownSelected = computed<DropdownSelectable>({
|
||||||
<Listbox v-model="dropdownSelected" as="div">
|
<Listbox v-model="dropdownSelected" as="div">
|
||||||
<div class="relative mt-1 w-full">
|
<div class="relative mt-1 w-full">
|
||||||
<ListboxButton
|
<ListboxButton
|
||||||
class="relative flex w-full cursor-default flex-row items-center border bg-white py-3 pl-5 pr-10 text-left font-bold"
|
class="relative flex w-full cursor-default flex-row items-center bg-white py-3 pl-5 pr-10 text-left"
|
||||||
|
:class="{
|
||||||
|
border: !props.borderless,
|
||||||
|
'font-bold': !props.borderless,
|
||||||
|
}"
|
||||||
>
|
>
|
||||||
<span v-if="dropdownSelected.iconName" class="mr-4">
|
<span v-if="dropdownSelected.iconName" class="mr-4">
|
||||||
<component :is="dropdownSelected.iconName"></component>
|
<component :is="dropdownSelected.iconName"></component>
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,14 @@
|
||||||
import { computed, ref, watch } from "vue";
|
import { computed, ref, watch } from "vue";
|
||||||
import { useCourseSessionsStore } from "@/stores/courseSessions";
|
import { useCourseSessionsStore } from "@/stores/courseSessions";
|
||||||
import { useLearningPathStore } from "@/stores/learningPath";
|
import { useLearningPathStore } from "@/stores/learningPath";
|
||||||
|
import { useTranslation } from "i18next-vue";
|
||||||
import ItDropdownSelect from "@/components/ui/ItDropdownSelect.vue";
|
import ItDropdownSelect from "@/components/ui/ItDropdownSelect.vue";
|
||||||
import type { DueDate } from "@/types";
|
import type { DueDate } from "@/types";
|
||||||
|
import DueDateSingle from "@/components/dueDates/DueDateSingle.vue";
|
||||||
|
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const UNFILTERED = Number.MAX_SAFE_INTEGER;
|
const UNFILTERED = Number.MAX_SAFE_INTEGER;
|
||||||
|
|
||||||
const courseSessionsStore = useCourseSessionsStore();
|
const courseSessionsStore = useCourseSessionsStore();
|
||||||
const learningPathStore = useLearningPathStore();
|
const learningPathStore = useLearningPathStore();
|
||||||
|
|
||||||
|
|
@ -15,22 +18,33 @@ type Item = {
|
||||||
name: string;
|
name: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
const initialItem: Item = {
|
const initialItemCircle: Item = {
|
||||||
id: UNFILTERED,
|
id: UNFILTERED,
|
||||||
name: "Alle",
|
name: t("a.AlleCircle"),
|
||||||
};
|
};
|
||||||
|
|
||||||
const circles = ref<Item[]>([initialItem]);
|
const circles = ref<Item[]>([initialItemCircle]);
|
||||||
|
|
||||||
const courseSessions: Item[] = [
|
const courseSessions: Item[] = [
|
||||||
initialItem,
|
{
|
||||||
|
id: UNFILTERED,
|
||||||
|
name: t("a.AlleDurchführungen"),
|
||||||
|
},
|
||||||
...courseSessionsStore.allCourseSessions.map((cs) => ({ id: cs.id, name: cs.title })),
|
...courseSessionsStore.allCourseSessions.map((cs) => ({ id: cs.id, name: cs.title })),
|
||||||
];
|
];
|
||||||
|
|
||||||
const selectedSession = ref<Item>(courseSessions[0]);
|
const selectedSession = ref<Item>(courseSessions[0]);
|
||||||
const selectedCircle = ref<Item>(circles.value[0]);
|
const selectedCircle = ref<Item>(circles.value[0]);
|
||||||
|
|
||||||
|
if (courseSessionsStore.currentCourseSession) {
|
||||||
|
selectedSession.value = {
|
||||||
|
id: courseSessionsStore.currentCourseSession.id,
|
||||||
|
name: courseSessionsStore.currentCourseSession.title,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
watch(selectedSession, async () => {
|
watch(selectedSession, async () => {
|
||||||
|
// We don't have all circles for the unfiltered session,
|
||||||
|
// we fetch them from the learning path when the session changes
|
||||||
const isUnfiltered = selectedSession.value.id === UNFILTERED;
|
const isUnfiltered = selectedSession.value.id === UNFILTERED;
|
||||||
const courseSession = courseSessionsStore.allCourseSessions.find(
|
const courseSession = courseSessionsStore.allCourseSessions.find(
|
||||||
(item) => item.id === selectedSession.value.id
|
(item) => item.id === selectedSession.value.id
|
||||||
|
|
@ -48,21 +62,23 @@ watch(selectedSession, async () => {
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
|
||||||
updateCircles(data?.circles);
|
if (data) {
|
||||||
|
updateCircles(data.circles);
|
||||||
|
} else {
|
||||||
|
resetCircles();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const resetCircles = () => {
|
const resetCircles = () => {
|
||||||
circles.value = [initialItem];
|
circles.value = [initialItemCircle];
|
||||||
selectedCircle.value = circles.value[0];
|
selectedCircle.value = circles.value[0];
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateCircles = (newCircles?: { id: number; title: string }[]) => {
|
const updateCircles = (newCircles: { id: number; title: string }[]) => {
|
||||||
circles.value = newCircles
|
circles.value = [
|
||||||
? [
|
initialItemCircle,
|
||||||
initialItem,
|
...newCircles.map((circle) => ({ id: circle.id, name: circle.title })),
|
||||||
...newCircles.map((circle) => ({ id: circle.id, name: circle.title })),
|
];
|
||||||
]
|
|
||||||
: [initialItem];
|
|
||||||
selectedCircle.value = circles.value[0];
|
selectedCircle.value = circles.value[0];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -88,32 +104,43 @@ const isMatchingCircle = (dueDate: DueDate) =>
|
||||||
<h1>{{ $t("a.AlleTermine") }}</h1>
|
<h1>{{ $t("a.AlleTermine") }}</h1>
|
||||||
</header>
|
</header>
|
||||||
<main>
|
<main>
|
||||||
<div class="col flex">
|
<div class="flex flex-col space-y-2">
|
||||||
<span>{{ $t("a.Durchfuehrung") }}:</span>
|
<div class="flex flex-col space-x-3 bg-white lg:flex-row">
|
||||||
<ItDropdownSelect
|
|
||||||
v-model="selectedSession"
|
|
||||||
class="mt-4 w-full lg:mt-0 lg:w-96"
|
|
||||||
:items="courseSessions"
|
|
||||||
></ItDropdownSelect>
|
|
||||||
<template v-if="selectedSession.id !== UNFILTERED">
|
|
||||||
<span>{{ $t("a.Circle") }}:</span>
|
|
||||||
<ItDropdownSelect
|
<ItDropdownSelect
|
||||||
v-model="selectedCircle"
|
v-model="selectedSession"
|
||||||
class="mt-4 w-full lg:mt-0 lg:w-96"
|
:items="courseSessions"
|
||||||
:items="circles"
|
borderless
|
||||||
></ItDropdownSelect>
|
></ItDropdownSelect>
|
||||||
</template>
|
<template v-if="selectedSession.id !== UNFILTERED">
|
||||||
</div>
|
<ItDropdownSelect
|
||||||
<div class="bg-white px-4 py-4">
|
v-model="selectedCircle"
|
||||||
<ul>
|
:items="circles"
|
||||||
<li v-for="appointment in appointments" :key="appointment.id">
|
borderless
|
||||||
{{ appointment.title }} - {{ appointment.start }}
|
></ItDropdownSelect>
|
||||||
</li>
|
</template>
|
||||||
</ul>
|
</div>
|
||||||
|
<div class="bg-white px-5">
|
||||||
|
<ul class="no-border-last">
|
||||||
|
<li
|
||||||
|
v-for="appointment in appointments"
|
||||||
|
:key="appointment.id"
|
||||||
|
class="border-b"
|
||||||
|
>
|
||||||
|
<DueDateSingle :due-date="appointment"></DueDateSingle>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<div v-if="appointments.length === 0" class="w-full py-5">
|
||||||
|
{{ $t("dueDates.noDueDatesAvailable") }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped></style>
|
<style lang="postcss" scoped>
|
||||||
|
.no-border-last li:last-child {
|
||||||
|
border-bottom: none !important;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue