#157 - prepared clikable days for calendar of holidays

This commit is contained in:
Kamil Niemczycki 2022-06-03 13:18:27 +02:00
parent 44531b0d08
commit c154c51ef4
3 changed files with 40 additions and 2 deletions

View File

@ -42,6 +42,7 @@ class CalendarGenerator
"isToday" => $day->isToday(), "isToday" => $day->isToday(),
"isWeekend" => $day->isWeekend(), "isWeekend" => $day->isWeekend(),
"isHoliday" => $holidays->contains($day), "isHoliday" => $holidays->contains($day),
"isFuture" => $day->isToday() || $day >= Carbon::now(),
"vacations" => $vacationsForDay->pluck("user_id"), "vacations" => $vacationsForDay->pluck("user_id"),
"vacationTypes" => $vacationsForDay->pluck("vacationRequest.type", "user_id"), "vacationTypes" => $vacationsForDay->pluck("vacationRequest.type", "user_id"),
]; ];

View File

@ -9,6 +9,7 @@ import CalendarCheckIcon from 'vue-material-design-icons/CalendarCheck.vue'
import MedicalBagIcon from 'vue-material-design-icons/MedicalBag.vue' import MedicalBagIcon from 'vue-material-design-icons/MedicalBag.vue'
import CalendarRemoveIcon from 'vue-material-design-icons/CalendarRemove.vue' import CalendarRemoveIcon from 'vue-material-design-icons/CalendarRemove.vue'
import HomeCityIcon from 'vue-material-design-icons/HomeCity.vue' import HomeCityIcon from 'vue-material-design-icons/HomeCity.vue'
import BookPlusIcon from 'vue-material-design-icons/BookPlus.vue'
const types = [ const types = [
{ {
@ -88,6 +89,13 @@ const types = [
color: 'text-lime-500', color: 'text-lime-500',
border: 'border-lime-500', border: 'border-lime-500',
}, },
{
text: 'Złóż wniosek',
value: 'create',
icon: BookPlusIcon,
color: 'text-blumilk-700',
border: 'border-lime-500',
},
] ]
export default function useVacationTypeInfo() { export default function useVacationTypeInfo() {

View File

@ -100,7 +100,9 @@
v-for="day in calendar" v-for="day in calendar"
:key="day.dayOfMonth" :key="day.dayOfMonth"
class="border border-gray-300" class="border border-gray-300"
:class="{ 'bg-blumilk-25': day.isToday, 'bg-red-100': day.isWeekend || day.isHoliday}" :class="{ 'bg-blumilk-25': day.isToday, 'bg-red-100': day.isWeekend || day.isHoliday }"
@mouseover="setActiveBtn(user.id.toString() + '' + day.date)"
@mouseleave="unsetActiveBtn"
> >
<div <div
v-if="day.vacations.includes(user.id)" v-if="day.vacations.includes(user.id)"
@ -108,6 +110,18 @@
> >
<VacationTypeCalendarIcon :type="day.vacationTypes[user.id]" /> <VacationTypeCalendarIcon :type="day.vacationTypes[user.id]" />
</div> </div>
<InertiaLink
v-else-if="isActiveBtn(user.id.toString() + '' + day.date) && !day.isWeekend && !day.isHoliday && day.isFuture"
href="/vacation/requests/create"
:data="{ 'start_date': day.date }"
>
<div class="flex justify-center items-center">
<VacationTypeCalendarIcon
type="create"
class="text-blumilk-700"
/>
</div>
</InertiaLink>
</td> </td>
</tr> </tr>
</tbody> </tbody>
@ -118,7 +132,7 @@
<script setup> <script setup>
import { ChevronLeftIcon, ChevronRightIcon } from '@heroicons/vue/solid' import { ChevronLeftIcon, ChevronRightIcon } from '@heroicons/vue/solid'
import { computed } from 'vue' import { computed, ref } from 'vue'
import { useMonthInfo } from '@/Composables/monthInfo' import { useMonthInfo } from '@/Composables/monthInfo'
import VacationTypeCalendarIcon from '@/Shared/VacationTypeCalendarIcon' import VacationTypeCalendarIcon from '@/Shared/VacationTypeCalendarIcon'
@ -132,6 +146,8 @@ const props = defineProps({
can: Object, can: Object,
}) })
let activeElement = ref(undefined)
const { getMonths, findMonth } = useMonthInfo() const { getMonths, findMonth } = useMonthInfo()
const months = getMonths() const months = getMonths()
@ -140,4 +156,17 @@ const currentMonth = computed(() => findMonth(props.current))
const selectedMonth = computed(() => findMonth(props.selected)) const selectedMonth = computed(() => findMonth(props.selected))
const previousMonth = computed(() => months[months.indexOf(selectedMonth.value) - 1]) const previousMonth = computed(() => months[months.indexOf(selectedMonth.value) - 1])
const nextMonth = computed(() => months[months.indexOf(selectedMonth.value) + 1]) const nextMonth = computed(() => months[months.indexOf(selectedMonth.value) + 1])
function isActiveBtn(key) {
return activeElement.value === key
}
function setActiveBtn(key) {
if(activeElement.value === undefined)
activeElement.value = key
}
function unsetActiveBtn() {
activeElement.value = undefined
}
</script> </script>