#74 - vacation calendar (#87)

* - polishing calendar

* wip

* wip

* #74 - wip

* #74 - wip

* #74 - wip

* #74 - fix icons

Co-authored-by: EwelinaLasowy <ewelina.lasowy@blumilk.pl>
This commit is contained in:
Adrian Hopek
2022-03-21 11:57:32 +01:00
committed by GitHub
parent 8c1819aa01
commit a0e60a3160
13 changed files with 326 additions and 82 deletions

View File

@@ -44,6 +44,7 @@ class CalendarGenerator
"isWeekend" => $day->isWeekend(),
"isHoliday" => $holidays->contains($day),
"vacations" => $vacationsForDay->pluck("user_id"),
"vacationTypes" => $vacationsForDay->pluck("vacationRequest.type", "user_id"),
];
}
@@ -55,6 +56,7 @@ class CalendarGenerator
return Vacation::query()
->whereBetween("date", [$period->start, $period->end])
->whereRelation("vacationRequest", fn(Builder $query) => $query->states(VacationRequestStatesRetriever::successStates()))
->with("vacationRequest")
->get()
->groupBy(fn(Vacation $vacation) => $vacation->date->toDateString());
}

View File

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

View File

@@ -16,7 +16,7 @@ class VacationRequestResource extends JsonResource
"id" => $this->id,
"name" => $this->name,
"user" => new UserResource($this->user),
"type" => $this->type->label(),
"type" => $this->type,
"state" => $this->state,
"from" => $this->from->toDisplayString(),
"to" => $this->to->toDisplayString(),