* #108 - wip * #108 - add icon to absence * #108 - wip * #108 - fix * #108 - fix title Co-authored-by: EwelinaLasowy <ewelina.lasowy@blumilk.pl>
This commit is contained in:
parent
fa244b96cd
commit
6af4380fe6
@ -4,6 +4,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace Toby\Domain\Enums;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
enum VacationType: string
|
||||
{
|
||||
case Vacation = "vacation";
|
||||
@ -15,6 +17,7 @@ enum VacationType: string
|
||||
case Volunteering = "volunteering_vacation";
|
||||
case TimeInLieu = "time_in_lieu";
|
||||
case Sick = "sick_vacation";
|
||||
case Absence = "absence";
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
@ -23,7 +26,7 @@ enum VacationType: string
|
||||
|
||||
public static function casesToSelect(): array
|
||||
{
|
||||
$cases = collect(VacationType::cases());
|
||||
$cases = VacationType::all();
|
||||
|
||||
return $cases->map(
|
||||
fn(VacationType $enum) => [
|
||||
@ -32,4 +35,9 @@ enum VacationType: string
|
||||
],
|
||||
)->toArray();
|
||||
}
|
||||
|
||||
public static function all(): Collection
|
||||
{
|
||||
return new Collection(VacationType::cases());
|
||||
}
|
||||
}
|
||||
|
@ -4,20 +4,21 @@ declare(strict_types=1);
|
||||
|
||||
namespace Toby\Domain;
|
||||
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Collection;
|
||||
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
|
||||
use Toby\Eloquent\Models\User;
|
||||
|
||||
class TimesheetExport implements WithMultipleSheets
|
||||
{
|
||||
protected Collection $users;
|
||||
protected Collection $types;
|
||||
protected Carbon $month;
|
||||
|
||||
public function sheets(): array
|
||||
{
|
||||
return $this->users
|
||||
->map(fn(User $user) => new TimesheetPerUserSheet($user, $this->month))
|
||||
->map(fn(User $user) => new TimesheetPerUserSheet($user, $this->month, $this->types))
|
||||
->toArray();
|
||||
}
|
||||
|
||||
@ -34,4 +35,11 @@ class TimesheetExport implements WithMultipleSheets
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function forVacationTypes(Collection $types): static
|
||||
{
|
||||
$this->types = $types;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ namespace Toby\Domain;
|
||||
use Carbon\CarbonInterface;
|
||||
use Carbon\CarbonPeriod;
|
||||
use Generator;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Collection;
|
||||
use Maatwebsite\Excel\Concerns\FromGenerator;
|
||||
@ -40,6 +41,7 @@ class TimesheetPerUserSheet implements WithTitle, WithHeadings, WithEvents, With
|
||||
public function __construct(
|
||||
protected User $user,
|
||||
protected Carbon $month,
|
||||
protected Collection $types,
|
||||
) {}
|
||||
|
||||
public function title(): string
|
||||
@ -49,8 +51,6 @@ class TimesheetPerUserSheet implements WithTitle, WithHeadings, WithEvents, With
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
$types = VacationType::cases();
|
||||
|
||||
$headings = [
|
||||
__("Date"),
|
||||
__("Day of week"),
|
||||
@ -59,7 +59,7 @@ class TimesheetPerUserSheet implements WithTitle, WithHeadings, WithEvents, With
|
||||
__("Worked hours"),
|
||||
];
|
||||
|
||||
foreach ($types as $type) {
|
||||
foreach ($this->types as $type) {
|
||||
$headings[] = $type->label();
|
||||
}
|
||||
|
||||
@ -187,6 +187,7 @@ class TimesheetPerUserSheet implements WithTitle, WithHeadings, WithEvents, With
|
||||
{
|
||||
return $user->vacations()
|
||||
->with("vacationRequest")
|
||||
->whereRelation("vacationRequest", fn(Builder $query) => $query->whereIn("type", $this->types))
|
||||
->whereBetween("date", [$period->start, $period->end])
|
||||
->approved()
|
||||
->get()
|
||||
|
@ -95,14 +95,14 @@ class UserVacationStatsRetriever
|
||||
|
||||
protected function getLimitableVacationTypes(): Collection
|
||||
{
|
||||
$types = new Collection(VacationType::cases());
|
||||
$types = VacationType::all();
|
||||
|
||||
return $types->filter(fn(VacationType $type) => $this->configRetriever->hasLimit($type));
|
||||
}
|
||||
|
||||
protected function getNotLimitableVacationTypes(): Collection
|
||||
{
|
||||
$types = new Collection(VacationType::cases());
|
||||
$types = VacationType::all();
|
||||
|
||||
return $types->filter(fn(VacationType $type) => !$this->configRetriever->hasLimit($type));
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace Toby\Domain;
|
||||
|
||||
use Illuminate\Contracts\Config\Repository;
|
||||
use Toby\Domain\Enums\EmploymentForm;
|
||||
use Toby\Domain\Enums\VacationType;
|
||||
|
||||
class VacationTypeConfigRetriever
|
||||
@ -13,6 +14,7 @@ class VacationTypeConfigRetriever
|
||||
public const KEY_ADMINISTRATIVE_APPROVAL = "administrative_approval";
|
||||
public const KEY_BILLABLE = "billable";
|
||||
public const KEY_HAS_LIMIT = "has_limit";
|
||||
public const KEY_AVAILABLE_FOR = "available_for";
|
||||
|
||||
public function __construct(
|
||||
protected Repository $config,
|
||||
@ -38,6 +40,11 @@ class VacationTypeConfigRetriever
|
||||
return $this->getConfigFor($type)[static::KEY_HAS_LIMIT];
|
||||
}
|
||||
|
||||
public function isAvailableFor(VacationType $type, EmploymentForm $employmentForm): bool
|
||||
{
|
||||
return in_array($employmentForm, $this->getConfigFor($type)[static::KEY_AVAILABLE_FOR], true);
|
||||
}
|
||||
|
||||
protected function getConfigFor(VacationType $type): array
|
||||
{
|
||||
return $this->config->get("vacation_types.{$type->value}");
|
||||
|
@ -5,7 +5,7 @@ declare(strict_types=1);
|
||||
namespace Toby\Domain\Validation\Rules;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Support\Collection;
|
||||
use Toby\Domain\Enums\VacationType;
|
||||
use Toby\Domain\VacationDaysCalculator;
|
||||
use Toby\Domain\VacationRequestStatesRetriever;
|
||||
@ -59,7 +59,7 @@ class DoesNotExceedLimitRule implements VacationRequestRule
|
||||
|
||||
protected function getLimitableVacationTypes(): Collection
|
||||
{
|
||||
$types = new Collection(VacationType::cases());
|
||||
$types = VacationType::all();
|
||||
|
||||
return $types->filter(fn(VacationType $type) => $this->configRetriever->hasLimit($type));
|
||||
}
|
||||
|
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Toby\Infrastructure\Http\Controllers\Api;
|
||||
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Toby\Domain\Enums\VacationType;
|
||||
use Toby\Domain\VacationTypeConfigRetriever;
|
||||
use Toby\Eloquent\Models\User;
|
||||
use Toby\Infrastructure\Http\Controllers\Controller;
|
||||
use Toby\Infrastructure\Http\Requests\Api\GetAvailableVacationTypesRequest;
|
||||
|
||||
class GetAvailableVacationTypesController extends Controller
|
||||
{
|
||||
public function __invoke(
|
||||
GetAvailableVacationTypesRequest $request,
|
||||
VacationTypeConfigRetriever $configRetriever,
|
||||
): JsonResponse {
|
||||
/** @var User $user */
|
||||
$user = User::query()->find($request->get("user"));
|
||||
|
||||
$types = VacationType::all()
|
||||
->filter(fn(VacationType $type) => $configRetriever->isAvailableFor($type, $user->employment_form))
|
||||
->map(fn(VacationType $type) => [
|
||||
"label" => $type->label(),
|
||||
"value" => $type->value,
|
||||
])
|
||||
->values();
|
||||
|
||||
return new JsonResponse($types);
|
||||
}
|
||||
}
|
@ -7,30 +7,43 @@ namespace Toby\Infrastructure\Http\Controllers;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
use Toby\Domain\Enums\EmploymentForm;
|
||||
use Toby\Domain\Enums\Month;
|
||||
use Toby\Domain\Enums\VacationType;
|
||||
use Toby\Domain\TimesheetExport;
|
||||
use Toby\Domain\VacationTypeConfigRetriever;
|
||||
use Toby\Eloquent\Helpers\YearPeriodRetriever;
|
||||
use Toby\Eloquent\Models\User;
|
||||
|
||||
class TimesheetController extends Controller
|
||||
{
|
||||
public function __invoke(Month $month, YearPeriodRetriever $yearPeriodRetriever): BinaryFileResponse
|
||||
{
|
||||
public function __invoke(
|
||||
Month $month,
|
||||
YearPeriodRetriever $yearPeriodRetriever,
|
||||
VacationTypeConfigRetriever $configRetriever,
|
||||
): BinaryFileResponse {
|
||||
$this->authorize("generateTimesheet");
|
||||
|
||||
$yearPeriod = $yearPeriodRetriever->selected();
|
||||
$carbonMonth = Carbon::create($yearPeriod->year, $month->toCarbonNumber());
|
||||
|
||||
$users = User::query()
|
||||
->where("employment_form", EmploymentForm::EmploymentContract)
|
||||
->orderBy("last_name")
|
||||
->orderBy("first_name")
|
||||
->get();
|
||||
|
||||
$types = VacationType::all()
|
||||
->filter(
|
||||
fn(VacationType $type) => $configRetriever->isAvailableFor($type, EmploymentForm::EmploymentContract),
|
||||
);
|
||||
|
||||
$filename = "{$carbonMonth->translatedFormat("F Y")}.xlsx";
|
||||
|
||||
$timesheet = (new TimesheetExport())
|
||||
->forMonth($carbonMonth)
|
||||
->forUsers($users);
|
||||
->forUsers($users)
|
||||
->forVacationTypes($types);
|
||||
|
||||
return Excel::download($timesheet, $filename);
|
||||
}
|
||||
|
@ -158,10 +158,7 @@ class VacationRequestController extends Controller
|
||||
|
||||
public function create(Request $request, YearPeriodRetriever $yearPeriodRetriever): Response
|
||||
{
|
||||
$yearPeriod = $yearPeriodRetriever->selected();
|
||||
|
||||
$users = User::query()
|
||||
->withVacationLimitIn($yearPeriod)
|
||||
->orderBy("last_name")
|
||||
->orderBy("first_name")
|
||||
->get();
|
||||
|
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Toby\Infrastructure\Http\Requests\Api;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class GetAvailableVacationTypesRequest extends FormRequest
|
||||
{
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
"user" => ["required", "exists:users,id"],
|
||||
];
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Toby\Domain\Enums\EmploymentForm;
|
||||
use Toby\Domain\Enums\VacationType;
|
||||
use Toby\Domain\VacationTypeConfigRetriever;
|
||||
|
||||
@ -11,53 +12,100 @@ return [
|
||||
VacationTypeConfigRetriever::KEY_ADMINISTRATIVE_APPROVAL => true,
|
||||
VacationTypeConfigRetriever::KEY_BILLABLE => true,
|
||||
VacationTypeConfigRetriever::KEY_HAS_LIMIT => true,
|
||||
VacationTypeConfigRetriever::KEY_AVAILABLE_FOR => [
|
||||
EmploymentForm::EmploymentContract,
|
||||
],
|
||||
],
|
||||
VacationType::OnRequest->value => [
|
||||
VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => true,
|
||||
VacationTypeConfigRetriever::KEY_ADMINISTRATIVE_APPROVAL => true,
|
||||
VacationTypeConfigRetriever::KEY_BILLABLE => true,
|
||||
VacationTypeConfigRetriever::KEY_HAS_LIMIT => true,
|
||||
VacationTypeConfigRetriever::KEY_AVAILABLE_FOR => [
|
||||
EmploymentForm::EmploymentContract,
|
||||
],
|
||||
],
|
||||
VacationType::TimeInLieu->value => [
|
||||
VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => false,
|
||||
VacationTypeConfigRetriever::KEY_ADMINISTRATIVE_APPROVAL => false,
|
||||
VacationTypeConfigRetriever::KEY_BILLABLE => true,
|
||||
VacationTypeConfigRetriever::KEY_HAS_LIMIT => false,
|
||||
VacationTypeConfigRetriever::KEY_AVAILABLE_FOR => [
|
||||
EmploymentForm::EmploymentContract,
|
||||
],
|
||||
],
|
||||
VacationType::Sick->value => [
|
||||
VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => false,
|
||||
VacationTypeConfigRetriever::KEY_ADMINISTRATIVE_APPROVAL => true,
|
||||
VacationTypeConfigRetriever::KEY_BILLABLE => true,
|
||||
VacationTypeConfigRetriever::KEY_HAS_LIMIT => false,
|
||||
VacationTypeConfigRetriever::KEY_AVAILABLE_FOR => [
|
||||
EmploymentForm::EmploymentContract,
|
||||
],
|
||||
],
|
||||
VacationType::Unpaid->value => [
|
||||
VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => true,
|
||||
VacationTypeConfigRetriever::KEY_ADMINISTRATIVE_APPROVAL => true,
|
||||
VacationTypeConfigRetriever::KEY_BILLABLE => false,
|
||||
VacationTypeConfigRetriever::KEY_HAS_LIMIT => false,
|
||||
VacationTypeConfigRetriever::KEY_AVAILABLE_FOR => [
|
||||
EmploymentForm::EmploymentContract,
|
||||
],
|
||||
],
|
||||
VacationType::Special->value => [
|
||||
VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => true,
|
||||
VacationTypeConfigRetriever::KEY_ADMINISTRATIVE_APPROVAL => true,
|
||||
VacationTypeConfigRetriever::KEY_BILLABLE => false,
|
||||
VacationTypeConfigRetriever::KEY_HAS_LIMIT => false,
|
||||
VacationTypeConfigRetriever::KEY_AVAILABLE_FOR => [
|
||||
EmploymentForm::EmploymentContract,
|
||||
],
|
||||
],
|
||||
VacationType::Childcare->value => [
|
||||
VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => true,
|
||||
VacationTypeConfigRetriever::KEY_ADMINISTRATIVE_APPROVAL => true,
|
||||
VacationTypeConfigRetriever::KEY_BILLABLE => false,
|
||||
VacationTypeConfigRetriever::KEY_HAS_LIMIT => false,
|
||||
VacationTypeConfigRetriever::KEY_AVAILABLE_FOR => [
|
||||
EmploymentForm::EmploymentContract,
|
||||
],
|
||||
],
|
||||
VacationType::Training->value => [
|
||||
VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => true,
|
||||
VacationTypeConfigRetriever::KEY_ADMINISTRATIVE_APPROVAL => true,
|
||||
VacationTypeConfigRetriever::KEY_BILLABLE => true,
|
||||
VacationTypeConfigRetriever::KEY_HAS_LIMIT => false,
|
||||
VacationTypeConfigRetriever::KEY_AVAILABLE_FOR => [
|
||||
EmploymentForm::EmploymentContract,
|
||||
],
|
||||
],
|
||||
VacationType::Volunteering->value => [
|
||||
VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => true,
|
||||
VacationTypeConfigRetriever::KEY_ADMINISTRATIVE_APPROVAL => true,
|
||||
VacationTypeConfigRetriever::KEY_BILLABLE => true,
|
||||
VacationTypeConfigRetriever::KEY_HAS_LIMIT => false,
|
||||
VacationTypeConfigRetriever::KEY_AVAILABLE_FOR => [
|
||||
EmploymentForm::EmploymentContract,
|
||||
],
|
||||
],
|
||||
VacationType::Volunteering->value => [
|
||||
VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => true,
|
||||
VacationTypeConfigRetriever::KEY_ADMINISTRATIVE_APPROVAL => true,
|
||||
VacationTypeConfigRetriever::KEY_BILLABLE => true,
|
||||
VacationTypeConfigRetriever::KEY_HAS_LIMIT => false,
|
||||
VacationTypeConfigRetriever::KEY_AVAILABLE_FOR => [
|
||||
EmploymentForm::EmploymentContract,
|
||||
],
|
||||
],
|
||||
VacationType::Absence->value => [
|
||||
VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => true,
|
||||
VacationTypeConfigRetriever::KEY_ADMINISTRATIVE_APPROVAL => false,
|
||||
VacationTypeConfigRetriever::KEY_BILLABLE => false,
|
||||
VacationTypeConfigRetriever::KEY_HAS_LIMIT => false,
|
||||
VacationTypeConfigRetriever::KEY_AVAILABLE_FOR => [
|
||||
EmploymentForm::CommissionContract,
|
||||
EmploymentForm::B2bContract,
|
||||
EmploymentForm::BoardMemberContract,
|
||||
],
|
||||
],
|
||||
];
|
||||
|
@ -7,6 +7,7 @@ import CurrencyUsdOffIcon from 'vue-material-design-icons/CurrencyUsdOff.vue'
|
||||
import HandHeartOutlineIcon from 'vue-material-design-icons/HandHeartOutline.vue'
|
||||
import CalendarCheckIcon from 'vue-material-design-icons/CalendarCheck.vue'
|
||||
import MedicalBagIcon from 'vue-material-design-icons/MedicalBag.vue'
|
||||
import CalendarRemoveIcon from 'vue-material-design-icons/CalendarRemove.vue'
|
||||
|
||||
const types = [
|
||||
{
|
||||
@ -63,6 +64,12 @@ const types = [
|
||||
icon: MedicalBagIcon,
|
||||
color: 'text-rose-500',
|
||||
},
|
||||
{
|
||||
text: 'Nieobecność',
|
||||
value: 'absence',
|
||||
icon: CalendarRemoveIcon,
|
||||
color: 'text-cyan-500',
|
||||
},
|
||||
]
|
||||
|
||||
export default function useVacationTypeInfo() {
|
||||
|
@ -4,7 +4,7 @@
|
||||
<div class="flex justify-between items-center p-4 sm:px-6">
|
||||
<div class="flex items-center">
|
||||
<h2 class="text-lg font-medium leading-6 text-gray-900">
|
||||
Wykorzystanie miesięczne urlopu wypoczynkowego
|
||||
Wykorzystanie miesięczne urlopu
|
||||
</h2>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -30,7 +30,7 @@
|
||||
scope="col"
|
||||
class="py-3 px-4 text-xs font-semibold tracking-wider text-left text-gray-500 uppercase whitespace-nowrap"
|
||||
>
|
||||
Posiada urlop?
|
||||
Posiada limit?
|
||||
</th>
|
||||
<th
|
||||
scope="col"
|
||||
|
@ -1,10 +1,10 @@
|
||||
<template>
|
||||
<InertiaHead title="Złóż wniosek urlopowy" />
|
||||
<InertiaHead title="Złóż wniosek" />
|
||||
<div class="grid grid-cols-1 gap-4 items-start xl:grid-cols-3 xl:gap-8">
|
||||
<div class="flex flex-col h-full bg-white shadow-md xl:col-span-2">
|
||||
<div class="p-4 sm:px-6">
|
||||
<h2 class="text-lg font-medium leading-6 text-gray-900">
|
||||
Złóż wniosek urlopowy
|
||||
Złóż wniosek
|
||||
</h2>
|
||||
</div>
|
||||
<form
|
||||
@ -42,8 +42,8 @@
|
||||
</ListboxLabel>
|
||||
<div class="relative mt-1 sm:col-span-2 sm:mt-0">
|
||||
<ListboxButton
|
||||
class="relative py-2 pr-10 pl-3 w-full max-w-lg text-left bg-white rounded-md border focus:ring-1 shadow-sm cursor-default sm:text-sm"
|
||||
:class="{ 'border-red-300 text-red-900 focus:outline-none focus:ring-red-500 focus:border-red-500': form.errors.user, 'focus:ring-blumilk-500 focus:border-blumilk-500 sm:text-sm border-gray-300': !form.errors.user }"
|
||||
class="relative py-2 pr-10 pl-3 w-full max-w-lg text-left bg-white rounded-md border focus:outline-none focus:ring-1 shadow-sm cursor-default sm:text-sm"
|
||||
:class="{ 'border-red-300 text-red-900 focus:ring-red-500 focus:border-red-500': form.errors.user, 'focus:ring-blumilk-500 focus:border-blumilk-500 sm:text-sm border-gray-300': !form.errors.user }"
|
||||
>
|
||||
<span class="flex items-center">
|
||||
<img
|
||||
@ -63,7 +63,7 @@
|
||||
leave-to-class="opacity-0"
|
||||
>
|
||||
<ListboxOptions
|
||||
class="overflow-auto absolute z-10 py-1 mt-1 w-full max-w-lg max-h-60 text-base bg-white rounded-md focus:outline-none ring-1 ring-black ring-opacity-5 shadow-lg sm:text-sm"
|
||||
class="overflow-auto absolute z-10 py-1 mt-1 w-full max-w-lg max-h-60 text-base bg-white rounded-md focus:outline-none ring-1 focus:ring-blumilk-500 ring-opacity-5 shadow-lg sm:text-sm"
|
||||
>
|
||||
<ListboxOption
|
||||
v-for="user in users.data"
|
||||
@ -134,24 +134,29 @@
|
||||
class="items-center py-4 sm:grid sm:grid-cols-3"
|
||||
>
|
||||
<ListboxLabel class="block text-sm font-medium text-gray-700">
|
||||
Rodzaj urlopu
|
||||
Typ wniosku
|
||||
</ListboxLabel>
|
||||
<div class="relative mt-1 sm:col-span-2 sm:mt-0">
|
||||
<ListboxButton
|
||||
class="relative py-2 pr-10 pl-3 w-full max-w-lg text-left bg-white rounded-md border focus:ring-1 shadow-sm cursor-default sm:text-sm"
|
||||
:class="{ 'border-red-300 text-red-900 focus:outline-none focus:ring-red-500 focus:border-red-500': form.errors.type, 'focus:ring-blumilk-500 focus:border-blumilk-500 sm:text-sm border-gray-300': !form.errors.type }"
|
||||
class="relative py-2 pr-10 pl-3 w-full max-w-lg text-left bg-white rounded-md border focus:outline-none focus:ring-1 shadow-sm cursor-default sm:text-sm"
|
||||
:class="{ 'border-red-300 text-red-900 focus:ring-red-500 focus:border-red-500': form.errors.type, 'focus:ring-blumilk-500 focus:border-blumilk-500 sm:text-sm border-gray-300': !form.errors.type }"
|
||||
>
|
||||
<span class="block truncate">{{ form.vacationType.label }}</span>
|
||||
<span class="flex absolute inset-y-0 right-0 items-center pr-2 pointer-events-none">
|
||||
<SelectorIcon class="w-5 h-5 text-gray-400" />
|
||||
</span>
|
||||
<template v-if="form.vacationType">
|
||||
<span class="block truncate">{{ form.vacationType.label }}</span>
|
||||
<span class="flex absolute inset-y-0 right-0 items-center pr-2 pointer-events-none">
|
||||
<SelectorIcon class="w-5 h-5 text-gray-400" />
|
||||
</span>
|
||||
</template>
|
||||
<template v-else>
|
||||
Ładowanie...
|
||||
</template>
|
||||
</ListboxButton>
|
||||
<transition
|
||||
leave-active-class="transition ease-in duration-100"
|
||||
leave-from-class="opacity-100"
|
||||
leave-to-class="opacity-0"
|
||||
>
|
||||
<ListboxOptions class="overflow-auto absolute z-10 py-1 mt-1 w-full max-w-lg max-h-60 text-base bg-white rounded-md focus:outline-none ring-1 ring-black ring-opacity-5 shadow-lg sm:text-sm">
|
||||
<ListboxOptions class="overflow-auto absolute z-10 py-1 mt-1 w-full max-w-lg max-h-60 text-base bg-white rounded-md focus:outline-none ring-1 focus:ring-blumilk-500 ring-opacity-5 shadow-lg sm:text-sm">
|
||||
<ListboxOption
|
||||
v-for="vacationType in vacationTypes"
|
||||
:key="vacationType.value"
|
||||
@ -187,7 +192,7 @@
|
||||
for="date_from"
|
||||
class="block text-sm font-medium text-gray-700 sm:mt-px"
|
||||
>
|
||||
Planowany urlop od
|
||||
Data od
|
||||
</label>
|
||||
<div class="mt-1 sm:col-span-2 sm:mt-0">
|
||||
<FlatPickr
|
||||
@ -212,7 +217,7 @@
|
||||
for="date_from"
|
||||
class="block text-sm font-medium text-gray-700 sm:mt-px"
|
||||
>
|
||||
Planowany urlop do
|
||||
Data do
|
||||
</label>
|
||||
<div class="mt-1 sm:col-span-2 sm:mt-0">
|
||||
<FlatPickr
|
||||
@ -233,7 +238,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="items-center py-4 sm:grid sm:grid-cols-3">
|
||||
<span class="block text-sm font-medium text-gray-700 sm:mt-px">Liczba dni urlopu</span>
|
||||
<span class="block text-sm font-medium text-gray-700 sm:mt-px">Liczba dni</span>
|
||||
<div
|
||||
class="inline-flex items-center py-2 px-4 mt-1 w-full max-w-lg text-gray-500 bg-gray-50 rounded-md border border-gray-300 sm:col-span-2 sm:mt-0 sm:text-sm"
|
||||
>
|
||||
@ -303,10 +308,10 @@
|
||||
<div class="p-4 sm:px-6">
|
||||
<h2 class="text-lg font-medium leading-6 text-gray-900">
|
||||
<span v-if="auth.user.id !== form.user.id">
|
||||
Urlop wypoczynkowy, dane dla: {{ form.user.name }}
|
||||
Dane urlopowe dla: {{ form.user.name }}
|
||||
</span>
|
||||
<span v-else>
|
||||
Twoje dane o urlopie wypoczynkowym
|
||||
Twoje dane o urlopie
|
||||
</span>
|
||||
</h2>
|
||||
</div>
|
||||
@ -330,7 +335,6 @@ import VacationChart from '@/Shared/VacationChart'
|
||||
const props = defineProps({
|
||||
auth: Object,
|
||||
users: Object,
|
||||
vacationTypes: Object,
|
||||
holidays: Object,
|
||||
can: Object,
|
||||
})
|
||||
@ -341,12 +345,13 @@ const form = useForm({
|
||||
: props.auth.user,
|
||||
from: null,
|
||||
to: null,
|
||||
vacationType: props.vacationTypes[0],
|
||||
vacationType: null,
|
||||
comment: null,
|
||||
flowSkipped: false,
|
||||
})
|
||||
|
||||
const estimatedDays = ref([])
|
||||
const vacationTypes = ref([])
|
||||
|
||||
const stats = ref({
|
||||
used: 0,
|
||||
@ -372,8 +377,9 @@ const toInputConfig = reactive({
|
||||
|
||||
watch(() => form.user, user => {
|
||||
resetForm()
|
||||
refreshVacationStats(user)
|
||||
refreshAvailableTypes(user)
|
||||
refreshUnavailableDays(user)
|
||||
refreshVacationStats(user)
|
||||
}, { immediate: true })
|
||||
|
||||
function createForm() {
|
||||
@ -406,7 +412,7 @@ function onToChange(selectedDates, dateStr) {
|
||||
}
|
||||
|
||||
function resetForm() {
|
||||
form.reset('type', 'to', 'from', 'comment', 'flowSkipped')
|
||||
form.reset('to', 'from', 'comment', 'flowSkipped')
|
||||
form.clearErrors()
|
||||
estimatedDays.value = []
|
||||
}
|
||||
@ -440,4 +446,11 @@ async function refreshUnavailableDays(user) {
|
||||
]
|
||||
}
|
||||
|
||||
async function refreshAvailableTypes(user) {
|
||||
const res = await axios.post('/api/vacation/get-available-vacation-types', { user: user.id })
|
||||
|
||||
vacationTypes.value = res.data
|
||||
form.vacationType = vacationTypes.value[0]
|
||||
}
|
||||
|
||||
</script>
|
||||
|
@ -1,9 +1,9 @@
|
||||
<template>
|
||||
<InertiaHead title="Moje wnioski urlopowe" />
|
||||
<InertiaHead title="Moje wnioski" />
|
||||
<div class="bg-white shadow-md">
|
||||
<div class="flex justify-between items-center p-4 sm:px-6">
|
||||
<h2 class="text-lg font-medium leading-6 text-gray-900">
|
||||
Moje wnioski urlopowe
|
||||
Moje wnioski
|
||||
</h2>
|
||||
<div>
|
||||
<InertiaLink
|
||||
@ -102,7 +102,7 @@
|
||||
scope="col"
|
||||
class="py-3 px-4 text-xs font-semibold tracking-wider text-left text-gray-500 uppercase whitespace-nowrap"
|
||||
>
|
||||
Rodzaj urlopu
|
||||
Rodzaj wniosku
|
||||
</th>
|
||||
<th
|
||||
scope="col"
|
||||
|
@ -1,10 +1,10 @@
|
||||
<template>
|
||||
<InertiaHead title="Wnioski urlopowe" />
|
||||
<InertiaHead title="Lista wniosków" />
|
||||
<div class="bg-white shadow-md">
|
||||
<div class="flex justify-between items-center p-4 sm:px-6">
|
||||
<div>
|
||||
<h2 class="text-lg font-medium leading-6 text-gray-900">
|
||||
Wnioski urlopowe
|
||||
Lista wniosków
|
||||
</h2>
|
||||
</div>
|
||||
<div>
|
||||
@ -181,7 +181,7 @@
|
||||
scope="col"
|
||||
class="py-3 px-4 text-xs font-semibold tracking-wider text-left text-gray-500 uppercase whitespace-nowrap"
|
||||
>
|
||||
Rodzaj urlopu
|
||||
Rodzaj wniosku
|
||||
</th>
|
||||
<th
|
||||
scope="col"
|
||||
|
@ -41,7 +41,7 @@
|
||||
</div>
|
||||
<div class="py-4 sm:grid sm:grid-cols-3 sm:gap-4 sm:py-5 sm:px-6">
|
||||
<dt class="text-sm font-medium text-gray-500">
|
||||
Rodzaj urlopu
|
||||
Rodzaj wniosku
|
||||
</dt>
|
||||
<dd class="mt-1 text-sm text-gray-900 sm:col-span-2 sm:mt-0">
|
||||
<VacationType :type="request.type" />
|
||||
|
@ -301,7 +301,7 @@ const navigation = computed(() =>
|
||||
can: true,
|
||||
},
|
||||
{
|
||||
name: 'Wnioski urlopowe',
|
||||
name: 'Lista wniosków',
|
||||
href: '/vacation/requests',
|
||||
component: 'VacationRequest/IndexForApprovers',
|
||||
icon: CollectionIcon,
|
||||
|
@ -14,6 +14,7 @@
|
||||
"look_for_work_vacation": "Urlop na poszukiwanie pracy",
|
||||
"time_in_lieu": "Odbiór za święto",
|
||||
"sick_vacation": "Zwolnienie lekarskie",
|
||||
"absence": "Nieobecność",
|
||||
"employee": "Pracownik",
|
||||
"administrator": "Administrator",
|
||||
"technical_approver": "Techniczny akceptujący",
|
||||
|
@ -6,9 +6,11 @@ use Illuminate\Support\Facades\Route;
|
||||
use Toby\Infrastructure\Http\Controllers\Api\CalculateUserUnavailableDaysController;
|
||||
use Toby\Infrastructure\Http\Controllers\Api\CalculateUserVacationStatsController;
|
||||
use Toby\Infrastructure\Http\Controllers\Api\CalculateVacationDaysController;
|
||||
use Toby\Infrastructure\Http\Controllers\Api\GetAvailableVacationTypesController;
|
||||
|
||||
Route::middleware("auth:sanctum")->group(function (): void {
|
||||
Route::post("vacation/calculate-days", CalculateVacationDaysController::class);
|
||||
Route::post("vacation/calculate-stats", CalculateUserVacationStatsController::class);
|
||||
Route::post("vacation/calculate-unavailable-days", CalculateUserUnavailableDaysController::class);
|
||||
Route::post("vacation/get-available-vacation-types", GetAvailableVacationTypesController::class);
|
||||
});
|
||||
|
@ -6,6 +6,7 @@ namespace Tests\Feature;
|
||||
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
use Tests\FeatureTestCase;
|
||||
use Toby\Domain\Enums\EmploymentForm;
|
||||
use Toby\Eloquent\Models\User;
|
||||
|
||||
class VacationCalendarTest extends FeatureTestCase
|
||||
@ -16,6 +17,10 @@ class VacationCalendarTest extends FeatureTestCase
|
||||
{
|
||||
$administrativeApprover = User::factory()->administrativeApprover()->create();
|
||||
|
||||
User::factory(["employment_form" => EmploymentForm::EmploymentContract])
|
||||
->count(10)
|
||||
->create();
|
||||
|
||||
$this->actingAs($administrativeApprover)
|
||||
->get("/vacation/timesheet/january")
|
||||
->assertOk();
|
||||
|
Loading…
x
Reference in New Issue
Block a user