This commit is contained in:
Adrian Hopek 2022-03-16 13:39:27 +01:00
parent 0076c04e88
commit e365de21cf
2 changed files with 18 additions and 5 deletions

View File

@ -22,15 +22,19 @@ class VacationCalendarController extends Controller
?string $month = null, ?string $month = null,
): Response { ): Response {
$month = Month::fromNameOrCurrent((string)$month); $month = Month::fromNameOrCurrent((string)$month);
$currentUser = $request->user();
$yearPeriod = $yearPeriodRetriever->selected(); $yearPeriod = $yearPeriodRetriever->selected();
$carbonMonth = Carbon::create($yearPeriod->year, $month->toCarbonNumber()); $carbonMonth = Carbon::create($yearPeriod->year, $month->toCarbonNumber());
$users = User::query() $users = User::query()
->where("id", "!=", $currentUser->id)
->orderBy("last_name") ->orderBy("last_name")
->orderBy("first_name") ->orderBy("first_name")
->get(); ->get();
$users->prepend($currentUser);
$calendar = $calendarGenerator->generate($carbonMonth); $calendar = $calendarGenerator->generate($carbonMonth);
return inertia("Calendar", [ return inertia("Calendar", [

View File

@ -17,7 +17,7 @@
</div> </div>
</div> </div>
<div class="overflow-x-auto"> <div class="overflow-x-auto">
<table class="w-full text-center table-fixed text-sm border border-gray-300"> <table class="w-full text-center text-sm border border-gray-300">
<thead> <thead>
<tr> <tr>
<th class="w-64 py-2 border border-gray-300"> <th class="w-64 py-2 border border-gray-300">
@ -71,7 +71,8 @@
v-for="day in calendar" v-for="day in calendar"
:key="day.dayOfMonth" :key="day.dayOfMonth"
class="border border-gray-300 text-lg font-semibold text-gray-900 py-4 px-2" class="border border-gray-300 text-lg font-semibold text-gray-900 py-4 px-2"
:class="{ 'text-blumilk-600 bg-blumilk-25 font-black': day.isToday }" style="min-width: 46px;"
:class="{ 'bg-red-100 text-red-800': day.isWeekend || day.isHoliday, 'text-blumilk-600 bg-blumilk-25': day.isToday }"
> >
<div> <div>
{{ day.dayOfMonth }} {{ day.dayOfMonth }}
@ -87,7 +88,9 @@
v-for="user in users.data" v-for="user in users.data"
:key="user.id" :key="user.id"
> >
<th class="border border-gray-300 py-2 px-4"> <th
class="border border-gray-300 py-2 px-4"
>
<div class="flex justify-start items-center"> <div class="flex justify-start items-center">
<span class="inline-flex items-center justify-center h-10 w-10 rounded-full"> <span class="inline-flex items-center justify-center h-10 w-10 rounded-full">
<img <img
@ -96,7 +99,9 @@
> >
</span> </span>
<div class="ml-3"> <div class="ml-3">
<div class="text-sm font-medium text-gray-900"> <div
class="text-sm font-medium text-gray-900 whitespace-nowrap"
>
{{ user.name }} {{ user.name }}
</div> </div>
</div> </div>
@ -106,7 +111,7 @@
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-red-100': day.isWeekend || day.isHoliday, 'bg-blumilk-500': day.vacations.includes(user.id) }" :class="{ 'bg-blumilk-25': day.isToday, 'bg-red-100': day.isWeekend || day.isHoliday, 'bg-blumilk-500': day.vacations.includes(user.id) }"
> >
<div <div
v-if="day.vacations.includes(user.id)" v-if="day.vacations.includes(user.id)"
@ -152,6 +157,10 @@ export default {
type: Object, type: Object,
default: () => null, default: () => null,
}, },
auth: {
type: Object,
default: () => null,
},
calendar: { calendar: {
type: Object, type: Object,
default: () => null, default: () => null,