diff --git a/resources/js/Pages/Calendar.vue b/resources/js/Pages/Calendar.vue index 09f833ea..78138aa0 100644 --- a/resources/js/Pages/Calendar.vue +++ b/resources/js/Pages/Calendar.vue @@ -10,6 +10,8 @@ import { router } from '@inertiajs/vue3' import InertiaLink from '@/Shared/InertiaLink.vue' import { useGlobalProps } from '@/Composables/useGlobalProps' import AppLayout from '@/Shared/Layout/AppLayout.vue' +import { useStorage } from '@vueuse/core' +import Draggable from 'vuedraggable' const props = defineProps({ users: Object, @@ -20,7 +22,10 @@ const props = defineProps({ const { auth } = useGlobalProps() -let activeElement = ref(undefined) +const highlighted = useStorage(`calendar-highlight:${auth.value.user.id}`, []) +const order = useStorage(`calendar-order:${auth.value.user.id}`, props.users.data.map(user => user.id)) + +const usersInOrder = ref([...props.users.data].sort((a, b) => order.value.indexOf(a.id) > order.value.indexOf(b.id) ? 1 : -1)) const currentDate = DateTime.now() @@ -34,6 +39,10 @@ watch(selectedMonth, (value, oldValue) => { router.visit(`/calendar/${value.toFormat('LL-yyyy')}`) }) +watch(usersInOrder, (value) => { + order.value = value.map(item => item.id) +}) + function previousMonth() { selectedMonth.value = selectedMonth.value.minus({ month: 1 }) } @@ -46,19 +55,6 @@ function currentMonth() { selectedMonth.value = currentDate } -function isActiveDay(key) { - return activeElement.value === key -} - -function setActiveDay(key) { - if (activeElement.value === undefined) - activeElement.value = key -} - -function unsetActiveDay() { - activeElement.value = undefined -} - function linkParameters(user, day) { return auth.value.can.createRequestsOnBehalfOfEmployee ? { user: user.id, from_date: day.date } : { from_date: day.date } } @@ -66,6 +62,16 @@ function linkParameters(user, day) { function linkVacationRequest(user) { return auth.value.user.id === user.id || auth.value.can.manageRequestsAsTechnicalApprover || auth.value.can.manageRequestsAsAdministrativeApprover } + +function toggleHighlight(id) { + if (highlighted.value.includes(id)) { + highlighted.value = highlighted.value.filter(item => item !== id) + + return + } + + highlighted.value.push(id) +} @@ -145,7 +151,7 @@ function linkVacationRequest(user) { - {{ selectedMonth.toLocaleString({ month: 'long', year: 'numeric' }) }} + {{ selectedMonth.toLocaleString({month: 'long', year: 'numeric'}) }} - - - - + + + - - - - - - - {{ user.name }} + + + + + + + + {{ element.name }} + - - - - - + + - - - - - - - - - - - - + + + + + + + + + + + + + diff --git a/resources/js/Shared/UserProfileLink.vue b/resources/js/Shared/UserProfileLink.vue index 351161c6..3c605fd2 100644 --- a/resources/js/Shared/UserProfileLink.vue +++ b/resources/js/Shared/UserProfileLink.vue @@ -13,6 +13,7 @@ const { auth } = useGlobalProps()