Merge branch 'main' into #42-global-notifications
# Conflicts: # app/Domain/Enums/VacationRequestState.php # app/Domain/VacationRequestStateManager.php # app/Eloquent/Models/Vacation.php # app/Infrastructure/Http/Controllers/VacationCalendarController.php # app/Infrastructure/Http/Controllers/VacationRequestController.php # database/factories/VacationFactory.php # database/migrations/2022_02_07_133018_create_vacations_table.php # database/seeders/DatabaseSeeder.php # resources/js/Pages/Calendar.vue # resources/js/Shared/Activity.vue # resources/js/Shared/MainMenu.vue # resources/js/Shared/Status.vue # tailwind.config.js # tests/Feature/VacationRequestTest.php # tests/Unit/VacationRequestStatesTest.php
This commit is contained in:
commit
c301ab7c26
80
app/Domain/CalendarGenerator.php
Normal file
80
app/Domain/CalendarGenerator.php
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Toby\Domain;
|
||||||
|
|
||||||
|
use Carbon\CarbonImmutable;
|
||||||
|
use Carbon\CarbonInterface;
|
||||||
|
use Carbon\CarbonPeriod;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
use Toby\Domain\Enums\VacationRequestState;
|
||||||
|
use Toby\Eloquent\Helpers\YearPeriodRetriever;
|
||||||
|
use Toby\Eloquent\Models\Vacation;
|
||||||
|
use Toby\Eloquent\Models\YearPeriod;
|
||||||
|
|
||||||
|
class CalendarGenerator
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
protected YearPeriodRetriever $yearPeriodRetriever,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public function generate(YearPeriod $yearPeriod, string $month): array
|
||||||
|
{
|
||||||
|
$date = CarbonImmutable::create($yearPeriod->year, $this->monthNameToNumber($month));
|
||||||
|
$period = CarbonPeriod::create($date->startOfMonth(), $date->endOfMonth());
|
||||||
|
$holidays = $yearPeriod->holidays()->pluck("date");
|
||||||
|
|
||||||
|
return $this->generateCalendar($period, $holidays);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function monthNameToNumber($name): int
|
||||||
|
{
|
||||||
|
return match ($name) {
|
||||||
|
default => CarbonInterface::JANUARY,
|
||||||
|
"february" => CarbonInterface::FEBRUARY,
|
||||||
|
"march" => CarbonInterface::MARCH,
|
||||||
|
"april" => CarbonInterface::APRIL,
|
||||||
|
"may" => CarbonInterface::MAY,
|
||||||
|
"june" => CarbonInterface::JUNE,
|
||||||
|
"july" => CarbonInterface::JULY,
|
||||||
|
"august" => CarbonInterface::AUGUST,
|
||||||
|
"september" => CarbonInterface::SEPTEMBER,
|
||||||
|
"october" => CarbonInterface::OCTOBER,
|
||||||
|
"november" => CarbonInterface::NOVEMBER,
|
||||||
|
"december" => CarbonInterface::DECEMBER,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function generateCalendar(CarbonPeriod $period, Collection $holidays): array
|
||||||
|
{
|
||||||
|
$calendar = [];
|
||||||
|
$vacations = $this->getVacationsForPeriod($period);
|
||||||
|
|
||||||
|
foreach ($period as $day) {
|
||||||
|
$vacationsForDay = $vacations[$day->toDateString()] ?? new Collection();
|
||||||
|
|
||||||
|
$calendar[] = [
|
||||||
|
"date" => $day->toDateString(),
|
||||||
|
"dayOfMonth" => $day->translatedFormat("j"),
|
||||||
|
"dayOfWeek" => $day->translatedFormat("D"),
|
||||||
|
"isToday" => $day->isToday(),
|
||||||
|
"isWeekend" => $day->isWeekend(),
|
||||||
|
"isHoliday" => $holidays->contains($day),
|
||||||
|
"vacations" => $vacationsForDay->pluck("user_id"),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $calendar;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getVacationsForPeriod(CarbonPeriod $period): Collection
|
||||||
|
{
|
||||||
|
return Vacation::query()
|
||||||
|
->whereBetween("date", [$period->start, $period->end])
|
||||||
|
->whereRelation("vacationRequest", "state", VacationRequestState::Approved->value)
|
||||||
|
->get()
|
||||||
|
->groupBy(fn(Vacation $vacation) => $vacation->date->toDateString());
|
||||||
|
}
|
||||||
|
}
|
@ -6,10 +6,10 @@ namespace Toby\Domain\Enums;
|
|||||||
|
|
||||||
enum EmploymentForm: string
|
enum EmploymentForm: string
|
||||||
{
|
{
|
||||||
case EMPLOYMENT_CONTRACT = "employment_contract";
|
case EmploymentContract = "employment_contract";
|
||||||
case COMMISSION_CONTRACT = "commission_contract";
|
case ComissionContract = "commission_contract";
|
||||||
case B2B_CONTRACT = "b2b_contract";
|
case B2bContract = "b2b_contract";
|
||||||
case BOARD_MEMBER_CONTRACT = "board_member_contract";
|
case BoardMemberContract = "board_member_contract";
|
||||||
|
|
||||||
public function label(): string
|
public function label(): string
|
||||||
{
|
{
|
||||||
|
@ -6,10 +6,10 @@ namespace Toby\Domain\Enums;
|
|||||||
|
|
||||||
enum Role: string
|
enum Role: string
|
||||||
{
|
{
|
||||||
case EMPLOYEE = "employee";
|
case Employee = "employee";
|
||||||
case ADMINISTRATOR = "administrator";
|
case Administrator = "administrator";
|
||||||
case TECHNICAL_APPROVER = "technical_approver";
|
case TechnicalApprover = "technical_approver";
|
||||||
case ADMINISTRATIVE_APPROVER = "administrative_approver";
|
case AdministrativeApprover = "administrative_approver";
|
||||||
|
|
||||||
public function label(): string
|
public function label(): string
|
||||||
{
|
{
|
||||||
|
@ -6,14 +6,14 @@ namespace Toby\Domain\Enums;
|
|||||||
|
|
||||||
enum VacationRequestState: string
|
enum VacationRequestState: string
|
||||||
{
|
{
|
||||||
case CREATED = "created";
|
case Created = "created";
|
||||||
case CANCELED = "canceled";
|
case Canceled = "canceled";
|
||||||
case REJECTED = "rejected";
|
case Rejected = "rejected";
|
||||||
case APPROVED = "approved";
|
case Approved = "approved";
|
||||||
case WAITING_FOR_TECHNICAL = "waiting_for_technical";
|
case WaitingForTechnical = "waiting_for_technical";
|
||||||
case WAITING_FOR_ADMINISTRATIVE = "waiting_for_administrative";
|
case WaitingForAdministrative = "waiting_for_administrative";
|
||||||
case ACCEPTED_BY_TECHNICAL = "accepted_by_technical";
|
case AcceptedByTechnical = "accepted_by_technical";
|
||||||
case ACCEPTED_BY_ADMINISTRATIVE = "accepted_by_administrative";
|
case AcceptedByAdministrative = "accepted_by_administrative";
|
||||||
|
|
||||||
public function label(): string
|
public function label(): string
|
||||||
{
|
{
|
||||||
@ -23,24 +23,24 @@ enum VacationRequestState: string
|
|||||||
public static function pendingStates(): array
|
public static function pendingStates(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
self::CREATED,
|
self::Created,
|
||||||
self::WAITING_FOR_TECHNICAL,
|
self::WaitingForTechnical,
|
||||||
self::WAITING_FOR_ADMINISTRATIVE,
|
self::WaitingForAdministrative,
|
||||||
self::ACCEPTED_BY_TECHNICAL,
|
self::AcceptedByTechnical,
|
||||||
self::ACCEPTED_BY_ADMINISTRATIVE,
|
self::AcceptedByAdministrative,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function successStates(): array
|
public static function successStates(): array
|
||||||
{
|
{
|
||||||
return [self::APPROVED];
|
return [self::Approved];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function failedStates(): array
|
public static function failedStates(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
self::REJECTED,
|
self::Rejected,
|
||||||
self::CANCELED,
|
self::Canceled,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,15 +6,15 @@ namespace Toby\Domain\Enums;
|
|||||||
|
|
||||||
enum VacationType: string
|
enum VacationType: string
|
||||||
{
|
{
|
||||||
case VACATION = "vacation";
|
case Vacation = "vacation";
|
||||||
case VACATION_ON_REQUEST = "vacation_on_request";
|
case OnRequest = "vacation_on_request";
|
||||||
case SPECIAL_VACATION = "special_vacation";
|
case Special = "special_vacation";
|
||||||
case CHILDCARE_VACATION = "childcare_vacation";
|
case Childcare = "childcare_vacation";
|
||||||
case TRAINING_VACATION = "training_vacation";
|
case Training = "training_vacation";
|
||||||
case UNPAID_VACATION = "unpaid_vacation";
|
case Unpaid = "unpaid_vacation";
|
||||||
case VOLUNTEERING_VACATION = "volunteering_vacation";
|
case Volunteering = "volunteering_vacation";
|
||||||
case TIME_IN_LIEU = "time_in_lieu";
|
case TimeInLieu = "time_in_lieu";
|
||||||
case SICK_VACATION = "sick_vacation";
|
case Sick = "sick_vacation";
|
||||||
|
|
||||||
public function label(): string
|
public function label(): string
|
||||||
{
|
{
|
||||||
|
@ -23,50 +23,50 @@ class VacationRequestStateManager
|
|||||||
|
|
||||||
public function markAsCreated(VacationRequest $vacationRequest): void
|
public function markAsCreated(VacationRequest $vacationRequest): void
|
||||||
{
|
{
|
||||||
$this->changeState($vacationRequest, VacationRequestState::CREATED);
|
$this->changeState($vacationRequest, VacationRequestState::Created);
|
||||||
|
|
||||||
$this->dispatcher->dispatch(new VacationRequestCreated($vacationRequest));
|
$this->dispatcher->dispatch(new VacationRequestCreated($vacationRequest));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function approve(VacationRequest $vacationRequest): void
|
public function approve(VacationRequest $vacationRequest): void
|
||||||
{
|
{
|
||||||
$this->changeState($vacationRequest, VacationRequestState::APPROVED);
|
$this->changeState($vacationRequest, VacationRequestState::Approved);
|
||||||
|
|
||||||
$this->dispatcher->dispatch(new VacationRequestApproved($vacationRequest));
|
$this->dispatcher->dispatch(new VacationRequestApproved($vacationRequest));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function reject(VacationRequest $vacationRequest): void
|
public function reject(VacationRequest $vacationRequest): void
|
||||||
{
|
{
|
||||||
$this->changeState($vacationRequest, VacationRequestState::REJECTED);
|
$this->changeState($vacationRequest, VacationRequestState::Rejected);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function cancel(VacationRequest $vacationRequest): void
|
public function cancel(VacationRequest $vacationRequest): void
|
||||||
{
|
{
|
||||||
$this->changeState($vacationRequest, VacationRequestState::CANCELED);
|
$this->changeState($vacationRequest, VacationRequestState::Canceled);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function acceptAsTechnical(VacationRequest $vacationRequest): void
|
public function acceptAsTechnical(VacationRequest $vacationRequest): void
|
||||||
{
|
{
|
||||||
$this->changeState($vacationRequest, VacationRequestState::ACCEPTED_BY_TECHNICAL);
|
$this->changeState($vacationRequest, VacationRequestState::AcceptedByTechnical);
|
||||||
|
|
||||||
$this->dispatcher->dispatch(new VacationRequestAcceptedByTechnical($vacationRequest));
|
$this->dispatcher->dispatch(new VacationRequestAcceptedByTechnical($vacationRequest));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function acceptAsAdministrative(VacationRequest $vacationRequest): void
|
public function acceptAsAdministrative(VacationRequest $vacationRequest): void
|
||||||
{
|
{
|
||||||
$this->changeState($vacationRequest, VacationRequestState::ACCEPTED_BY_ADMINISTRATIVE);
|
$this->changeState($vacationRequest, VacationRequestState::AcceptedByAdministrative);
|
||||||
|
|
||||||
$this->dispatcher->dispatch(new VacationRequestAcceptedByAdministrative($vacationRequest));
|
$this->dispatcher->dispatch(new VacationRequestAcceptedByAdministrative($vacationRequest));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function waitForTechnical(VacationRequest $vacationRequest): void
|
public function waitForTechnical(VacationRequest $vacationRequest): void
|
||||||
{
|
{
|
||||||
$this->changeState($vacationRequest, VacationRequestState::WAITING_FOR_TECHNICAL);
|
$this->changeState($vacationRequest, VacationRequestState::WaitingForTechnical);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function waitForAdministrative(VacationRequest $vacationRequest): void
|
public function waitForAdministrative(VacationRequest $vacationRequest): void
|
||||||
{
|
{
|
||||||
$this->changeState($vacationRequest, VacationRequestState::WAITING_FOR_ADMINISTRATIVE);
|
$this->changeState($vacationRequest, VacationRequestState::WaitingForAdministrative);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function changeState(VacationRequest $vacationRequest, VacationRequestState $state): void
|
protected function changeState(VacationRequest $vacationRequest, VacationRequestState $state): void
|
||||||
|
@ -4,23 +4,64 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Toby\Domain\Validation\Rules;
|
namespace Toby\Domain\Validation\Rules;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
|
use Toby\Domain\Enums\VacationRequestState;
|
||||||
|
use Toby\Domain\Enums\VacationType;
|
||||||
|
use Toby\Domain\VacationDaysCalculator;
|
||||||
use Toby\Domain\VacationTypeConfigRetriever;
|
use Toby\Domain\VacationTypeConfigRetriever;
|
||||||
|
use Toby\Eloquent\Models\User;
|
||||||
use Toby\Eloquent\Models\VacationRequest;
|
use Toby\Eloquent\Models\VacationRequest;
|
||||||
|
use Toby\Eloquent\Models\YearPeriod;
|
||||||
|
|
||||||
class DoesNotExceedLimitRule implements VacationRequestRule
|
class DoesNotExceedLimitRule implements VacationRequestRule
|
||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
protected VacationTypeConfigRetriever $configRetriever,
|
protected VacationTypeConfigRetriever $configRetriever,
|
||||||
|
protected VacationDaysCalculator $vacationDaysCalculator,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function check(VacationRequest $vacationRequest): bool
|
public function check(VacationRequest $vacationRequest): bool
|
||||||
{
|
{
|
||||||
|
if (!$this->configRetriever->hasLimit($vacationRequest->type)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$limit = $this->getUserVacationLimit($vacationRequest->user, $vacationRequest->yearPeriod);
|
||||||
|
$vacationDays = $this->getVacationDaysWithLimit($vacationRequest->user, $vacationRequest->yearPeriod);
|
||||||
|
$estimatedDays = $this->vacationDaysCalculator->calculateDays($vacationRequest->yearPeriod, $vacationRequest->from, $vacationRequest->to)->count();
|
||||||
|
|
||||||
|
return $limit >= ($vacationDays + $estimatedDays);
|
||||||
|
}
|
||||||
|
|
||||||
public function errorMessage(): string
|
public function errorMessage(): string
|
||||||
{
|
{
|
||||||
return __("You have exceeded your vacation limit.");
|
return __("Vacation limit has been exceeded.");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getUserVacationLimit(User $user, YearPeriod $yearPeriod): int
|
||||||
|
{
|
||||||
|
return $user->vacationLimits()->where("year_period_id", $yearPeriod->id)->first()->days ?? 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getVacationDaysWithLimit(User $user, YearPeriod $yearPeriod): int
|
||||||
|
{
|
||||||
|
return $user->vacations()
|
||||||
|
->where("year_period_id", $yearPeriod->id)
|
||||||
|
->whereRelation(
|
||||||
|
"vacationRequest",
|
||||||
|
fn(Builder $query) => $query
|
||||||
|
->whereIn("type", $this->getLimitableVacationTypes())
|
||||||
|
->noStates(VacationRequestState::failedStates()),
|
||||||
|
)
|
||||||
|
->count();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getLimitableVacationTypes(): Collection
|
||||||
|
{
|
||||||
|
$types = new Collection(VacationType::cases());
|
||||||
|
|
||||||
|
return $types->filter(fn(VacationType $type) => $this->configRetriever->hasLimit($type));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ use Illuminate\Support\Carbon;
|
|||||||
* @property Carbon $date
|
* @property Carbon $date
|
||||||
* @property User $user
|
* @property User $user
|
||||||
* @property VacationRequest $vacationRequest
|
* @property VacationRequest $vacationRequest
|
||||||
|
* @property YearPeriod $yearPeriod
|
||||||
*/
|
*/
|
||||||
class Vacation extends Model
|
class Vacation extends Model
|
||||||
{
|
{
|
||||||
@ -34,4 +35,9 @@ class Vacation extends Model
|
|||||||
{
|
{
|
||||||
return $this->belongsTo(VacationRequest::class);
|
return $this->belongsTo(VacationRequest::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function yearPeriod(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(YearPeriod::class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,6 @@ use Toby\Domain\Enums\VacationType;
|
|||||||
* @property VacationRequestState $state
|
* @property VacationRequestState $state
|
||||||
* @property Carbon $from
|
* @property Carbon $from
|
||||||
* @property Carbon $to
|
* @property Carbon $to
|
||||||
* @property int $estimated_days
|
|
||||||
* @property string $comment
|
* @property string $comment
|
||||||
* @property User $user
|
* @property User $user
|
||||||
* @property YearPeriod $yearPeriod
|
* @property YearPeriod $yearPeriod
|
||||||
@ -75,6 +74,11 @@ class VacationRequest extends Model
|
|||||||
return $query->whereIn("state", $states);
|
return $query->whereIn("state", $states);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function scopeNoStates(Builder $query, array $states): Builder
|
||||||
|
{
|
||||||
|
return $query->whereNotIn("state", $states);
|
||||||
|
}
|
||||||
|
|
||||||
public function scopeOverlapsWith(Builder $query, self $vacationRequest): Builder
|
public function scopeOverlapsWith(Builder $query, self $vacationRequest): Builder
|
||||||
{
|
{
|
||||||
return $query->where("from", "<=", $vacationRequest->to)
|
return $query->where("from", "<=", $vacationRequest->to)
|
||||||
|
@ -4,81 +4,35 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Toby\Infrastructure\Http\Controllers;
|
namespace Toby\Infrastructure\Http\Controllers;
|
||||||
|
|
||||||
use Carbon\CarbonImmutable;
|
|
||||||
use Carbon\CarbonInterface;
|
|
||||||
use Carbon\CarbonPeriod;
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Carbon;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use Inertia\Response;
|
use Inertia\Response;
|
||||||
use Toby\Domain\Enums\VacationRequestState;
|
use Toby\Domain\CalendarGenerator;
|
||||||
use Toby\Eloquent\Helpers\YearPeriodRetriever;
|
use Toby\Eloquent\Helpers\YearPeriodRetriever;
|
||||||
use Toby\Eloquent\Models\User;
|
use Toby\Eloquent\Models\User;
|
||||||
use Toby\Eloquent\Models\Vacation;
|
|
||||||
use Toby\Infrastructure\Http\Resources\UserResource;
|
use Toby\Infrastructure\Http\Resources\UserResource;
|
||||||
|
|
||||||
class VacationCalendarController extends Controller
|
class VacationCalendarController extends Controller
|
||||||
{
|
{
|
||||||
public function index(Request $request, YearPeriodRetriever $yearPeriodRetriever): Response
|
public function index(
|
||||||
{
|
Request $request,
|
||||||
$month = $request->query("month", "february");
|
YearPeriodRetriever $yearPeriodRetriever,
|
||||||
|
CalendarGenerator $calendarGenerator,
|
||||||
|
): Response {
|
||||||
|
$month = Str::lower($request->query("month", Carbon::now()->englishMonth));
|
||||||
$yearPeriod = $yearPeriodRetriever->selected();
|
$yearPeriod = $yearPeriodRetriever->selected();
|
||||||
$date = CarbonImmutable::create($yearPeriod->year, $this->monthNameToNumber($month));
|
|
||||||
$period = CarbonPeriod::create($date->startOfMonth(), $date->endOfMonth());
|
|
||||||
$holidays = $yearPeriod->holidays()->pluck("date");
|
|
||||||
$users = User::query()
|
$users = User::query()
|
||||||
->with([
|
|
||||||
"vacations" => fn($query) => $query
|
|
||||||
->whereBetween("date", [$period->start, $period->end])
|
|
||||||
->whereRelation("vacationRequest", "state", VacationRequestState::APPROVED->value),
|
|
||||||
])
|
|
||||||
->orderBy("last_name")
|
->orderBy("last_name")
|
||||||
->orderBy("first_name")
|
->orderBy("first_name")
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
$calendar = [];
|
$calendar = $calendarGenerator->generate($yearPeriod, $month);
|
||||||
|
|
||||||
foreach ($period as $day) {
|
|
||||||
$calendar[] = [
|
|
||||||
"date" => $day->toDateString(),
|
|
||||||
"dayOfMonth" => $day->translatedFormat("j"),
|
|
||||||
"dayOfWeek" => $day->translatedFormat("D"),
|
|
||||||
"isToday" => $day->isToday(),
|
|
||||||
"isWeekend" => $day->isWeekend(),
|
|
||||||
"isHoliday" => $holidays->contains($day),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
$userVacations = [];
|
|
||||||
|
|
||||||
/** @var User $user */
|
|
||||||
foreach ($users as $user) {
|
|
||||||
$userVacations[] = [
|
|
||||||
"user" => new UserResource($user),
|
|
||||||
"vacations" => $user->vacations->map(fn(Vacation $vacation) => $vacation->date->toDateString()),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
return inertia("Calendar", [
|
return inertia("Calendar", [
|
||||||
"calendar" => $calendar,
|
"calendar" => $calendar,
|
||||||
"currentMonth" => $month,
|
"currentMonth" => $month,
|
||||||
"userVacations" => $userVacations,
|
"users" => UserResource::collection($users),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function monthNameToNumber(?string $name): int
|
|
||||||
{
|
|
||||||
return match ($name) {
|
|
||||||
default => CarbonInterface::JANUARY,
|
|
||||||
"february" => CarbonInterface::FEBRUARY,
|
|
||||||
"march" => CarbonInterface::MARCH,
|
|
||||||
"april" => CarbonInterface::APRIL,
|
|
||||||
"may" => CarbonInterface::MAY,
|
|
||||||
"june" => CarbonInterface::JUNE,
|
|
||||||
"july" => CarbonInterface::JULY,
|
|
||||||
"august" => CarbonInterface::AUGUST,
|
|
||||||
"september" => CarbonInterface::SEPTEMBER,
|
|
||||||
"october" => CarbonInterface::OCTOBER,
|
|
||||||
"november" => CarbonInterface::NOVEMBER,
|
|
||||||
"december" => CarbonInterface::DECEMBER,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -75,6 +75,7 @@ class VacationRequestController extends Controller
|
|||||||
/** @var VacationRequest $vacationRequest */
|
/** @var VacationRequest $vacationRequest */
|
||||||
$vacationRequest = $request->user()->vacationRequests()->make($request->data());
|
$vacationRequest = $request->user()->vacationRequests()->make($request->data());
|
||||||
$vacationRequestValidator->validate($vacationRequest);
|
$vacationRequestValidator->validate($vacationRequest);
|
||||||
|
|
||||||
$vacationRequest->save();
|
$vacationRequest->save();
|
||||||
|
|
||||||
$days = $vacationDaysCalculator->calculateDays(
|
$days = $vacationDaysCalculator->calculateDays(
|
||||||
@ -86,7 +87,8 @@ class VacationRequestController extends Controller
|
|||||||
foreach ($days as $day) {
|
foreach ($days as $day) {
|
||||||
$vacationRequest->vacations()->create([
|
$vacationRequest->vacations()->create([
|
||||||
"date" => $day,
|
"date" => $day,
|
||||||
"user_id" => $vacationRequest->user_id,
|
"user_id" => $vacationRequest->user->id,
|
||||||
|
"year_period_id" => $vacationRequest->yearPeriod->id,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,55 +6,55 @@ use Toby\Domain\Enums\VacationType;
|
|||||||
use Toby\Domain\VacationTypeConfigRetriever;
|
use Toby\Domain\VacationTypeConfigRetriever;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
VacationType::VACATION->value => [
|
VacationType::Vacation->value => [
|
||||||
VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => true,
|
VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => true,
|
||||||
VacationTypeConfigRetriever::KEY_ADMINISTRATIVE_APPROVAL => true,
|
VacationTypeConfigRetriever::KEY_ADMINISTRATIVE_APPROVAL => true,
|
||||||
VacationTypeConfigRetriever::KEY_BILLABLE => true,
|
VacationTypeConfigRetriever::KEY_BILLABLE => true,
|
||||||
VacationTypeConfigRetriever::KEY_HAS_LIMIT => true,
|
VacationTypeConfigRetriever::KEY_HAS_LIMIT => true,
|
||||||
],
|
],
|
||||||
VacationType::VACATION_ON_REQUEST->value => [
|
VacationType::OnRequest->value => [
|
||||||
VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => true,
|
VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => true,
|
||||||
VacationTypeConfigRetriever::KEY_ADMINISTRATIVE_APPROVAL => true,
|
VacationTypeConfigRetriever::KEY_ADMINISTRATIVE_APPROVAL => true,
|
||||||
VacationTypeConfigRetriever::KEY_BILLABLE => true,
|
VacationTypeConfigRetriever::KEY_BILLABLE => true,
|
||||||
VacationTypeConfigRetriever::KEY_HAS_LIMIT => true,
|
VacationTypeConfigRetriever::KEY_HAS_LIMIT => true,
|
||||||
],
|
],
|
||||||
VacationType::TIME_IN_LIEU->value => [
|
VacationType::TimeInLieu->value => [
|
||||||
VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => false,
|
VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => false,
|
||||||
VacationTypeConfigRetriever::KEY_ADMINISTRATIVE_APPROVAL => false,
|
VacationTypeConfigRetriever::KEY_ADMINISTRATIVE_APPROVAL => false,
|
||||||
VacationTypeConfigRetriever::KEY_BILLABLE => true,
|
VacationTypeConfigRetriever::KEY_BILLABLE => true,
|
||||||
VacationTypeConfigRetriever::KEY_HAS_LIMIT => false,
|
VacationTypeConfigRetriever::KEY_HAS_LIMIT => false,
|
||||||
],
|
],
|
||||||
VacationType::SICK_VACATION->value => [
|
VacationType::Sick->value => [
|
||||||
VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => false,
|
VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => false,
|
||||||
VacationTypeConfigRetriever::KEY_ADMINISTRATIVE_APPROVAL => true,
|
VacationTypeConfigRetriever::KEY_ADMINISTRATIVE_APPROVAL => true,
|
||||||
VacationTypeConfigRetriever::KEY_BILLABLE => true,
|
VacationTypeConfigRetriever::KEY_BILLABLE => true,
|
||||||
VacationTypeConfigRetriever::KEY_HAS_LIMIT => false,
|
VacationTypeConfigRetriever::KEY_HAS_LIMIT => false,
|
||||||
],
|
],
|
||||||
VacationType::UNPAID_VACATION->value => [
|
VacationType::Unpaid->value => [
|
||||||
VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => true,
|
VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => true,
|
||||||
VacationTypeConfigRetriever::KEY_ADMINISTRATIVE_APPROVAL => true,
|
VacationTypeConfigRetriever::KEY_ADMINISTRATIVE_APPROVAL => true,
|
||||||
VacationTypeConfigRetriever::KEY_BILLABLE => false,
|
VacationTypeConfigRetriever::KEY_BILLABLE => false,
|
||||||
VacationTypeConfigRetriever::KEY_HAS_LIMIT => false,
|
VacationTypeConfigRetriever::KEY_HAS_LIMIT => false,
|
||||||
],
|
],
|
||||||
VacationType::SPECIAL_VACATION->value => [
|
VacationType::Special->value => [
|
||||||
VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => true,
|
VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => true,
|
||||||
VacationTypeConfigRetriever::KEY_ADMINISTRATIVE_APPROVAL => true,
|
VacationTypeConfigRetriever::KEY_ADMINISTRATIVE_APPROVAL => true,
|
||||||
VacationTypeConfigRetriever::KEY_BILLABLE => false,
|
VacationTypeConfigRetriever::KEY_BILLABLE => false,
|
||||||
VacationTypeConfigRetriever::KEY_HAS_LIMIT => false,
|
VacationTypeConfigRetriever::KEY_HAS_LIMIT => false,
|
||||||
],
|
],
|
||||||
VacationType::CHILDCARE_VACATION->value => [
|
VacationType::Childcare->value => [
|
||||||
VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => true,
|
VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => true,
|
||||||
VacationTypeConfigRetriever::KEY_ADMINISTRATIVE_APPROVAL => true,
|
VacationTypeConfigRetriever::KEY_ADMINISTRATIVE_APPROVAL => true,
|
||||||
VacationTypeConfigRetriever::KEY_BILLABLE => false,
|
VacationTypeConfigRetriever::KEY_BILLABLE => false,
|
||||||
VacationTypeConfigRetriever::KEY_HAS_LIMIT => false,
|
VacationTypeConfigRetriever::KEY_HAS_LIMIT => false,
|
||||||
],
|
],
|
||||||
VacationType::TRAINING_VACATION->value => [
|
VacationType::Training->value => [
|
||||||
VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => true,
|
VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => true,
|
||||||
VacationTypeConfigRetriever::KEY_ADMINISTRATIVE_APPROVAL => true,
|
VacationTypeConfigRetriever::KEY_ADMINISTRATIVE_APPROVAL => true,
|
||||||
VacationTypeConfigRetriever::KEY_BILLABLE => true,
|
VacationTypeConfigRetriever::KEY_BILLABLE => true,
|
||||||
VacationTypeConfigRetriever::KEY_HAS_LIMIT => false,
|
VacationTypeConfigRetriever::KEY_HAS_LIMIT => false,
|
||||||
],
|
],
|
||||||
VacationType::VOLUNTEERING_VACATION->value => [
|
VacationType::Volunteering->value => [
|
||||||
VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => true,
|
VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => true,
|
||||||
VacationTypeConfigRetriever::KEY_ADMINISTRATIVE_APPROVAL => true,
|
VacationTypeConfigRetriever::KEY_ADMINISTRATIVE_APPROVAL => true,
|
||||||
VacationTypeConfigRetriever::KEY_BILLABLE => true,
|
VacationTypeConfigRetriever::KEY_BILLABLE => true,
|
||||||
|
@ -23,7 +23,7 @@ class UserFactory extends Factory
|
|||||||
"email" => $this->faker->unique()->safeEmail(),
|
"email" => $this->faker->unique()->safeEmail(),
|
||||||
"employment_form" => $this->faker->randomElement(EmploymentForm::cases()),
|
"employment_form" => $this->faker->randomElement(EmploymentForm::cases()),
|
||||||
"position" => $this->faker->jobTitle(),
|
"position" => $this->faker->jobTitle(),
|
||||||
"role" => Role::EMPLOYEE,
|
"role" => Role::Employee,
|
||||||
"employment_date" => Carbon::createFromInterface($this->faker->dateTimeBetween("2020-10-27"))->toDateString(),
|
"employment_date" => Carbon::createFromInterface($this->faker->dateTimeBetween("2020-10-27"))->toDateString(),
|
||||||
"remember_token" => Str::random(10),
|
"remember_token" => Str::random(10),
|
||||||
];
|
];
|
||||||
|
@ -8,15 +8,8 @@ use Illuminate\Database\Eloquent\Factories\Factory;
|
|||||||
|
|
||||||
class VacationFactory extends Factory
|
class VacationFactory extends Factory
|
||||||
{
|
{
|
||||||
/**
|
public function definition(): array
|
||||||
* Define the model's default state.
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function definition()
|
|
||||||
{
|
{
|
||||||
return [
|
return [];
|
||||||
//
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ return new class() extends Migration {
|
|||||||
$table->string("last_name");
|
$table->string("last_name");
|
||||||
$table->string("email")->unique();
|
$table->string("email")->unique();
|
||||||
$table->string("avatar")->nullable();
|
$table->string("avatar")->nullable();
|
||||||
$table->string("role")->default(Role::EMPLOYEE->value);
|
$table->string("role")->default(Role::Employee->value);
|
||||||
$table->string("position");
|
$table->string("position");
|
||||||
$table->string("employment_form");
|
$table->string("employment_form");
|
||||||
$table->date("employment_date");
|
$table->date("employment_date");
|
||||||
|
@ -7,6 +7,7 @@ use Illuminate\Database\Schema\Blueprint;
|
|||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
use Toby\Eloquent\Models\User;
|
use Toby\Eloquent\Models\User;
|
||||||
use Toby\Eloquent\Models\VacationRequest;
|
use Toby\Eloquent\Models\VacationRequest;
|
||||||
|
use Toby\Eloquent\Models\YearPeriod;
|
||||||
|
|
||||||
return new class() extends Migration {
|
return new class() extends Migration {
|
||||||
public function up(): void
|
public function up(): void
|
||||||
@ -15,6 +16,7 @@ return new class() extends Migration {
|
|||||||
$table->id();
|
$table->id();
|
||||||
$table->foreignIdFor(User::class)->constrained()->cascadeOnDelete();
|
$table->foreignIdFor(User::class)->constrained()->cascadeOnDelete();
|
||||||
$table->foreignIdFor(VacationRequest::class)->constrained()->cascadeOnDelete();
|
$table->foreignIdFor(VacationRequest::class)->constrained()->cascadeOnDelete();
|
||||||
|
$table->foreignIdFor(YearPeriod::class)->constrained()->cascadeOnDelete();
|
||||||
$table->date("date");
|
$table->date("date");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -91,6 +91,7 @@ class DatabaseSeeder extends Seeder
|
|||||||
$vacationRequest->vacations()->create([
|
$vacationRequest->vacations()->create([
|
||||||
"date" => $day,
|
"date" => $day,
|
||||||
"user_id" => $vacationRequest->user->id,
|
"user_id" => $vacationRequest->user->id,
|
||||||
|
"year_period_id" => $vacationRequest->yearPeriod->id,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
60
resources/js/Composables/monthInfo.js
Normal file
60
resources/js/Composables/monthInfo.js
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
const months = [
|
||||||
|
{
|
||||||
|
'name': 'Styczeń',
|
||||||
|
'value': 'january',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name': 'Luty',
|
||||||
|
'value': 'february',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name': 'Marzec',
|
||||||
|
'value': 'march',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name': 'Kwiecień',
|
||||||
|
'value': 'april',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name': 'Maj',
|
||||||
|
'value': 'may',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name': 'Czerwiec',
|
||||||
|
'value': 'june',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name': 'Lipiec',
|
||||||
|
'value': 'july',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name': 'Sierpień',
|
||||||
|
'value': 'august',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name': 'Wrzesień',
|
||||||
|
'value': 'september',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name': 'Październik',
|
||||||
|
'value': 'october',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name': 'Listopad',
|
||||||
|
'value': 'november',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name': 'Grudzień',
|
||||||
|
'value': 'december',
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
export function useMonthInfo() {
|
||||||
|
const getMonths = () => months
|
||||||
|
const findMonth = value => months.find(month => month.value === value)
|
||||||
|
|
||||||
|
return {
|
||||||
|
getMonths,
|
||||||
|
findMonth,
|
||||||
|
}
|
||||||
|
}
|
128
resources/js/Composables/statusInfo.js
Normal file
128
resources/js/Composables/statusInfo.js
Normal file
@ -0,0 +1,128 @@
|
|||||||
|
import {
|
||||||
|
CheckIcon as OutlineCheckIcon,
|
||||||
|
ClockIcon as OutlineClockIcon,
|
||||||
|
DocumentTextIcon as OutlineDocumentTextIcon,
|
||||||
|
ThumbDownIcon as OutlineThumbDownIcon,
|
||||||
|
ThumbUpIcon as OutlineThumbUpIcon,
|
||||||
|
XIcon as OutlineXIcon,
|
||||||
|
} from '@heroicons/vue/outline'
|
||||||
|
|
||||||
|
import {
|
||||||
|
CheckIcon as SolidCheckIcon,
|
||||||
|
ClockIcon as SolidClockIcon,
|
||||||
|
DocumentTextIcon as SolidDocumentTextIcon,
|
||||||
|
ThumbDownIcon as SolidThumbDownIcon,
|
||||||
|
ThumbUpIcon as SolidThumbUpIcon,
|
||||||
|
XIcon as SolidXIcon,
|
||||||
|
} from '@heroicons/vue/solid'
|
||||||
|
|
||||||
|
const statuses = [
|
||||||
|
{
|
||||||
|
text: 'Utworzony',
|
||||||
|
value: 'created',
|
||||||
|
outline: {
|
||||||
|
icon: OutlineDocumentTextIcon,
|
||||||
|
foreground: 'text-white',
|
||||||
|
background: 'bg-gray-400',
|
||||||
|
},
|
||||||
|
solid: {
|
||||||
|
icon: SolidDocumentTextIcon,
|
||||||
|
color: 'text-gray-400',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: 'Czeka na akceptację od przełożonego technicznego',
|
||||||
|
value: 'waiting_for_technical',
|
||||||
|
outline: {
|
||||||
|
icon: OutlineClockIcon,
|
||||||
|
foreground: 'text-white',
|
||||||
|
background: 'bg-amber-400',
|
||||||
|
},
|
||||||
|
solid: {
|
||||||
|
icon: SolidClockIcon,
|
||||||
|
color: 'text-amber-400',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: 'Czeka na akceptację od przełożonego administracyjnego',
|
||||||
|
value: 'waiting_for_administrative',
|
||||||
|
outline: {
|
||||||
|
icon: OutlineClockIcon,
|
||||||
|
foreground: 'text-white',
|
||||||
|
background: 'bg-amber-400',
|
||||||
|
},
|
||||||
|
solid: {
|
||||||
|
icon: SolidClockIcon,
|
||||||
|
color: 'text-amber-400',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: 'Odrzucony',
|
||||||
|
value: 'rejected',
|
||||||
|
outline: {
|
||||||
|
icon: OutlineThumbDownIcon,
|
||||||
|
foreground: 'text-white',
|
||||||
|
background: 'bg-rose-600',
|
||||||
|
},
|
||||||
|
solid: {
|
||||||
|
icon: SolidThumbDownIcon,
|
||||||
|
color: 'text-rose-600',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: 'Zaakceptowany przez przełożonego technicznego',
|
||||||
|
value: 'accepted_by_technical',
|
||||||
|
outline: {
|
||||||
|
icon: OutlineThumbUpIcon,
|
||||||
|
foreground: 'text-white',
|
||||||
|
background: 'bg-green-500',
|
||||||
|
},
|
||||||
|
solid: {
|
||||||
|
icon: SolidThumbUpIcon,
|
||||||
|
color: 'text-green-500',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: 'Zaakceptowany przez przełożonego administracyjnego',
|
||||||
|
value: 'accepted_by_administrative',
|
||||||
|
outline: {
|
||||||
|
icon: OutlineThumbUpIcon,
|
||||||
|
foreground: 'text-white',
|
||||||
|
background: 'bg-green-500',
|
||||||
|
},
|
||||||
|
solid: {
|
||||||
|
icon: SolidThumbUpIcon,
|
||||||
|
color: 'text-green-500',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: 'Zatwierdzony',
|
||||||
|
value: 'approved',
|
||||||
|
outline: {
|
||||||
|
icon: OutlineCheckIcon,
|
||||||
|
foreground: 'text-white',
|
||||||
|
background: 'bg-blumilk-500',
|
||||||
|
},
|
||||||
|
solid: {
|
||||||
|
icon: SolidCheckIcon,
|
||||||
|
color: 'text-blumilk-500',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: 'Anulowany',
|
||||||
|
value: 'canceled',
|
||||||
|
outline: {
|
||||||
|
icon: OutlineXIcon,
|
||||||
|
foreground: 'text-white',
|
||||||
|
background: 'bg-gray-900',
|
||||||
|
},
|
||||||
|
solid: {
|
||||||
|
icon: SolidXIcon,
|
||||||
|
color: 'text-gray-900',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
export function useStatusInfo(status) {
|
||||||
|
return statuses.find(statusInfo => statusInfo.value === status)
|
||||||
|
}
|
@ -75,21 +75,20 @@
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr
|
<tr
|
||||||
v-for="userVacation in userVacations"
|
v-for="user in users.data"
|
||||||
:key="userVacation.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
|
||||||
class="h-10 w-10 rounded-full"
|
class="h-10 w-10 rounded-full"
|
||||||
:src="userVacation.user.avatar"
|
:src="user.avatar"
|
||||||
alt=""
|
|
||||||
>
|
>
|
||||||
</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">
|
||||||
{{ userVacation.user.name }}
|
{{ user.name }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -98,10 +97,10 @@
|
|||||||
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-gray-100': day.isWeekend, 'bg-green-100': day.isHoliday, 'bg-blumilk-500': userVacation.vacations.includes(day.date) }"
|
:class="{'bg-red-100': day.isWeekend || day.isHoliday, 'bg-blumilk-500': day.vacations.includes(user.id) }"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
v-if="userVacation.vacations.includes(day.date)"
|
v-if="day.vacations.includes(user.id)"
|
||||||
class="flex justify-center items-center"
|
class="flex justify-center items-center"
|
||||||
>
|
>
|
||||||
<svg
|
<svg
|
||||||
@ -127,6 +126,7 @@
|
|||||||
import {Menu, MenuButton, MenuItem, MenuItems} from '@headlessui/vue'
|
import {Menu, MenuButton, MenuItem, MenuItems} from '@headlessui/vue'
|
||||||
import {CheckIcon, ChevronDownIcon} from '@heroicons/vue/solid'
|
import {CheckIcon, ChevronDownIcon} from '@heroicons/vue/solid'
|
||||||
import {computed} from 'vue'
|
import {computed} from 'vue'
|
||||||
|
import {useMonthInfo} from '@/Composables/monthInfo'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'VacationCalendar',
|
name: 'VacationCalendar',
|
||||||
@ -139,7 +139,7 @@ export default {
|
|||||||
ChevronDownIcon,
|
ChevronDownIcon,
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
userVacations: {
|
users: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: () => null,
|
default: () => null,
|
||||||
},
|
},
|
||||||
@ -153,58 +153,10 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
setup(props) {
|
setup(props) {
|
||||||
const months = [
|
const {getMonths, findMonth} = useMonthInfo()
|
||||||
{
|
const months = getMonths()
|
||||||
'name': 'Styczeń',
|
|
||||||
'value': 'january',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'name': 'Luty',
|
|
||||||
'value': 'february',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'name': 'Marzec',
|
|
||||||
'value': 'march',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'name': 'Kwiecień',
|
|
||||||
'value': 'april',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'name': 'Maj',
|
|
||||||
'value': 'may',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'name': 'Czerwiec',
|
|
||||||
'value': 'june',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'name': 'Lipiec',
|
|
||||||
'value': 'july',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'name': 'Sierpień',
|
|
||||||
'value': 'august',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'name': 'Wrzesień',
|
|
||||||
'value': 'september',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'name': 'Październik',
|
|
||||||
'value': 'october',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'name': 'Listopad',
|
|
||||||
'value': 'november',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'name': 'Grudzień',
|
|
||||||
'value': 'december',
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
const selectedMonth = computed(() => months.find(month => month.value === props.currentMonth))
|
const selectedMonth = computed(() => findMonth(props.currentMonth))
|
||||||
|
|
||||||
return {
|
return {
|
||||||
months,
|
months,
|
||||||
|
@ -18,6 +18,14 @@
|
|||||||
{{ request.name }}
|
{{ request.name }}
|
||||||
</dd>
|
</dd>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="py-4 sm:py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
|
||||||
|
<dt class="text-sm font-medium text-gray-500">
|
||||||
|
Pracownik
|
||||||
|
</dt>
|
||||||
|
<dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
|
||||||
|
{{ request.user.name }}
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
<div class="py-4 sm:py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
|
<div class="py-4 sm:py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
|
||||||
<dt class="text-sm font-medium text-gray-500">
|
<dt class="text-sm font-medium text-gray-500">
|
||||||
Rodzaj urlopu
|
Rodzaj urlopu
|
||||||
|
@ -6,9 +6,9 @@
|
|||||||
/>
|
/>
|
||||||
<div class="relative flex space-x-3">
|
<div class="relative flex space-x-3">
|
||||||
<div>
|
<div>
|
||||||
<span :class="[statusInfo.iconBackground, statusInfo.iconForeground, 'h-8 w-8 rounded-full flex items-center justify-center ring-8 ring-white']">
|
<span :class="[statusInfo.outline.background, statusInfo.outline.foreground, 'h-8 w-8 rounded-full flex items-center justify-center ring-8 ring-white']">
|
||||||
<component
|
<component
|
||||||
:is="statusInfo.icon"
|
:is="statusInfo.outline.icon"
|
||||||
class="w-5 h-5 text-white"
|
class="w-5 h-5 text-white"
|
||||||
/>
|
/>
|
||||||
</span>
|
</span>
|
||||||
@ -32,8 +32,8 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {CheckIcon, ClockIcon, DocumentTextIcon, ThumbDownIcon, ThumbUpIcon, XIcon} from '@heroicons/vue/outline'
|
|
||||||
import {computed} from 'vue'
|
import {computed} from 'vue'
|
||||||
|
import {useStatusInfo} from '@/Composables/statusInfo'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'VacationRequestActivity',
|
name: 'VacationRequestActivity',
|
||||||
@ -48,65 +48,7 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
setup(props) {
|
setup(props) {
|
||||||
const statuses = [
|
const statusInfo = computed(() => useStatusInfo(props.activity.state))
|
||||||
{
|
|
||||||
text: 'Utworzony',
|
|
||||||
icon: DocumentTextIcon,
|
|
||||||
value: 'created',
|
|
||||||
iconForeground: 'text-white',
|
|
||||||
iconBackground: 'bg-gray-400',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: 'Czeka na akceptację od technicznego',
|
|
||||||
icon: ClockIcon,
|
|
||||||
value: 'waiting_for_technical',
|
|
||||||
iconForeground: 'text-white',
|
|
||||||
iconBackground: 'bg-amber-400',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: 'Czeka na akceptację od administracyjnego',
|
|
||||||
icon: ClockIcon,
|
|
||||||
value: 'waiting_for_administrative',
|
|
||||||
iconForeground: 'text-white',
|
|
||||||
iconBackground: 'bg-amber-400',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: 'Odrzucony',
|
|
||||||
icon: ThumbDownIcon,
|
|
||||||
value: 'rejected',
|
|
||||||
iconForeground: 'text-white',
|
|
||||||
iconBackground: 'bg-rose-600',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: 'Zaakceptowany przez technicznego',
|
|
||||||
icon: ThumbUpIcon,
|
|
||||||
value: 'accepted_by_technical',
|
|
||||||
iconForeground: 'text-white',
|
|
||||||
iconBackground: 'bg-green-500',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: 'Zaakceptowany przez administracyjnego',
|
|
||||||
icon: ThumbUpIcon,
|
|
||||||
value: 'accepted_by_administrative',
|
|
||||||
iconForeground: 'text-white',
|
|
||||||
iconBackground: 'bg-green-500',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: 'Zatwierdzony',
|
|
||||||
icon: CheckIcon,
|
|
||||||
value: 'approved',
|
|
||||||
iconForeground: 'text-white',
|
|
||||||
iconBackground: 'bg-blumilk-500',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: 'Anulowany',
|
|
||||||
icon: XIcon,
|
|
||||||
value: 'canceled',
|
|
||||||
iconForeground: 'text-white',
|
|
||||||
iconBackground: 'bg-gray-900',
|
|
||||||
},
|
|
||||||
]
|
|
||||||
const statusInfo = computed(() => statuses.find(status => status.value === props.activity.state))
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
statusInfo,
|
statusInfo,
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="flex items-center">
|
<div class="flex items-center">
|
||||||
<component
|
<component
|
||||||
:is="statusInfo.icon"
|
:is="statusInfo.solid.icon"
|
||||||
:class="[statusInfo.color ,'w-5 h-5 mr-1']"
|
:class="[statusInfo.solid.color ,'w-5 h-5 mr-1']"
|
||||||
/>
|
/>
|
||||||
<span>{{ statusInfo.text }}</span>
|
<span>{{ statusInfo.text }}</span>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {CheckIcon, ClockIcon, DocumentTextIcon, ThumbDownIcon, ThumbUpIcon, XIcon} from '@heroicons/vue/solid'
|
|
||||||
import {computed} from 'vue'
|
import {computed} from 'vue'
|
||||||
|
import {useStatusInfo} from '@/Composables/statusInfo'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'VacationRequestStatus',
|
name: 'VacationRequestStatus',
|
||||||
@ -25,57 +25,7 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
setup(props) {
|
setup(props) {
|
||||||
const statuses = [
|
const statusInfo = computed(() => useStatusInfo(props.status))
|
||||||
{
|
|
||||||
text: 'Utworzony',
|
|
||||||
icon: DocumentTextIcon,
|
|
||||||
value: 'created',
|
|
||||||
color: 'text-gray-400',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: 'Czeka na akceptację od technicznego',
|
|
||||||
icon: ClockIcon,
|
|
||||||
value: 'waiting_for_technical',
|
|
||||||
color: 'text-amber-400',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: 'Czeka na akceptację od administracyjnego',
|
|
||||||
icon: ClockIcon,
|
|
||||||
value: 'waiting_for_administrative',
|
|
||||||
color: 'text-amber-400',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: 'Odrzucony',
|
|
||||||
icon: ThumbDownIcon,
|
|
||||||
value: 'rejected',
|
|
||||||
color: 'text-rose-600',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: 'Zaakceptowany przez technicznego',
|
|
||||||
icon: ThumbUpIcon,
|
|
||||||
value: 'accepted_by_technical',
|
|
||||||
color: 'text-green-500',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: 'Zaakceptowany przez administracyjnego',
|
|
||||||
icon: ThumbUpIcon,
|
|
||||||
value: 'accepted_by_administrative',
|
|
||||||
color: 'text-green-500',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: 'Zatwierdzony',
|
|
||||||
icon: CheckIcon,
|
|
||||||
value: 'approved',
|
|
||||||
color: 'text-blumilk-500',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: 'Anulowany',
|
|
||||||
icon: XIcon,
|
|
||||||
value: 'canceled',
|
|
||||||
color: 'text-gray-900',
|
|
||||||
},
|
|
||||||
]
|
|
||||||
const statusInfo = computed(() => statuses.find(status => status.value === props.status))
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
statusInfo,
|
statusInfo,
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
"accepted_by_administrative": "Zaakceptowany przez administracyjnego",
|
"accepted_by_administrative": "Zaakceptowany przez administracyjnego",
|
||||||
"You have pending vacation request in this range.": "Masz oczekujący wniosek urlopowy w tym zakresie dat.",
|
"You have pending vacation request in this range.": "Masz oczekujący wniosek urlopowy w tym zakresie dat.",
|
||||||
"You have approved vacation request in this range.": "Masz zaakceptowany wniosek urlopowy w tym zakresie dat.",
|
"You have approved vacation request in this range.": "Masz zaakceptowany wniosek urlopowy w tym zakresie dat.",
|
||||||
"You have exceeded your vacation limit.": "Przekroczyłeś/aś limit urlopu.",
|
"Vacation limit has been exceeded.": "Limit urlopu został przekroczony.",
|
||||||
"Vacation needs minimum one day.": "Urlop musi być co najmniej na jeden dzień.",
|
"Vacation needs minimum one day.": "Urlop musi być co najmniej na jeden dzień.",
|
||||||
"The vacation request cannot be created at the turn of the year.": "Wniosek urlopowy nie może zostać złożony na przełomie roku.",
|
"The vacation request cannot be created at the turn of the year.": "Wniosek urlopowy nie może zostać złożony na przełomie roku.",
|
||||||
"User has been created.": "Użytkownik został utworzony.",
|
"User has been created.": "Użytkownik został utworzony.",
|
||||||
|
@ -3,6 +3,7 @@ const defaultTheme = require('tailwindcss/defaultTheme')
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
content: [
|
content: [
|
||||||
'./resources/**/*.vue',
|
'./resources/**/*.vue',
|
||||||
|
'./resources/**/*.js',
|
||||||
],
|
],
|
||||||
theme: {
|
theme: {
|
||||||
extend: {
|
extend: {
|
||||||
|
@ -88,10 +88,10 @@ class UserTest extends FeatureTestCase
|
|||||||
->post("/users", [
|
->post("/users", [
|
||||||
"firstName" => "John",
|
"firstName" => "John",
|
||||||
"lastName" => "Doe",
|
"lastName" => "Doe",
|
||||||
"role" => Role::EMPLOYEE->value,
|
"role" => Role::Employee->value,
|
||||||
"position" => "Test position",
|
"position" => "Test position",
|
||||||
"email" => "john.doe@example.com",
|
"email" => "john.doe@example.com",
|
||||||
"employmentForm" => EmploymentForm::B2B_CONTRACT->value,
|
"employmentForm" => EmploymentForm::B2bContract->value,
|
||||||
"employmentDate" => Carbon::now()->toDateString(),
|
"employmentDate" => Carbon::now()->toDateString(),
|
||||||
])
|
])
|
||||||
->assertSessionHasNoErrors();
|
->assertSessionHasNoErrors();
|
||||||
@ -100,9 +100,9 @@ class UserTest extends FeatureTestCase
|
|||||||
"first_name" => "John",
|
"first_name" => "John",
|
||||||
"last_name" => "Doe",
|
"last_name" => "Doe",
|
||||||
"email" => "john.doe@example.com",
|
"email" => "john.doe@example.com",
|
||||||
"role" => Role::EMPLOYEE->value,
|
"role" => Role::Employee->value,
|
||||||
"position" => "Test position",
|
"position" => "Test position",
|
||||||
"employment_form" => EmploymentForm::B2B_CONTRACT->value,
|
"employment_form" => EmploymentForm::B2bContract->value,
|
||||||
"employment_date" => Carbon::now()->toDateString(),
|
"employment_date" => Carbon::now()->toDateString(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@ -127,9 +127,9 @@ class UserTest extends FeatureTestCase
|
|||||||
"firstName" => "John",
|
"firstName" => "John",
|
||||||
"lastName" => "Doe",
|
"lastName" => "Doe",
|
||||||
"email" => "john.doe@example.com",
|
"email" => "john.doe@example.com",
|
||||||
"role" => Role::EMPLOYEE->value,
|
"role" => Role::Employee->value,
|
||||||
"position" => "Test position",
|
"position" => "Test position",
|
||||||
"employmentForm" => EmploymentForm::B2B_CONTRACT->value,
|
"employmentForm" => EmploymentForm::B2bContract->value,
|
||||||
"employmentDate" => Carbon::now()->toDateString(),
|
"employmentDate" => Carbon::now()->toDateString(),
|
||||||
])
|
])
|
||||||
->assertSessionHasNoErrors();
|
->assertSessionHasNoErrors();
|
||||||
@ -138,9 +138,9 @@ class UserTest extends FeatureTestCase
|
|||||||
"first_name" => "John",
|
"first_name" => "John",
|
||||||
"last_name" => "Doe",
|
"last_name" => "Doe",
|
||||||
"email" => "john.doe@example.com",
|
"email" => "john.doe@example.com",
|
||||||
"role" => Role::EMPLOYEE->value,
|
"role" => Role::Employee->value,
|
||||||
"position" => "Test position",
|
"position" => "Test position",
|
||||||
"employment_form" => EmploymentForm::B2B_CONTRACT->value,
|
"employment_form" => EmploymentForm::B2bContract->value,
|
||||||
"employment_date" => Carbon::now()->toDateString(),
|
"employment_date" => Carbon::now()->toDateString(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ use Toby\Domain\Enums\VacationRequestState;
|
|||||||
use Toby\Domain\Enums\VacationType;
|
use Toby\Domain\Enums\VacationType;
|
||||||
use Toby\Domain\PolishHolidaysRetriever;
|
use Toby\Domain\PolishHolidaysRetriever;
|
||||||
use Toby\Eloquent\Models\User;
|
use Toby\Eloquent\Models\User;
|
||||||
|
use Toby\Eloquent\Models\VacationLimit;
|
||||||
use Toby\Eloquent\Models\VacationRequest;
|
use Toby\Eloquent\Models\VacationRequest;
|
||||||
use Toby\Eloquent\Models\YearPeriod;
|
use Toby\Eloquent\Models\YearPeriod;
|
||||||
|
|
||||||
@ -55,9 +56,16 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
|
|
||||||
$currentYearPeriod = YearPeriod::current();
|
$currentYearPeriod = YearPeriod::current();
|
||||||
|
|
||||||
|
VacationLimit::factory([
|
||||||
|
"days" => 20,
|
||||||
|
])
|
||||||
|
->for($user)
|
||||||
|
->for($currentYearPeriod)
|
||||||
|
->create();
|
||||||
|
|
||||||
$this->actingAs($user)
|
$this->actingAs($user)
|
||||||
->post("/vacation-requests", [
|
->post("/vacation-requests", [
|
||||||
"type" => VacationType::VACATION->value,
|
"type" => VacationType::Vacation->value,
|
||||||
"from" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(),
|
"from" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(),
|
||||||
"to" => Carbon::create($currentYearPeriod->year, 2, 11)->toDateString(),
|
"to" => Carbon::create($currentYearPeriod->year, 2, 11)->toDateString(),
|
||||||
"comment" => "Comment for the vacation request.",
|
"comment" => "Comment for the vacation request.",
|
||||||
@ -68,8 +76,8 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
"user_id" => $user->id,
|
"user_id" => $user->id,
|
||||||
"year_period_id" => $currentYearPeriod->id,
|
"year_period_id" => $currentYearPeriod->id,
|
||||||
"name" => "1/" . $currentYearPeriod->year,
|
"name" => "1/" . $currentYearPeriod->year,
|
||||||
"type" => VacationType::VACATION->value,
|
"type" => VacationType::Vacation->value,
|
||||||
"state" => VacationRequestState::WAITING_FOR_TECHNICAL,
|
"state" => VacationRequestState::WaitingForTechnical,
|
||||||
"from" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(),
|
"from" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(),
|
||||||
"to" => Carbon::create($currentYearPeriod->year, 2, 11)->toDateString(),
|
"to" => Carbon::create($currentYearPeriod->year, 2, 11)->toDateString(),
|
||||||
"comment" => "Comment for the vacation request.",
|
"comment" => "Comment for the vacation request.",
|
||||||
@ -83,8 +91,8 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
$currentYearPeriod = YearPeriod::current();
|
$currentYearPeriod = YearPeriod::current();
|
||||||
|
|
||||||
$vacationRequest = VacationRequest::factory([
|
$vacationRequest = VacationRequest::factory([
|
||||||
"state" => VacationRequestState::WAITING_FOR_TECHNICAL,
|
"state" => VacationRequestState::WaitingForTechnical,
|
||||||
"type" => VacationType::VACATION,
|
"type" => VacationType::Vacation,
|
||||||
])
|
])
|
||||||
->for($user)
|
->for($user)
|
||||||
->for($currentYearPeriod)
|
->for($currentYearPeriod)
|
||||||
@ -95,7 +103,7 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
->assertSessionHasNoErrors();
|
->assertSessionHasNoErrors();
|
||||||
|
|
||||||
$this->assertDatabaseHas("vacation_requests", [
|
$this->assertDatabaseHas("vacation_requests", [
|
||||||
"state" => VacationRequestState::WAITING_FOR_ADMINISTRATIVE,
|
"state" => VacationRequestState::WaitingForAdministrative,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,7 +115,7 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
$currentYearPeriod = YearPeriod::current();
|
$currentYearPeriod = YearPeriod::current();
|
||||||
|
|
||||||
$vacationRequest = VacationRequest::factory([
|
$vacationRequest = VacationRequest::factory([
|
||||||
"state" => VacationRequestState::WAITING_FOR_ADMINISTRATIVE,
|
"state" => VacationRequestState::WaitingForAdministrative,
|
||||||
])
|
])
|
||||||
->for($user)
|
->for($user)
|
||||||
->for($currentYearPeriod)
|
->for($currentYearPeriod)
|
||||||
@ -118,7 +126,7 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
->assertSessionHasNoErrors();
|
->assertSessionHasNoErrors();
|
||||||
|
|
||||||
$this->assertDatabaseHas("vacation_requests", [
|
$this->assertDatabaseHas("vacation_requests", [
|
||||||
"state" => VacationRequestState::APPROVED,
|
"state" => VacationRequestState::Approved,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,9 +136,16 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
$technicalApprover = User::factory()->createQuietly();
|
$technicalApprover = User::factory()->createQuietly();
|
||||||
$currentYearPeriod = YearPeriod::current();
|
$currentYearPeriod = YearPeriod::current();
|
||||||
|
|
||||||
|
$vacationLimit = VacationLimit::factory([
|
||||||
|
"days" => 20,
|
||||||
|
])
|
||||||
|
->for($user)
|
||||||
|
->for($currentYearPeriod)
|
||||||
|
->create();
|
||||||
|
|
||||||
$vacationRequest = VacationRequest::factory([
|
$vacationRequest = VacationRequest::factory([
|
||||||
"state" => VacationRequestState::WAITING_FOR_TECHNICAL,
|
"state" => VacationRequestState::WaitingForTechnical,
|
||||||
"type" => VacationType::VACATION,
|
"type" => VacationType::Vacation,
|
||||||
])
|
])
|
||||||
->for($user)
|
->for($user)
|
||||||
->for($currentYearPeriod)
|
->for($currentYearPeriod)
|
||||||
@ -141,7 +156,31 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
->assertSessionHasNoErrors();
|
->assertSessionHasNoErrors();
|
||||||
|
|
||||||
$this->assertDatabaseHas("vacation_requests", [
|
$this->assertDatabaseHas("vacation_requests", [
|
||||||
"state" => VacationRequestState::REJECTED,
|
"state" => VacationRequestState::Rejected,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testUserCannotCreateVacationRequestIfHeExceedsHisVacationLimit(): void
|
||||||
|
{
|
||||||
|
$user = User::factory()->createQuietly();
|
||||||
|
$currentYearPeriod = YearPeriod::current();
|
||||||
|
|
||||||
|
VacationLimit::factory([
|
||||||
|
"days" => 3,
|
||||||
|
])
|
||||||
|
->for($user)
|
||||||
|
->for($currentYearPeriod)
|
||||||
|
->create();
|
||||||
|
|
||||||
|
$this->actingAs($user)
|
||||||
|
->post("/vacation-requests", [
|
||||||
|
"type" => VacationType::Vacation->value,
|
||||||
|
"from" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(),
|
||||||
|
"to" => Carbon::create($currentYearPeriod->year, 2, 11)->toDateString(),
|
||||||
|
"comment" => "Comment for the vacation request.",
|
||||||
|
])
|
||||||
|
->assertSessionHasErrors([
|
||||||
|
"vacationRequest" => __("Vacation limit has been exceeded."),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,15 +189,22 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
$user = User::factory()->createQuietly();
|
$user = User::factory()->createQuietly();
|
||||||
$currentYearPeriod = YearPeriod::current();
|
$currentYearPeriod = YearPeriod::current();
|
||||||
|
|
||||||
|
VacationLimit::factory([
|
||||||
|
"days" => 20,
|
||||||
|
])
|
||||||
|
->for($user)
|
||||||
|
->for($currentYearPeriod)
|
||||||
|
->create();
|
||||||
|
|
||||||
$this->actingAs($user)
|
$this->actingAs($user)
|
||||||
->post("/vacation-requests", [
|
->post("/vacation-requests", [
|
||||||
"type" => VacationType::VACATION->value,
|
"type" => VacationType::Vacation->value,
|
||||||
"from" => Carbon::create($currentYearPeriod->year, 2, 5)->toDateString(),
|
"from" => Carbon::create($currentYearPeriod->year, 2, 5)->toDateString(),
|
||||||
"to" => Carbon::create($currentYearPeriod->year, 2, 6)->toDateString(),
|
"to" => Carbon::create($currentYearPeriod->year, 2, 6)->toDateString(),
|
||||||
"comment" => "Vacation at weekend.",
|
"comment" => "Vacation at weekend.",
|
||||||
])
|
])
|
||||||
->assertSessionHasErrors([
|
->assertSessionHasErrors([
|
||||||
"vacationRequest" => trans("Vacation needs minimum one day."),
|
"vacationRequest" => __("Vacation needs minimum one day."),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,6 +213,13 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
$user = User::factory()->createQuietly();
|
$user = User::factory()->createQuietly();
|
||||||
$currentYearPeriod = YearPeriod::current();
|
$currentYearPeriod = YearPeriod::current();
|
||||||
|
|
||||||
|
VacationLimit::factory([
|
||||||
|
"days" => 20,
|
||||||
|
])
|
||||||
|
->for($user)
|
||||||
|
->for($currentYearPeriod)
|
||||||
|
->create();
|
||||||
|
|
||||||
foreach ($this->polishHolidaysRetriever->getForYearPeriod($currentYearPeriod) as $holiday) {
|
foreach ($this->polishHolidaysRetriever->getForYearPeriod($currentYearPeriod) as $holiday) {
|
||||||
$currentYearPeriod->holidays()->create([
|
$currentYearPeriod->holidays()->create([
|
||||||
"name" => $holiday["name"],
|
"name" => $holiday["name"],
|
||||||
@ -176,13 +229,13 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
|
|
||||||
$this->actingAs($user)
|
$this->actingAs($user)
|
||||||
->post("/vacation-requests", [
|
->post("/vacation-requests", [
|
||||||
"type" => VacationType::VACATION->value,
|
"type" => VacationType::Vacation->value,
|
||||||
"from" => Carbon::create($currentYearPeriod->year, 4, 18)->toDateString(),
|
"from" => Carbon::create($currentYearPeriod->year, 4, 18)->toDateString(),
|
||||||
"to" => Carbon::create($currentYearPeriod->year, 4, 18)->toDateString(),
|
"to" => Carbon::create($currentYearPeriod->year, 4, 18)->toDateString(),
|
||||||
"comment" => "Vacation at holiday.",
|
"comment" => "Vacation at holiday.",
|
||||||
])
|
])
|
||||||
->assertSessionHasErrors([
|
->assertSessionHasErrors([
|
||||||
"vacationRequest" => trans("Vacation needs minimum one day."),
|
"vacationRequest" => __("Vacation needs minimum one day."),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,9 +244,16 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
$user = User::factory()->createQuietly();
|
$user = User::factory()->createQuietly();
|
||||||
$currentYearPeriod = YearPeriod::current();
|
$currentYearPeriod = YearPeriod::current();
|
||||||
|
|
||||||
|
VacationLimit::factory([
|
||||||
|
"days" => 20,
|
||||||
|
])
|
||||||
|
->for($user)
|
||||||
|
->for($currentYearPeriod)
|
||||||
|
->create();
|
||||||
|
|
||||||
VacationRequest::factory([
|
VacationRequest::factory([
|
||||||
"type" => VacationType::VACATION->value,
|
"type" => VacationType::Vacation->value,
|
||||||
"state" => VacationRequestState::WAITING_FOR_TECHNICAL,
|
"state" => VacationRequestState::WaitingForTechnical,
|
||||||
"from" => Carbon::create($currentYearPeriod->year, 2, 1)->toDateString(),
|
"from" => Carbon::create($currentYearPeriod->year, 2, 1)->toDateString(),
|
||||||
"to" => Carbon::create($currentYearPeriod->year, 2, 4)->toDateString(),
|
"to" => Carbon::create($currentYearPeriod->year, 2, 4)->toDateString(),
|
||||||
"comment" => "Comment for the vacation request.",
|
"comment" => "Comment for the vacation request.",
|
||||||
@ -204,14 +264,15 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
|
|
||||||
$this->actingAs($user)
|
$this->actingAs($user)
|
||||||
->post("/vacation-requests", [
|
->post("/vacation-requests", [
|
||||||
"type" => VacationType::VACATION->value,
|
"type" => VacationType::Vacation->value,
|
||||||
"from" => Carbon::create($currentYearPeriod->year, 2, 1)->toDateString(),
|
"from" => Carbon::create($currentYearPeriod->year, 2, 1)->toDateString(),
|
||||||
"to" => Carbon::create($currentYearPeriod->year, 2, 4)->toDateString(),
|
"to" => Carbon::create($currentYearPeriod->year, 2, 4)->toDateString(),
|
||||||
"comment" => "Another comment for the another vacation request.",
|
"comment" => "Another comment for the another vacation request.",
|
||||||
])
|
])
|
||||||
->assertSessionHasErrors([
|
->assertSessionHasErrors([
|
||||||
"vacationRequest" => trans("You have pending vacation request in this range."),
|
"vacationRequest" => __("You have pending vacation request in this range."),
|
||||||
]);
|
])
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testUserCannotCreateVacationRequestIfHeHasApprovedVacationRequestInThisRange(): void
|
public function testUserCannotCreateVacationRequestIfHeHasApprovedVacationRequestInThisRange(): void
|
||||||
@ -219,9 +280,16 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
$user = User::factory()->createQuietly();
|
$user = User::factory()->createQuietly();
|
||||||
$currentYearPeriod = YearPeriod::current();
|
$currentYearPeriod = YearPeriod::current();
|
||||||
|
|
||||||
|
$vacationLimit = VacationLimit::factory([
|
||||||
|
"days" => 20,
|
||||||
|
])
|
||||||
|
->for($user)
|
||||||
|
->for($currentYearPeriod)
|
||||||
|
->create();
|
||||||
|
|
||||||
VacationRequest::factory([
|
VacationRequest::factory([
|
||||||
"type" => VacationType::VACATION->value,
|
"type" => VacationType::Vacation->value,
|
||||||
"state" => VacationRequestState::APPROVED,
|
"state" => VacationRequestState::Approved,
|
||||||
"from" => Carbon::create($currentYearPeriod->year, 2, 2)->toDateString(),
|
"from" => Carbon::create($currentYearPeriod->year, 2, 2)->toDateString(),
|
||||||
"to" => Carbon::create($currentYearPeriod->year, 2, 4)->toDateString(),
|
"to" => Carbon::create($currentYearPeriod->year, 2, 4)->toDateString(),
|
||||||
"comment" => "Comment for the vacation request.",
|
"comment" => "Comment for the vacation request.",
|
||||||
@ -232,13 +300,13 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
|
|
||||||
$this->actingAs($user)
|
$this->actingAs($user)
|
||||||
->post("/vacation-requests", [
|
->post("/vacation-requests", [
|
||||||
"type" => VacationType::VACATION->value,
|
"type" => VacationType::Vacation->value,
|
||||||
"from" => Carbon::create($currentYearPeriod->year, 2, 1)->toDateString(),
|
"from" => Carbon::create($currentYearPeriod->year, 2, 1)->toDateString(),
|
||||||
"to" => Carbon::create($currentYearPeriod->year, 2, 4)->toDateString(),
|
"to" => Carbon::create($currentYearPeriod->year, 2, 4)->toDateString(),
|
||||||
"comment" => "Another comment for the another vacation request.",
|
"comment" => "Another comment for the another vacation request.",
|
||||||
])
|
])
|
||||||
->assertSessionHasErrors([
|
->assertSessionHasErrors([
|
||||||
"vacationRequest" => trans("You have approved vacation request in this range."),
|
"vacationRequest" => __("You have approved vacation request in this range."),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,13 +316,13 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
$currentYearPeriod = YearPeriod::current();
|
$currentYearPeriod = YearPeriod::current();
|
||||||
$this->actingAs($user)
|
$this->actingAs($user)
|
||||||
->post("/vacation-requests", [
|
->post("/vacation-requests", [
|
||||||
"type" => VacationType::VACATION->value,
|
"type" => VacationType::Vacation->value,
|
||||||
"from" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(),
|
"from" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(),
|
||||||
"to" => Carbon::create($currentYearPeriod->year, 2, 6)->toDateString(),
|
"to" => Carbon::create($currentYearPeriod->year, 2, 6)->toDateString(),
|
||||||
"comment" => "Comment for the vacation request.",
|
"comment" => "Comment for the vacation request.",
|
||||||
])
|
])
|
||||||
->assertSessionHasErrors([
|
->assertSessionHasErrors([
|
||||||
"vacationRequest" => trans("Vacation needs minimum one day."),
|
"vacationRequest" => __("Vacation needs minimum one day."),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -265,13 +333,13 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
$nextYearPeriod = $this->createYearPeriod(Carbon::now()->year + 1);
|
$nextYearPeriod = $this->createYearPeriod(Carbon::now()->year + 1);
|
||||||
$this->actingAs($user)
|
$this->actingAs($user)
|
||||||
->post("/vacation-requests", [
|
->post("/vacation-requests", [
|
||||||
"type" => VacationType::VACATION->value,
|
"type" => VacationType::Vacation->value,
|
||||||
"from" => Carbon::create($currentYearPeriod->year, 12, 27)->toDateString(),
|
"from" => Carbon::create($currentYearPeriod->year, 12, 27)->toDateString(),
|
||||||
"to" => Carbon::create($nextYearPeriod->year, 1, 2)->toDateString(),
|
"to" => Carbon::create($nextYearPeriod->year, 1, 2)->toDateString(),
|
||||||
"comment" => "Comment for the vacation request.",
|
"comment" => "Comment for the vacation request.",
|
||||||
])
|
])
|
||||||
->assertSessionHasErrors([
|
->assertSessionHasErrors([
|
||||||
"vacationRequest" => trans("The vacation request cannot be created at the turn of the year."),
|
"vacationRequest" => __("The vacation request cannot be created at the turn of the year."),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,8 +39,8 @@ class VacationRequestStatesTest extends TestCase
|
|||||||
|
|
||||||
/** @var VacationRequest $vacationRequest */
|
/** @var VacationRequest $vacationRequest */
|
||||||
$vacationRequest = VacationRequest::factory([
|
$vacationRequest = VacationRequest::factory([
|
||||||
"type" => VacationType::VACATION->value,
|
"type" => VacationType::Vacation->value,
|
||||||
"state" => VacationRequestState::CREATED,
|
"state" => VacationRequestState::Created,
|
||||||
"from" => Carbon::create($currentYearPeriod->year, 2, 1)->toDateString(),
|
"from" => Carbon::create($currentYearPeriod->year, 2, 1)->toDateString(),
|
||||||
"to" => Carbon::create($currentYearPeriod->year, 2, 4)->toDateString(),
|
"to" => Carbon::create($currentYearPeriod->year, 2, 4)->toDateString(),
|
||||||
"comment" => "Comment for the vacation request.",
|
"comment" => "Comment for the vacation request.",
|
||||||
@ -51,7 +51,7 @@ class VacationRequestStatesTest extends TestCase
|
|||||||
|
|
||||||
$this->stateManager->waitForTechnical($vacationRequest);
|
$this->stateManager->waitForTechnical($vacationRequest);
|
||||||
|
|
||||||
$this->assertEquals(VacationRequestState::WAITING_FOR_TECHNICAL, $vacationRequest->state);
|
$this->assertEquals(VacationRequestState::WaitingForTechnical, $vacationRequest->state);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAfterCreatingVacationRequestOfTypeSickVacationItTransitsToProperState(): void
|
public function testAfterCreatingVacationRequestOfTypeSickVacationItTransitsToProperState(): void
|
||||||
@ -62,8 +62,8 @@ class VacationRequestStatesTest extends TestCase
|
|||||||
|
|
||||||
/** @var VacationRequest $vacationRequest */
|
/** @var VacationRequest $vacationRequest */
|
||||||
$vacationRequest = VacationRequest::factory([
|
$vacationRequest = VacationRequest::factory([
|
||||||
"type" => VacationType::SICK_VACATION->value,
|
"type" => VacationType::Sick->value,
|
||||||
"state" => VacationRequestState::CREATED,
|
"state" => VacationRequestState::Created,
|
||||||
"from" => Carbon::create($currentYearPeriod->year, 2, 1)->toDateString(),
|
"from" => Carbon::create($currentYearPeriod->year, 2, 1)->toDateString(),
|
||||||
"to" => Carbon::create($currentYearPeriod->year, 2, 4)->toDateString(),
|
"to" => Carbon::create($currentYearPeriod->year, 2, 4)->toDateString(),
|
||||||
])
|
])
|
||||||
@ -73,7 +73,7 @@ class VacationRequestStatesTest extends TestCase
|
|||||||
|
|
||||||
$this->stateManager->approve($vacationRequest);
|
$this->stateManager->approve($vacationRequest);
|
||||||
|
|
||||||
$this->assertEquals(VacationRequestState::APPROVED, $vacationRequest->state);
|
$this->assertEquals(VacationRequestState::Approved, $vacationRequest->state);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAfterCreatingVacationRequestOfTypeTimeInLieuItTransitsToProperState(): void
|
public function testAfterCreatingVacationRequestOfTypeTimeInLieuItTransitsToProperState(): void
|
||||||
@ -84,8 +84,8 @@ class VacationRequestStatesTest extends TestCase
|
|||||||
|
|
||||||
/** @var VacationRequest $vacationRequest */
|
/** @var VacationRequest $vacationRequest */
|
||||||
$vacationRequest = VacationRequest::factory([
|
$vacationRequest = VacationRequest::factory([
|
||||||
"type" => VacationType::TIME_IN_LIEU->value,
|
"type" => VacationType::TimeInLieu->value,
|
||||||
"state" => VacationRequestState::CREATED,
|
"state" => VacationRequestState::Created,
|
||||||
"from" => Carbon::create($currentYearPeriod->year, 2, 2)->toDateString(),
|
"from" => Carbon::create($currentYearPeriod->year, 2, 2)->toDateString(),
|
||||||
"to" => Carbon::create($currentYearPeriod->year, 2, 2)->toDateString(),
|
"to" => Carbon::create($currentYearPeriod->year, 2, 2)->toDateString(),
|
||||||
])
|
])
|
||||||
@ -95,6 +95,6 @@ class VacationRequestStatesTest extends TestCase
|
|||||||
|
|
||||||
$this->stateManager->approve($vacationRequest);
|
$this->stateManager->approve($vacationRequest);
|
||||||
|
|
||||||
$this->assertEquals(VacationRequestState::APPROVED, $vacationRequest->state);
|
$this->assertEquals(VacationRequestState::Approved, $vacationRequest->state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
const mix = require('laravel-mix');
|
const mix = require('laravel-mix')
|
||||||
const webpackConfig = require('./webpack.config');
|
const webpackConfig = require('./webpack.config')
|
||||||
|
|
||||||
mix.js("resources/js/app.js", "public/js")
|
mix.js('resources/js/app.js', 'public/js')
|
||||||
.vue(3)
|
.vue(3)
|
||||||
.postCss("resources/css/app.css", "public/css", [
|
.postCss('resources/css/app.css', 'public/css', [
|
||||||
require("tailwindcss"),
|
require('tailwindcss'),
|
||||||
])
|
])
|
||||||
.webpackConfig(webpackConfig)
|
.webpackConfig(webpackConfig)
|
||||||
.sourceMaps();
|
.sourceMaps()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user