- small changes (#98)
* - added some test * - cr fix * wip * wip * Update resources/js/Shared/MainMenu.vue Co-authored-by: Ewelina Lasowy <56546832+EwelinaLasowy@users.noreply.github.com> * fix Co-authored-by: EwelinaLasowy <ewelina.lasowy@blumilk.pl> Co-authored-by: Ewelina Lasowy <56546832+EwelinaLasowy@users.noreply.github.com>
This commit is contained in:
parent
ab16af1ca9
commit
08421b8a69
@ -6,15 +6,12 @@ namespace Toby\Architecture\Providers;
|
|||||||
|
|
||||||
use Illuminate\Support\ServiceProvider;
|
use Illuminate\Support\ServiceProvider;
|
||||||
use Toby\Eloquent\Models\User;
|
use Toby\Eloquent\Models\User;
|
||||||
use Toby\Eloquent\Models\YearPeriod;
|
|
||||||
use Toby\Eloquent\Observers\UserObserver;
|
use Toby\Eloquent\Observers\UserObserver;
|
||||||
use Toby\Eloquent\Observers\YearPeriodObserver;
|
|
||||||
|
|
||||||
class ObserverServiceProvider extends ServiceProvider
|
class ObserverServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
public function boot(): void
|
public function boot(): void
|
||||||
{
|
{
|
||||||
User::observe(UserObserver::class);
|
User::observe(UserObserver::class);
|
||||||
YearPeriod::observe(YearPeriodObserver::class);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
33
app/Domain/Actions/CreateUserAction.php
Normal file
33
app/Domain/Actions/CreateUserAction.php
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Toby\Domain\Actions;
|
||||||
|
|
||||||
|
use Toby\Eloquent\Models\User;
|
||||||
|
use Toby\Eloquent\Models\YearPeriod;
|
||||||
|
|
||||||
|
class CreateUserAction
|
||||||
|
{
|
||||||
|
public function execute(array $data): User
|
||||||
|
{
|
||||||
|
$user = new User($data);
|
||||||
|
|
||||||
|
$user->save();
|
||||||
|
|
||||||
|
$this->createVacationLimitsFor($user);
|
||||||
|
|
||||||
|
return $user;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function createVacationLimitsFor(User $user): void
|
||||||
|
{
|
||||||
|
$yearPeriods = YearPeriod::all();
|
||||||
|
|
||||||
|
foreach ($yearPeriods as $yearPeriod) {
|
||||||
|
$user->vacationLimits()->create([
|
||||||
|
"year_period_id" => $yearPeriod->id,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -2,22 +2,30 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Toby\Eloquent\Observers;
|
namespace Toby\Domain\Actions;
|
||||||
|
|
||||||
use Toby\Domain\PolishHolidaysRetriever;
|
use Toby\Domain\PolishHolidaysRetriever;
|
||||||
use Toby\Eloquent\Models\User;
|
use Toby\Eloquent\Models\User;
|
||||||
use Toby\Eloquent\Models\YearPeriod;
|
use Toby\Eloquent\Models\YearPeriod;
|
||||||
|
|
||||||
class YearPeriodObserver
|
class CreateYearPeriodAction
|
||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
protected PolishHolidaysRetriever $polishHolidaysRetriever,
|
protected PolishHolidaysRetriever $polishHolidaysRetriever,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
public function created(YearPeriod $yearPeriod): void
|
public function execute(int $year): YearPeriod
|
||||||
{
|
{
|
||||||
|
$yearPeriod = new YearPeriod([
|
||||||
|
"year" => $year,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$yearPeriod->save();
|
||||||
|
|
||||||
$this->createVacationLimitsFor($yearPeriod);
|
$this->createVacationLimitsFor($yearPeriod);
|
||||||
$this->createHolidaysFor($yearPeriod);
|
$this->createHolidaysFor($yearPeriod);
|
||||||
|
|
||||||
|
return $yearPeriod;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function createVacationLimitsFor(YearPeriod $yearPeriod): void
|
protected function createVacationLimitsFor(YearPeriod $yearPeriod): void
|
@ -5,7 +5,6 @@ declare(strict_types=1);
|
|||||||
namespace Toby\Domain;
|
namespace Toby\Domain;
|
||||||
|
|
||||||
use Carbon\CarbonPeriod;
|
use Carbon\CarbonPeriod;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Toby\Eloquent\Helpers\YearPeriodRetriever;
|
use Toby\Eloquent\Helpers\YearPeriodRetriever;
|
||||||
@ -55,7 +54,7 @@ class CalendarGenerator
|
|||||||
{
|
{
|
||||||
return Vacation::query()
|
return Vacation::query()
|
||||||
->whereBetween("date", [$period->start, $period->end])
|
->whereBetween("date", [$period->start, $period->end])
|
||||||
->whereRelation("vacationRequest", fn(Builder $query) => $query->states(VacationRequestStatesRetriever::successStates()))
|
->approved()
|
||||||
->with("vacationRequest")
|
->with("vacationRequest")
|
||||||
->get()
|
->get()
|
||||||
->groupBy(fn(Vacation $vacation) => $vacation->date->toDateString());
|
->groupBy(fn(Vacation $vacation) => $vacation->date->toDateString());
|
||||||
|
@ -25,7 +25,6 @@ use PhpOffice\PhpSpreadsheet\Style\Fill;
|
|||||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||||
use Toby\Domain\Enums\VacationType;
|
use Toby\Domain\Enums\VacationType;
|
||||||
use Toby\Domain\States\VacationRequest\Approved;
|
|
||||||
use Toby\Eloquent\Models\Holiday;
|
use Toby\Eloquent\Models\Holiday;
|
||||||
use Toby\Eloquent\Models\User;
|
use Toby\Eloquent\Models\User;
|
||||||
use Toby\Eloquent\Models\Vacation;
|
use Toby\Eloquent\Models\Vacation;
|
||||||
@ -189,7 +188,7 @@ class TimesheetPerUserSheet implements WithTitle, WithHeadings, WithEvents, With
|
|||||||
return $user->vacations()
|
return $user->vacations()
|
||||||
->with("vacationRequest")
|
->with("vacationRequest")
|
||||||
->whereBetween("date", [$period->start, $period->end])
|
->whereBetween("date", [$period->start, $period->end])
|
||||||
->whereRelation("vacationRequest", "state", Approved::$name)
|
->approved()
|
||||||
->get()
|
->get()
|
||||||
->groupBy(
|
->groupBy(
|
||||||
[
|
[
|
||||||
|
@ -88,7 +88,7 @@ class UserVacationStatsRetriever
|
|||||||
$limit = $user->vacationLimits()
|
$limit = $user->vacationLimits()
|
||||||
->where("year_period_id", $yearPeriod->id)
|
->where("year_period_id", $yearPeriod->id)
|
||||||
->first()
|
->first()
|
||||||
->days;
|
?->days;
|
||||||
|
|
||||||
return $limit ?? 0;
|
return $limit ?? 0;
|
||||||
}
|
}
|
||||||
|
@ -30,13 +30,15 @@ class YearPeriodRetriever
|
|||||||
|
|
||||||
public function links(): array
|
public function links(): array
|
||||||
{
|
{
|
||||||
$current = $this->selected();
|
$selected = $this->selected();
|
||||||
|
$current = $this->current();
|
||||||
|
|
||||||
$years = YearPeriod::query()->whereIn("year", $this->offset($current->year))->get();
|
$years = YearPeriod::query()->whereIn("year", $this->offset($selected->year))->get();
|
||||||
$navigation = $years->map(fn(YearPeriod $yearPeriod) => $this->toNavigation($yearPeriod));
|
$navigation = $years->map(fn(YearPeriod $yearPeriod) => $this->toNavigation($yearPeriod));
|
||||||
|
|
||||||
return [
|
return [
|
||||||
"current" => $current->year,
|
"current" => $this->toNavigation($current),
|
||||||
|
"selected" => $this->toNavigation($selected),
|
||||||
"navigation" => $navigation->toArray(),
|
"navigation" => $navigation->toArray(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -71,18 +71,6 @@ class User extends Authenticatable
|
|||||||
return $this->hasMany(Vacation::class);
|
return $this->hasMany(Vacation::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function scopeSearch(Builder $query, ?string $text): Builder
|
|
||||||
{
|
|
||||||
if ($text === null) {
|
|
||||||
return $query;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $query
|
|
||||||
->where("first_name", "ILIKE", $text)
|
|
||||||
->orWhere("last_name", "ILIKE", $text)
|
|
||||||
->orWhere("email", "ILIKE", $text);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getAvatar(): string
|
public function getAvatar(): string
|
||||||
{
|
{
|
||||||
return $this->getAvatarGenerator()
|
return $this->getAvatarGenerator()
|
||||||
@ -108,6 +96,28 @@ class User extends Authenticatable
|
|||||||
->exists();
|
->exists();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function scopeSearch(Builder $query, ?string $text): Builder
|
||||||
|
{
|
||||||
|
if ($text === null) {
|
||||||
|
return $query;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $query
|
||||||
|
->where("first_name", "ILIKE", $text)
|
||||||
|
->orWhere("last_name", "ILIKE", $text)
|
||||||
|
->orWhere("email", "ILIKE", $text);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function scopeWithVacationLimitIn(Builder $query, YearPeriod $yearPeriod): Builder
|
||||||
|
{
|
||||||
|
return $query->whereRelation(
|
||||||
|
"vacationlimits",
|
||||||
|
fn(Builder $query) => $query
|
||||||
|
->where("year_period_id", $yearPeriod->id)
|
||||||
|
->whereNotNull("days"),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
protected function getAvatarName(): string
|
protected function getAvatarName(): string
|
||||||
{
|
{
|
||||||
return mb_substr($this->first_name, 0, 1) . mb_substr($this->last_name, 0, 1);
|
return mb_substr($this->first_name, 0, 1) . mb_substr($this->last_name, 0, 1);
|
||||||
|
@ -4,10 +4,12 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Toby\Eloquent\Models;
|
namespace Toby\Eloquent\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
|
use Toby\Domain\VacationRequestStatesRetriever;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property int $id
|
* @property int $id
|
||||||
@ -40,4 +42,12 @@ class Vacation extends Model
|
|||||||
{
|
{
|
||||||
return $this->belongsTo(YearPeriod::class);
|
return $this->belongsTo(YearPeriod::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function scopeApproved(Builder $query): Builder
|
||||||
|
{
|
||||||
|
return $query->whereRelation(
|
||||||
|
"vacationRequest",
|
||||||
|
fn(Builder $query) => $query->states(VacationRequestStatesRetriever::successStates()),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@ namespace Toby\Eloquent\Observers;
|
|||||||
use Illuminate\Contracts\Hashing\Hasher;
|
use Illuminate\Contracts\Hashing\Hasher;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use Toby\Eloquent\Models\User;
|
use Toby\Eloquent\Models\User;
|
||||||
use Toby\Eloquent\Models\YearPeriod;
|
|
||||||
|
|
||||||
class UserObserver
|
class UserObserver
|
||||||
{
|
{
|
||||||
@ -23,15 +22,4 @@ class UserObserver
|
|||||||
*/
|
*/
|
||||||
$user->password = $this->hash->make(Str::random(40));
|
$user->password = $this->hash->make(Str::random(40));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function created(User $user): void
|
|
||||||
{
|
|
||||||
$yearPeriods = YearPeriod::all();
|
|
||||||
|
|
||||||
foreach ($yearPeriods as $yearPeriod) {
|
|
||||||
$user->vacationLimits()->create([
|
|
||||||
"year_period_id" => $yearPeriod->id,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Toby\Infrastructure\Http\Controllers;
|
namespace Toby\Infrastructure\Http\Controllers;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
use Inertia\Response;
|
use Inertia\Response;
|
||||||
@ -29,10 +28,7 @@ class DashboardController extends Controller
|
|||||||
$absences = Vacation::query()
|
$absences = Vacation::query()
|
||||||
->with(["user", "vacationRequest"])
|
->with(["user", "vacationRequest"])
|
||||||
->whereDate("date", $now)
|
->whereDate("date", $now)
|
||||||
->whereRelation(
|
->approved()
|
||||||
"vacationRequest",
|
|
||||||
fn(Builder $query) => $query->states(VacationRequestStatesRetriever::successStates()),
|
|
||||||
)
|
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
if ($user->can("listAll", VacationRequest::class)) {
|
if ($user->can("listAll", VacationRequest::class)) {
|
||||||
|
@ -36,6 +36,6 @@ class GoogleController extends Controller
|
|||||||
|
|
||||||
$auth->guard()->login($user, true);
|
$auth->guard()->login($user, true);
|
||||||
|
|
||||||
return redirect()->route("dashboard");
|
return redirect()->intended();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Toby\Infrastructure\Http\Controllers;
|
namespace Toby\Infrastructure\Http\Controllers;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Inertia\Response;
|
use Inertia\Response;
|
||||||
use Toby\Domain\Enums\Month;
|
use Toby\Domain\Enums\Month;
|
||||||
@ -26,10 +25,7 @@ class MonthlyUsageController extends Controller
|
|||||||
$currentUser = $request->user();
|
$currentUser = $request->user();
|
||||||
|
|
||||||
$users = User::query()
|
$users = User::query()
|
||||||
->whereRelation(
|
->withVacationLimitIn($currentYearPeriod)
|
||||||
"vacationlimits",
|
|
||||||
fn(Builder $query) => $query->where("year_period_id", $currentYearPeriod->id)->whereNotNull("days"),
|
|
||||||
)
|
|
||||||
->where("id", "!=", $currentUser->id)
|
->where("id", "!=", $currentUser->id)
|
||||||
->orderBy("last_name")
|
->orderBy("last_name")
|
||||||
->orderBy("first_name")
|
->orderBy("first_name")
|
||||||
|
@ -8,6 +8,7 @@ use Illuminate\Auth\Access\AuthorizationException;
|
|||||||
use Illuminate\Http\RedirectResponse;
|
use Illuminate\Http\RedirectResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Inertia\Response;
|
use Inertia\Response;
|
||||||
|
use Toby\Domain\Actions\CreateUserAction;
|
||||||
use Toby\Domain\Enums\EmploymentForm;
|
use Toby\Domain\Enums\EmploymentForm;
|
||||||
use Toby\Domain\Enums\Role;
|
use Toby\Domain\Enums\Role;
|
||||||
use Toby\Eloquent\Models\User;
|
use Toby\Eloquent\Models\User;
|
||||||
@ -54,11 +55,11 @@ class UserController extends Controller
|
|||||||
/**
|
/**
|
||||||
* @throws AuthorizationException
|
* @throws AuthorizationException
|
||||||
*/
|
*/
|
||||||
public function store(UserRequest $request): RedirectResponse
|
public function store(UserRequest $request, CreateUserAction $createUserAction): RedirectResponse
|
||||||
{
|
{
|
||||||
$this->authorize("manageUsers");
|
$this->authorize("manageUsers");
|
||||||
|
|
||||||
User::query()->create($request->data());
|
$createUserAction->execute($request->data());
|
||||||
|
|
||||||
return redirect()
|
return redirect()
|
||||||
->route("users.index")
|
->route("users.index")
|
||||||
|
@ -103,10 +103,7 @@ class VacationRequestController extends Controller
|
|||||||
->paginate();
|
->paginate();
|
||||||
|
|
||||||
$users = User::query()
|
$users = User::query()
|
||||||
->whereRelation(
|
->withVacationLimitIn($yearPeriod)
|
||||||
"vacationlimits",
|
|
||||||
fn(Builder $query) => $query->where("year_period_id", $yearPeriod->id)->whereNotNull("days"),
|
|
||||||
)
|
|
||||||
->orderBy("last_name")
|
->orderBy("last_name")
|
||||||
->orderBy("first_name")
|
->orderBy("first_name")
|
||||||
->get();
|
->get();
|
||||||
@ -164,10 +161,7 @@ class VacationRequestController extends Controller
|
|||||||
$yearPeriod = $yearPeriodRetriever->selected();
|
$yearPeriod = $yearPeriodRetriever->selected();
|
||||||
|
|
||||||
$users = User::query()
|
$users = User::query()
|
||||||
->whereRelation(
|
->withVacationLimitIn($yearPeriod)
|
||||||
"vacationlimits",
|
|
||||||
fn(Builder $query) => $query->where("year_period_id", $yearPeriod->id)->whereNotNull("days"),
|
|
||||||
)
|
|
||||||
->orderBy("last_name")
|
->orderBy("last_name")
|
||||||
->orderBy("first_name")
|
->orderBy("first_name")
|
||||||
->get();
|
->get();
|
||||||
|
@ -8,6 +8,7 @@ use Illuminate\Bus\Queueable;
|
|||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
|
use Toby\Domain\Actions\CreateYearPeriodAction;
|
||||||
use Toby\Eloquent\Models\YearPeriod;
|
use Toby\Eloquent\Models\YearPeriod;
|
||||||
|
|
||||||
class CheckYearPeriod implements ShouldQueue
|
class CheckYearPeriod implements ShouldQueue
|
||||||
@ -15,30 +16,17 @@ class CheckYearPeriod implements ShouldQueue
|
|||||||
use Dispatchable;
|
use Dispatchable;
|
||||||
use Queueable;
|
use Queueable;
|
||||||
|
|
||||||
public function handle(): void
|
public function handle(CreateYearPeriodAction $createYearPeriodAction): void
|
||||||
{
|
{
|
||||||
$currentYearPeriod = YearPeriod::current();
|
$currentYearPeriod = YearPeriod::current();
|
||||||
|
$now = Carbon::now();
|
||||||
|
|
||||||
if ($currentYearPeriod === null) {
|
if ($currentYearPeriod === null) {
|
||||||
$this->createCurrentYearPeriod();
|
$createYearPeriodAction->execute($now->year);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (YearPeriod::query()->max("year") === Carbon::now()->year) {
|
if (YearPeriod::query()->max("year") === $now->year) {
|
||||||
$this->createNextYearPeriod();
|
$createYearPeriodAction->execute($now->year + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function createCurrentYearPeriod(): void
|
|
||||||
{
|
|
||||||
YearPeriod::query()->create([
|
|
||||||
"year" => Carbon::now()->year,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function createNextYearPeriod(): void
|
|
||||||
{
|
|
||||||
YearPeriod::query()->create([
|
|
||||||
"year" => Carbon::now()->year + 1,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -17,10 +17,6 @@ class DatabaseSeeder extends Seeder
|
|||||||
{
|
{
|
||||||
public function run(): void
|
public function run(): void
|
||||||
{
|
{
|
||||||
User::unsetEventDispatcher();
|
|
||||||
YearPeriod::unsetEventDispatcher();
|
|
||||||
VacationRequest::unsetEventDispatcher();
|
|
||||||
|
|
||||||
User::factory(9)->create();
|
User::factory(9)->create();
|
||||||
User::factory([
|
User::factory([
|
||||||
"email" => env("LOCAL_EMAIL_FOR_LOGIN_VIA_GOOGLE"),
|
"email" => env("LOCAL_EMAIL_FOR_LOGIN_VIA_GOOGLE"),
|
||||||
|
@ -29,10 +29,6 @@ class DemoSeeder extends Seeder
|
|||||||
{
|
{
|
||||||
public function run(): void
|
public function run(): void
|
||||||
{
|
{
|
||||||
User::unsetEventDispatcher();
|
|
||||||
YearPeriod::unsetEventDispatcher();
|
|
||||||
VacationRequest::unsetEventDispatcher();
|
|
||||||
|
|
||||||
$user = User::factory([
|
$user = User::factory([
|
||||||
"first_name" => "Jan",
|
"first_name" => "Jan",
|
||||||
"last_name" => "Kowalski",
|
"last_name" => "Kowalski",
|
||||||
|
@ -2,8 +2,8 @@ import { computed } from 'vue'
|
|||||||
import { usePage } from '@inertiajs/inertia-vue3'
|
import { usePage } from '@inertiajs/inertia-vue3'
|
||||||
|
|
||||||
export default function useCurrentYearPeriodInfo() {
|
export default function useCurrentYearPeriodInfo() {
|
||||||
const minDate = computed(() => new Date(usePage().props.value.years.current, 0, 1))
|
const minDate = computed(() => new Date(usePage().props.value.years.selected.year, 0, 1))
|
||||||
const maxDate = computed(() => new Date(usePage().props.value.years.current, 11, 31))
|
const maxDate = computed(() => new Date(usePage().props.value.years.selected.year, 11, 31))
|
||||||
|
|
||||||
return {
|
return {
|
||||||
minDate,
|
minDate,
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
<InertiaLink
|
<InertiaLink
|
||||||
v-if="previousMonth"
|
v-if="previousMonth"
|
||||||
as="button"
|
as="button"
|
||||||
:href="`/vacation-calendar/${previousMonth.value}`"
|
:href="`/vacation/calendar/${previousMonth.value}`"
|
||||||
class="flex items-center justify-center rounded-l-md border border-r-0 border-gray-300 bg-white py-2 pl-3 pr-4 text-gray-400 hover:text-gray-500 focus:relative md:w-9 md:px-2 md:hover:bg-gray-50"
|
class="flex items-center justify-center rounded-l-md border border-r-0 border-gray-300 bg-white py-2 pl-3 pr-4 text-gray-400 hover:text-gray-500 focus:relative md:w-9 md:px-2 md:hover:bg-gray-50"
|
||||||
>
|
>
|
||||||
<ChevronLeftIcon class="h-5 w-5" />
|
<ChevronLeftIcon class="h-5 w-5" />
|
||||||
@ -23,7 +23,7 @@
|
|||||||
</span>
|
</span>
|
||||||
<InertiaLink
|
<InertiaLink
|
||||||
as="button"
|
as="button"
|
||||||
:href="`/vacation-calendar/${currentMonth.value}`"
|
:href="`/vacation/calendar/${currentMonth.value}`"
|
||||||
class="hidden border-t border-b border-gray-300 bg-white px-3.5 text-sm font-medium flex items-center text-gray-700 hover:bg-gray-50 hover:text-gray-900 focus:relative md:block"
|
class="hidden border-t border-b border-gray-300 bg-white px-3.5 text-sm font-medium flex items-center text-gray-700 hover:bg-gray-50 hover:text-gray-900 focus:relative md:block"
|
||||||
>
|
>
|
||||||
Dzisiaj
|
Dzisiaj
|
||||||
@ -31,7 +31,7 @@
|
|||||||
<InertiaLink
|
<InertiaLink
|
||||||
v-if="nextMonth"
|
v-if="nextMonth"
|
||||||
as="button"
|
as="button"
|
||||||
:href="`/vacation-calendar/${nextMonth.value}`"
|
:href="`/vacation/calendar/${nextMonth.value}`"
|
||||||
class="flex items-center justify-center rounded-r-md border border-l-0 border-gray-300 bg-white py-2 pl-4 pr-3 text-gray-400 hover:text-gray-500 focus:relative md:w-9 md:px-2 md:hover:bg-gray-50"
|
class="flex items-center justify-center rounded-r-md border border-l-0 border-gray-300 bg-white py-2 pl-4 pr-3 text-gray-400 hover:text-gray-500 focus:relative md:w-9 md:px-2 md:hover:bg-gray-50"
|
||||||
>
|
>
|
||||||
<ChevronRightIcon class="h-5 w-5" />
|
<ChevronRightIcon class="h-5 w-5" />
|
||||||
@ -46,7 +46,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div v-if="can.generateTimesheet">
|
<div v-if="can.generateTimesheet">
|
||||||
<a
|
<a
|
||||||
:href="`/timesheet/${selectedMonth.value}`"
|
:href="`/vacation/timesheet/${selectedMonth.value}`"
|
||||||
class="inline-flex items-center px-4 py-3 border border-transparent text-sm leading-4 font-medium rounded-md shadow-sm text-white bg-blumilk-600 hover:bg-blumilk-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blumilk-500"
|
class="inline-flex items-center px-4 py-3 border border-transparent text-sm leading-4 font-medium rounded-md shadow-sm text-white bg-blumilk-600 hover:bg-blumilk-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blumilk-500"
|
||||||
>
|
>
|
||||||
Pobierz plik Excel
|
Pobierz plik Excel
|
||||||
@ -59,13 +59,13 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th class="w-64 py-2 border text-lg font-semibold text-gray-800 border-gray-300">
|
<th class="w-64 py-2 border text-lg font-semibold text-gray-800 border-gray-300">
|
||||||
<div class="flex justify-center items-center">
|
<div class="flex justify-center items-center">
|
||||||
{{ selectedMonth.name }} {{ years.current }}
|
{{ selectedMonth.name }} {{ years.selected.year }}
|
||||||
</div>
|
</div>
|
||||||
</th>
|
</th>
|
||||||
<th
|
<th
|
||||||
v-for="day in calendar"
|
v-for="day in calendar"
|
||||||
:key="day.dayOfMonth"
|
:key="day.dayOfMonth"
|
||||||
class="border border-gray-300 text-lg font-semibold text-gray-900 py-4 px-2"
|
class="border border-gray-300 text-lg font-semibold text-gray-900 py-2 px-2"
|
||||||
style="min-width: 46px;"
|
style="min-width: 46px;"
|
||||||
:class="{ 'bg-red-100 text-red-800': day.isWeekend || day.isHoliday, 'text-blumilk-600 bg-blumilk-25': day.isToday }"
|
:class="{ 'bg-red-100 text-red-800': day.isWeekend || day.isHoliday, 'text-blumilk-600 bg-blumilk-25': day.isToday }"
|
||||||
>
|
>
|
||||||
@ -83,16 +83,13 @@
|
|||||||
v-for="user in users.data"
|
v-for="user in users.data"
|
||||||
:key="user.id"
|
:key="user.id"
|
||||||
>
|
>
|
||||||
<th class="border border-gray-300 py-2 px-4">
|
<th class="border border-gray-300 py-2 px-2">
|
||||||
<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-8 w-8 rounded-full">
|
||||||
<img
|
<img :src="user.avatar">
|
||||||
class="h-10 w-10 rounded-full"
|
|
||||||
:src="user.avatar"
|
|
||||||
>
|
|
||||||
</span>
|
</span>
|
||||||
<div class="ml-3">
|
<div class="ml-3">
|
||||||
<div class="text-sm font-medium text-gray-900 whitespace-nowrap">
|
<div class="text-sm font-medium text-gray-900 truncate">
|
||||||
{{ user.name }}
|
{{ user.name }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -81,6 +81,7 @@ import { useMonthInfo } from '@/Composables/monthInfo'
|
|||||||
import VacationBar from '@/Shared/VacationBar'
|
import VacationBar from '@/Shared/VacationBar'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
|
years: Object,
|
||||||
monthlyUsage: Object,
|
monthlyUsage: Object,
|
||||||
currentMonth: String,
|
currentMonth: String,
|
||||||
})
|
})
|
||||||
@ -89,6 +90,6 @@ const { getMonths } = useMonthInfo()
|
|||||||
const months = getMonths()
|
const months = getMonths()
|
||||||
|
|
||||||
function isCurrentMonth(month) {
|
function isCurrentMonth(month) {
|
||||||
return props.currentMonth === month.value
|
return (props.years.selected.year === props.years.current.year && props.currentMonth === month.value)
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
<div class="border-t border-gray-200">
|
<div class="border-t border-gray-200">
|
||||||
<div class="overflow-x-auto xl:overflow-x-visible overflow-y-auto xl:overflow-y-visible">
|
<div class="overflow-x-auto xl:overflow-x-visible overflow-y-auto xl:overflow-y-visible">
|
||||||
<form @submit.prevent="submitVacationDays">
|
<form @submit.prevent="submitVacationDays">
|
||||||
<table class="min-w-full divide-y divide-gray-200">
|
<table class="min-w-full divide-y divide-gray-200 border-b">
|
||||||
<thead class="bg-gray-50">
|
<thead class="bg-gray-50">
|
||||||
<tr>
|
<tr>
|
||||||
<th
|
<th
|
||||||
@ -155,7 +155,7 @@ function submitVacationDays() {
|
|||||||
days: item.hasVacation ? item.days : null,
|
days: item.hasVacation ? item.days : null,
|
||||||
})),
|
})),
|
||||||
}))
|
}))
|
||||||
.put('/vacation-limits', {
|
.put('/vacation/limits', {
|
||||||
preserveState: (page) => Object.keys(page.props.errors).length,
|
preserveState: (page) => Object.keys(page.props.errors).length,
|
||||||
preserveScroll: true,
|
preserveScroll: true,
|
||||||
})
|
})
|
||||||
|
@ -287,7 +287,7 @@
|
|||||||
<div class="flex justify-end py-3">
|
<div class="flex justify-end py-3">
|
||||||
<div class="space-x-3">
|
<div class="space-x-3">
|
||||||
<InertiaLink
|
<InertiaLink
|
||||||
href="/vacation-requests"
|
href="/vacation/requests"
|
||||||
class="bg-white py-2 px-4 border border-gray-300 rounded-md shadow-sm text-sm font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blumilk-500"
|
class="bg-white py-2 px-4 border border-gray-300 rounded-md shadow-sm text-sm font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blumilk-500"
|
||||||
>
|
>
|
||||||
Anuluj
|
Anuluj
|
||||||
@ -388,7 +388,7 @@ function createForm() {
|
|||||||
type: data.type.value,
|
type: data.type.value,
|
||||||
user: data.user.id,
|
user: data.user.id,
|
||||||
}))
|
}))
|
||||||
.post('/vacation-requests')
|
.post('/vacation/requests')
|
||||||
}
|
}
|
||||||
|
|
||||||
function onFromChange(selectedDates, dateStr) {
|
function onFromChange(selectedDates, dateStr) {
|
||||||
@ -418,14 +418,14 @@ function resetForm() {
|
|||||||
|
|
||||||
async function refreshEstimatedDays(from, to) {
|
async function refreshEstimatedDays(from, to) {
|
||||||
if (from && to) {
|
if (from && to) {
|
||||||
const res = await axios.post('/api/calculate-vacation-days', { from, to })
|
const res = await axios.post('/api/calculate-vacation/days', { from, to })
|
||||||
|
|
||||||
estimatedDays.value = res.data
|
estimatedDays.value = res.data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function refreshVacationStats(user) {
|
async function refreshVacationStats(user) {
|
||||||
const res = await axios.post('/api/calculate-vacation-stats', { user: user.id })
|
const res = await axios.post('/api/calculate-vacation/stats', { user: user.id })
|
||||||
|
|
||||||
stats.value = res.data
|
stats.value = res.data
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<InertiaLink
|
<InertiaLink
|
||||||
href="/vacation-requests/create"
|
href="/vacation/requests/create"
|
||||||
class="inline-flex items-center px-4 py-3 border border-transparent text-sm leading-4 font-medium rounded-md shadow-sm text-white bg-blumilk-600 hover:bg-blumilk-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blumilk-500"
|
class="inline-flex items-center px-4 py-3 border border-transparent text-sm leading-4 font-medium rounded-md shadow-sm text-white bg-blumilk-600 hover:bg-blumilk-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blumilk-500"
|
||||||
>
|
>
|
||||||
Dodaj wniosek
|
Dodaj wniosek
|
||||||
@ -84,7 +84,7 @@
|
|||||||
>
|
>
|
||||||
<td class="px-4 py-4 whitespace-nowrap text-sm text-gray-500">
|
<td class="px-4 py-4 whitespace-nowrap text-sm text-gray-500">
|
||||||
<InertiaLink
|
<InertiaLink
|
||||||
:href="`/vacation-requests/${request.id}`"
|
:href="`/vacation/requests/${request.id}`"
|
||||||
class="font-semibold text-blumilk-600 hover:text-blumilk-500 hover:underline"
|
class="font-semibold text-blumilk-600 hover:text-blumilk-500 hover:underline"
|
||||||
>
|
>
|
||||||
{{ request.name }}
|
{{ request.name }}
|
||||||
@ -107,13 +107,13 @@
|
|||||||
</td>
|
</td>
|
||||||
<td class="px-4 py-4 whitespace-nowrap text-sm text-gray-500">
|
<td class="px-4 py-4 whitespace-nowrap text-sm text-gray-500">
|
||||||
<InertiaLink
|
<InertiaLink
|
||||||
:href="`/vacation-requests/${request.id}`"
|
:href="`/vacation/requests/${request.id}`"
|
||||||
class="flex justify-around"
|
class="flex justify-around"
|
||||||
>
|
>
|
||||||
<ChevronRightIcon class="block w-6 h-6 fill-blumilk-500" />
|
<ChevronRightIcon class="block w-6 h-6 fill-blumilk-500" />
|
||||||
</InertiaLink>
|
</InertiaLink>
|
||||||
<InertiaLink
|
<InertiaLink
|
||||||
:href="`/vacation-requests/${request.id}`"
|
:href="`/vacation/requests/${request.id}`"
|
||||||
class="absolute inset-0"
|
class="absolute inset-0"
|
||||||
/>
|
/>
|
||||||
</td>
|
</td>
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<InertiaLink
|
<InertiaLink
|
||||||
href="/vacation-requests/create"
|
href="/vacation/requests/create"
|
||||||
class="inline-flex items-center px-4 py-3 border border-transparent text-sm leading-4 font-medium rounded-md shadow-sm text-white bg-blumilk-600 hover:bg-blumilk-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blumilk-500"
|
class="inline-flex items-center px-4 py-3 border border-transparent text-sm leading-4 font-medium rounded-md shadow-sm text-white bg-blumilk-600 hover:bg-blumilk-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blumilk-500"
|
||||||
>
|
>
|
||||||
Dodaj wniosek
|
Dodaj wniosek
|
||||||
@ -224,7 +224,7 @@
|
|||||||
>
|
>
|
||||||
<td class="px-4 py-4 whitespace-nowrap text-sm text-gray-500">
|
<td class="px-4 py-4 whitespace-nowrap text-sm text-gray-500">
|
||||||
<InertiaLink
|
<InertiaLink
|
||||||
:href="`/vacation-requests/${request.id}`"
|
:href="`/vacation/requests/${request.id}`"
|
||||||
class="font-semibold text-blumilk-600 hover:text-blumilk-500 hover:underline"
|
class="font-semibold text-blumilk-600 hover:text-blumilk-500 hover:underline"
|
||||||
>
|
>
|
||||||
{{ request.name }}
|
{{ request.name }}
|
||||||
@ -263,13 +263,13 @@
|
|||||||
</td>
|
</td>
|
||||||
<td class="px-4 py-4 whitespace-nowrap text-sm text-gray-500">
|
<td class="px-4 py-4 whitespace-nowrap text-sm text-gray-500">
|
||||||
<InertiaLink
|
<InertiaLink
|
||||||
:href="`/vacation-requests/${request.id}`"
|
:href="`/vacation/requests/${request.id}`"
|
||||||
class="flex justify-around"
|
class="flex justify-around"
|
||||||
>
|
>
|
||||||
<ChevronRightIcon class="block w-6 h-6 fill-blumilk-500" />
|
<ChevronRightIcon class="block w-6 h-6 fill-blumilk-500" />
|
||||||
</InertiaLink>
|
</InertiaLink>
|
||||||
<InertiaLink
|
<InertiaLink
|
||||||
:href="`/vacation-requests/${request.id}`"
|
:href="`/vacation/requests/${request.id}`"
|
||||||
class="absolute inset-0"
|
class="absolute inset-0"
|
||||||
/>
|
/>
|
||||||
</td>
|
</td>
|
||||||
@ -334,7 +334,7 @@ const form = reactive({
|
|||||||
})
|
})
|
||||||
|
|
||||||
watch(form, debounce(() => {
|
watch(form, debounce(() => {
|
||||||
Inertia.get('/vacation-requests', { user: form.user?.id, status: form.status.value }, {
|
Inertia.get('/vacation/requests', { user: form.user?.id, status: form.status.value }, {
|
||||||
preserveState: true,
|
preserveState: true,
|
||||||
replace: true,
|
replace: true,
|
||||||
})
|
})
|
||||||
|
@ -60,13 +60,14 @@
|
|||||||
Data
|
Data
|
||||||
</dt>
|
</dt>
|
||||||
<dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
|
<dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
|
||||||
|
<template v-if="request.days.length > 1">
|
||||||
|
{{ request.from }} - {{ request.to }}
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
{{ request.from }}
|
||||||
|
</template>
|
||||||
<span class="font-semibold">
|
<span class="font-semibold">
|
||||||
<template v-if="request.days.length > 1">
|
[Liczba dni: {{ request.days.length }}]
|
||||||
{{ request.from }} - {{ request.to }} [Liczba dni: {{ request.days.length }}]
|
|
||||||
</template>
|
|
||||||
<template v-else>
|
|
||||||
{{ request.from }} [Liczba dni: {{ request.days.length }}]
|
|
||||||
</template>
|
|
||||||
</span>
|
</span>
|
||||||
</dd>
|
</dd>
|
||||||
</div>
|
</div>
|
||||||
@ -100,7 +101,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="ml-4 flex-shrink-0">
|
<div class="ml-4 flex-shrink-0">
|
||||||
<a
|
<a
|
||||||
:href="`/vacation-requests/${request.id}/download`"
|
:href="`/vacation/requests/${request.id}/download`"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
class="font-medium text-blumilk-600 hover:text-blumilk-500"
|
class="font-medium text-blumilk-600 hover:text-blumilk-500"
|
||||||
>
|
>
|
||||||
@ -130,7 +131,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="mt-5">
|
<div class="mt-5">
|
||||||
<InertiaLink
|
<InertiaLink
|
||||||
:href="`/vacation-requests/${request.id}/accept-as-technical`"
|
:href="`/vacation/requests/${request.id}/accept-as-technical`"
|
||||||
method="post"
|
method="post"
|
||||||
as="button"
|
as="button"
|
||||||
preserve-scroll
|
preserve-scroll
|
||||||
@ -156,7 +157,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="mt-5">
|
<div class="mt-5">
|
||||||
<InertiaLink
|
<InertiaLink
|
||||||
:href="`/vacation-requests/${request.id}/accept-as-administrative`"
|
:href="`/vacation/requests/${request.id}/accept-as-administrative`"
|
||||||
method="post"
|
method="post"
|
||||||
as="button"
|
as="button"
|
||||||
preserve-scroll
|
preserve-scroll
|
||||||
@ -182,7 +183,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="mt-5">
|
<div class="mt-5">
|
||||||
<InertiaLink
|
<InertiaLink
|
||||||
:href="`/vacation-requests/${request.id}/reject`"
|
:href="`/vacation/requests/${request.id}/reject`"
|
||||||
method="post"
|
method="post"
|
||||||
as="button"
|
as="button"
|
||||||
preserve-scroll
|
preserve-scroll
|
||||||
@ -208,7 +209,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="mt-5">
|
<div class="mt-5">
|
||||||
<InertiaLink
|
<InertiaLink
|
||||||
:href="`/vacation-requests/${request.id}/cancel`"
|
:href="`/vacation/requests/${request.id}/cancel`"
|
||||||
method="post"
|
method="post"
|
||||||
as="button"
|
as="button"
|
||||||
preserve-scroll
|
preserve-scroll
|
||||||
|
@ -44,7 +44,6 @@
|
|||||||
class="ml-1 flex items-center justify-center h-10 w-10 rounded-full focus:outline-none focus:ring-2 focus:ring-inset focus:ring-white"
|
class="ml-1 flex items-center justify-center h-10 w-10 rounded-full focus:outline-none focus:ring-2 focus:ring-inset focus:ring-white"
|
||||||
@click="sidebarOpen = false"
|
@click="sidebarOpen = false"
|
||||||
>
|
>
|
||||||
<span class="sr-only">Close sidebar</span>
|
|
||||||
<XIcon class="h-6 w-6 text-white" />
|
<XIcon class="h-6 w-6 text-white" />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
@ -102,32 +101,28 @@
|
|||||||
>
|
>
|
||||||
</InertiaLink>
|
</InertiaLink>
|
||||||
</div>
|
</div>
|
||||||
<nav class="mt-5 flex-1 flex flex-col divide-y divide-blumilk-800 overflow-y-auto">
|
<nav class="mt-5 px-2 flex-1 flex flex-col divide-y divide-blumilk-800 overflow-y-auto">
|
||||||
<div class="px-2 space-y-1">
|
<InertiaLink
|
||||||
|
href="/"
|
||||||
|
:class="[$page.component === 'Dashboard' ? 'bg-blumilk-800 text-white' : 'text-blumilk-100 hover:text-white hover:bg-blumilk-600', 'group flex items-center px-2 py-2 text-sm leading-6 font-medium rounded-md']"
|
||||||
|
>
|
||||||
|
<HomeIcon class="mr-4 flex-shrink-0 h-6 w-6 text-blumilk-200" />
|
||||||
|
Strona główna
|
||||||
|
</InertiaLink>
|
||||||
|
<div class="mt-1 pt-1 space-y-1">
|
||||||
<InertiaLink
|
<InertiaLink
|
||||||
href="/"
|
v-for="item in navigation"
|
||||||
:class="[$page.component === 'Dashboard' ? 'bg-blumilk-800 text-white' : 'text-blumilk-100 hover:text-white hover:bg-blumilk-600', 'group flex items-center px-2 py-2 text-sm leading-6 font-medium rounded-md']"
|
:key="item.name"
|
||||||
|
:href="item.href"
|
||||||
|
:class="[$page.component === item.component ? 'bg-blumilk-800 text-white' : 'text-blumilk-100 hover:text-white hover:bg-blumilk-600', 'group flex items-center px-2 py-2 text-sm leading-6 font-medium rounded-md']"
|
||||||
>
|
>
|
||||||
<HomeIcon class="mr-4 flex-shrink-0 h-6 w-6 text-blumilk-200" />
|
<component
|
||||||
Strona główna
|
:is="item.icon"
|
||||||
|
class="mr-4 flex-shrink-0 h-6 w-6 text-blumilk-200"
|
||||||
|
/>
|
||||||
|
{{ item.name }}
|
||||||
</InertiaLink>
|
</InertiaLink>
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-4 pt-4">
|
|
||||||
<div class="px-2 space-y-1">
|
|
||||||
<InertiaLink
|
|
||||||
v-for="item in navigation"
|
|
||||||
:key="item.name"
|
|
||||||
:href="item.href"
|
|
||||||
:class="[$page.component === item.component ? 'bg-blumilk-800 text-white' : 'text-blumilk-100 hover:text-white hover:bg-blumilk-600', 'group flex items-center px-2 py-2 text-sm leading-6 font-medium rounded-md']"
|
|
||||||
>
|
|
||||||
<component
|
|
||||||
:is="item.icon"
|
|
||||||
class="mr-4 flex-shrink-0 h-6 w-6 text-blumilk-200"
|
|
||||||
/>
|
|
||||||
{{ item.name }}
|
|
||||||
</InertiaLink>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -139,7 +134,6 @@
|
|||||||
class="px-4 border-r border-gray-200 text-gray-400 focus:outline-none focus:ring-2 focus:ring-inset focus:ring-blumilk-500 lg:hidden"
|
class="px-4 border-r border-gray-200 text-gray-400 focus:outline-none focus:ring-2 focus:ring-inset focus:ring-blumilk-500 lg:hidden"
|
||||||
@click="sidebarOpen = true"
|
@click="sidebarOpen = true"
|
||||||
>
|
>
|
||||||
<span class="sr-only">Open sidebar</span>
|
|
||||||
<MenuAlt1Icon class="h-6 w-6" />
|
<MenuAlt1Icon class="h-6 w-6" />
|
||||||
</button>
|
</button>
|
||||||
<div class="flex-1 px-4 flex justify-between sm:px-6 lg:px-8">
|
<div class="flex-1 px-4 flex justify-between sm:px-6 lg:px-8">
|
||||||
@ -150,14 +144,14 @@
|
|||||||
class="relative inline-block text-left"
|
class="relative inline-block text-left"
|
||||||
>
|
>
|
||||||
<div class="flex justify-center items-center">
|
<div class="flex justify-center items-center">
|
||||||
<div class="mr-4">
|
<div class="mr-4 text-sm">
|
||||||
Wybrany rok:
|
Wybrany rok:
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<MenuButton
|
<MenuButton
|
||||||
class="inline-flex justify-center w-full rounded-md border border-gray-300 shadow-sm px-4 py-2 bg-white text-sm font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blumilk-500"
|
class="inline-flex justify-center w-full rounded-md border border-gray-300 shadow-sm px-4 py-2 bg-white text-sm font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blumilk-500"
|
||||||
>
|
>
|
||||||
{{ years.current }}
|
{{ years.selected.year }}
|
||||||
<ChevronDownIcon class="-mr-1 ml-2 h-5 w-5" />
|
<ChevronDownIcon class="-mr-1 ml-2 h-5 w-5" />
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
</div>
|
</div>
|
||||||
@ -172,7 +166,7 @@
|
|||||||
leave-to-class="transform opacity-0 scale-95"
|
leave-to-class="transform opacity-0 scale-95"
|
||||||
>
|
>
|
||||||
<MenuItems
|
<MenuItems
|
||||||
class="origin-top-right absolute right-0 mt-2 w-32 rounded-md shadow-lg bg-white ring-1 ring-black ring-opacity-5 focus:outline-none"
|
class="origin-top-right absolute right-0 mt-2 w-24 rounded-md shadow-lg bg-white ring-1 ring-black ring-opacity-5 focus:outline-none"
|
||||||
>
|
>
|
||||||
<div class="py-1">
|
<div class="py-1">
|
||||||
<MenuItem
|
<MenuItem
|
||||||
@ -189,7 +183,7 @@
|
|||||||
>
|
>
|
||||||
{{ item.year }}
|
{{ item.year }}
|
||||||
<CheckIcon
|
<CheckIcon
|
||||||
v-if="item.year === years.current"
|
v-if="item.year === years.selected.year"
|
||||||
class="h-5 w-5 text-blumilk-500 ml-2"
|
class="h-5 w-5 text-blumilk-500 ml-2"
|
||||||
/>
|
/>
|
||||||
</InertiaLink>
|
</InertiaLink>
|
||||||
@ -199,6 +193,20 @@
|
|||||||
</transition>
|
</transition>
|
||||||
</Menu>
|
</Menu>
|
||||||
</div>
|
</div>
|
||||||
|
<div
|
||||||
|
v-if="years.current.year !== years.selected.year"
|
||||||
|
class="ml-3 text-sm hidden sm:block"
|
||||||
|
>
|
||||||
|
<InertiaLink
|
||||||
|
:href="years.current.link"
|
||||||
|
as="button"
|
||||||
|
method="post"
|
||||||
|
:preserve-state="false"
|
||||||
|
class="font-semibold text-blumilk-600 hover:text-blumilk-500"
|
||||||
|
>
|
||||||
|
Wróć do obecnego roku
|
||||||
|
</inertialink>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="ml-4 flex items-center md:ml-6">
|
<div class="ml-4 flex items-center md:ml-6">
|
||||||
<Menu
|
<Menu
|
||||||
@ -213,7 +221,6 @@
|
|||||||
:src="auth.user.avatar"
|
:src="auth.user.avatar"
|
||||||
>
|
>
|
||||||
<span class="hidden ml-3 text-gray-700 text-sm font-medium lg:block">
|
<span class="hidden ml-3 text-gray-700 text-sm font-medium lg:block">
|
||||||
<span class="sr-only">Open user menu for </span>
|
|
||||||
{{ auth.user.name }}
|
{{ auth.user.name }}
|
||||||
</span>
|
</span>
|
||||||
<ChevronDownIcon class="hidden flex-shrink-0 ml-1 h-5 w-5 text-gray-400 lg:block" />
|
<ChevronDownIcon class="hidden flex-shrink-0 ml-1 h-5 w-5 text-gray-400 lg:block" />
|
||||||
@ -285,28 +292,28 @@ const navigation = computed(() =>
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
name: 'Moje wnioski',
|
name: 'Moje wnioski',
|
||||||
href: '/vacation-requests/me',
|
href: '/vacation/requests/me',
|
||||||
component: 'VacationRequest/Index',
|
component: 'VacationRequest/Index',
|
||||||
icon: DocumentTextIcon,
|
icon: DocumentTextIcon,
|
||||||
can: true,
|
can: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Wnioski urlopowe',
|
name: 'Wnioski urlopowe',
|
||||||
href: '/vacation-requests',
|
href: '/vacation/requests',
|
||||||
component: 'VacationRequest/IndexForApprovers',
|
component: 'VacationRequest/IndexForApprovers',
|
||||||
icon: CollectionIcon,
|
icon: CollectionIcon,
|
||||||
can: props.auth.can.listAllVacationRequests,
|
can: props.auth.can.listAllVacationRequests,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Kalendarz urlopów',
|
name: 'Kalendarz urlopów',
|
||||||
href: '/vacation-calendar',
|
href: '/vacation/calendar',
|
||||||
component: 'Calendar',
|
component: 'Calendar',
|
||||||
icon: CalendarIcon,
|
icon: CalendarIcon,
|
||||||
can: true,
|
can: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Wykorzystanie urlopu',
|
name: 'Wykorzystanie urlopu',
|
||||||
href: '/monthly-usage',
|
href: '/vacation/monthly-usage',
|
||||||
component: 'MonthlyUsage',
|
component: 'MonthlyUsage',
|
||||||
icon: AdjustmentsIcon,
|
icon: AdjustmentsIcon,
|
||||||
can: props.auth.can.listMonthlyUsage,
|
can: props.auth.can.listMonthlyUsage,
|
||||||
@ -320,7 +327,7 @@ const navigation = computed(() =>
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Limity urlopów',
|
name: 'Limity urlopów',
|
||||||
href: '/vacation-limits',
|
href: '/vacation/limits',
|
||||||
component: 'VacationLimits',
|
component: 'VacationLimits',
|
||||||
icon: SunIcon,
|
icon: SunIcon,
|
||||||
can: props.auth.can.manageVacationLimits,
|
can: props.auth.can.manageVacationLimits,
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
<div class="relative focus-within:ring-2 focus-within:ring-blumilk-500">
|
<div class="relative focus-within:ring-2 focus-within:ring-blumilk-500">
|
||||||
<h3 class="text-sm font-semibold text-blumilk-600 hover:text-blumilk-500">
|
<h3 class="text-sm font-semibold text-blumilk-600 hover:text-blumilk-500">
|
||||||
<InertiaLink
|
<InertiaLink
|
||||||
:href="`/vacation-requests/${request.id}`"
|
:href="`/vacation/requests/${request.id}`"
|
||||||
class="hover:underline focus:outline-none"
|
class="hover:underline focus:outline-none"
|
||||||
>
|
>
|
||||||
<span class="absolute inset-0" />
|
<span class="absolute inset-0" />
|
||||||
@ -54,7 +54,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="mt-6">
|
<div class="mt-6">
|
||||||
<InertiaLink
|
<InertiaLink
|
||||||
href="/vacation-requests"
|
href="/vacation/requests"
|
||||||
:data="{status: 'waiting_for_action'}"
|
:data="{status: 'waiting_for_action'}"
|
||||||
class="w-full flex justify-center items-center px-4 py-2 border border-gray-300 shadow-sm text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-blumilk-500"
|
class="w-full flex justify-center items-center px-4 py-2 border border-gray-300 shadow-sm text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-blumilk-500"
|
||||||
>
|
>
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
<div class="relative focus-within:ring-2 focus-within:ring-blumilk-500">
|
<div class="relative focus-within:ring-2 focus-within:ring-blumilk-500">
|
||||||
<h3 class="text-sm font-semibold text-blumilk-600 hover:text-blumilk-500">
|
<h3 class="text-sm font-semibold text-blumilk-600 hover:text-blumilk-500">
|
||||||
<InertiaLink
|
<InertiaLink
|
||||||
:href="`/vacation-requests/${request.id}`"
|
:href="`/vacation/requests/${request.id}`"
|
||||||
class="hover:underline focus:outline-none"
|
class="hover:underline focus:outline-none"
|
||||||
>
|
>
|
||||||
<span class="absolute inset-0" />
|
<span class="absolute inset-0" />
|
||||||
@ -41,7 +41,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="mt-6">
|
<div class="mt-6">
|
||||||
<InertiaLink
|
<InertiaLink
|
||||||
href="/vacation-requests/me"
|
href="/vacation/requests/me"
|
||||||
class="w-full flex justify-center items-center px-4 py-2 border border-gray-300 shadow-sm text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-blumilk-500"
|
class="w-full flex justify-center items-center px-4 py-2 border border-gray-300 shadow-sm text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-blumilk-500"
|
||||||
>
|
>
|
||||||
Zobacz wszystkie
|
Zobacz wszystkie
|
||||||
|
@ -32,7 +32,7 @@ createInertiaApp({
|
|||||||
|
|
||||||
InertiaProgress.init({
|
InertiaProgress.init({
|
||||||
delay: 0,
|
delay: 0,
|
||||||
color: 'red',
|
color: '#527ABA',
|
||||||
})
|
})
|
||||||
|
|
||||||
Flatpickr.localize(Polish)
|
Flatpickr.localize(Polish)
|
||||||
|
@ -21,51 +21,49 @@ Route::middleware("auth")->group(function (): void {
|
|||||||
Route::post("/logout", LogoutController::class);
|
Route::post("/logout", LogoutController::class);
|
||||||
|
|
||||||
Route::resource("users", UserController::class);
|
Route::resource("users", UserController::class);
|
||||||
Route::post("/users/{user}/restore", [UserController::class, "restore"])->withTrashed();
|
Route::post("/users/{user}/restore", [UserController::class, "restore"])
|
||||||
|
->withTrashed();
|
||||||
|
|
||||||
Route::resource("holidays", HolidayController::class);
|
Route::resource("holidays", HolidayController::class);
|
||||||
|
|
||||||
Route::get("/vacation-limits", [VacationLimitController::class, "edit"])
|
|
||||||
->name("vacation.limits");
|
|
||||||
Route::get("/vacation-calendar/{month?}", [VacationCalendarController::class, "index"])
|
|
||||||
->name("vacation.calendar");
|
|
||||||
Route::get("/timesheet/{month}", TimesheetController::class)
|
|
||||||
->name("timesheet");
|
|
||||||
|
|
||||||
Route::get("/vacation-limits", [VacationLimitController::class, "edit"])->name("vacation.limits");
|
|
||||||
Route::put("/vacation-limits", [VacationLimitController::class, "update"]);
|
|
||||||
|
|
||||||
Route::get("/vacation-requests/me", [VacationRequestController::class, "index"])
|
|
||||||
->name("vacation.requests.index");
|
|
||||||
Route::get("/vacation-requests", [VacationRequestController::class, "indexForApprovers"])
|
|
||||||
->name("vacation.requests.indexForApprovers");
|
|
||||||
Route::get("/vacation-requests/create", [VacationRequestController::class, "create"])
|
|
||||||
->name("vacation.requests.create");
|
|
||||||
Route::post("/vacation-requests", [VacationRequestController::class, "store"])
|
|
||||||
->name("vacation.requests.store");
|
|
||||||
Route::get("/vacation-requests/{vacationRequest}", [VacationRequestController::class, "show"])
|
|
||||||
->name("vacation.requests.show");
|
|
||||||
Route::get("/vacation-requests/{vacationRequest}/download", [VacationRequestController::class, "download"])
|
|
||||||
->name("vacation.requests.download");
|
|
||||||
Route::post("/vacation-requests/{vacationRequest}/reject", [VacationRequestController::class, "reject"])
|
|
||||||
->name("vacation.requests.reject");
|
|
||||||
Route::post("/vacation-requests/{vacationRequest}/cancel", [VacationRequestController::class, "cancel"])
|
|
||||||
->name("vacation.requests.cancel");
|
|
||||||
Route::post(
|
|
||||||
"/vacation-requests/{vacationRequest}/accept-as-technical",
|
|
||||||
[VacationRequestController::class, "acceptAsTechnical"],
|
|
||||||
)
|
|
||||||
->name("vacation.requests.accept-as-technical");
|
|
||||||
Route::post(
|
|
||||||
"/vacation-requests/{vacationRequest}/accept-as-administrative",
|
|
||||||
[VacationRequestController::class, "acceptAsAdministrative"],
|
|
||||||
)
|
|
||||||
->name("vacation.requests.accept-as-administrative");
|
|
||||||
|
|
||||||
Route::post("year-periods/{yearPeriod}/select", SelectYearPeriodController::class)
|
Route::post("year-periods/{yearPeriod}/select", SelectYearPeriodController::class)
|
||||||
->name("year-periods.select");
|
->name("year-periods.select");
|
||||||
|
|
||||||
Route::get("/monthly-usage", MonthlyUsageController::class)->name("monthly-usage");
|
Route::prefix("/vacation")->group(function (): void {
|
||||||
|
Route::get("/limits", [VacationLimitController::class, "edit"])
|
||||||
|
->name("vacation.limits");
|
||||||
|
Route::get("/calendar/{month?}", [VacationCalendarController::class, "index"])
|
||||||
|
->name("vacation.calendar");
|
||||||
|
Route::get("/timesheet/{month}", TimesheetController::class)
|
||||||
|
->name("timesheet");
|
||||||
|
|
||||||
|
Route::get("/limits", [VacationLimitController::class, "edit"])
|
||||||
|
->name("vacation.limits");
|
||||||
|
Route::put("/limits", [VacationLimitController::class, "update"]);
|
||||||
|
|
||||||
|
Route::get("/requests", [VacationRequestController::class, "indexForApprovers"])
|
||||||
|
->name("vacation.requests.indexForApprovers");
|
||||||
|
Route::get("/requests/me", [VacationRequestController::class, "index"])
|
||||||
|
->name("vacation.requests.index");
|
||||||
|
Route::get("/requests/create", [VacationRequestController::class, "create"])
|
||||||
|
->name("vacation.requests.create");
|
||||||
|
Route::post("/requests", [VacationRequestController::class, "store"])
|
||||||
|
->name("vacation.requests.store");
|
||||||
|
Route::get("/requests/{vacationRequest}", [VacationRequestController::class, "show"])
|
||||||
|
->name("vacation.requests.show");
|
||||||
|
Route::get("/requests/{vacationRequest}/download", [VacationRequestController::class, "download"])
|
||||||
|
->name("vacation.requests.download");
|
||||||
|
Route::post("/requests/{vacationRequest}/reject", [VacationRequestController::class, "reject"])
|
||||||
|
->name("vacation.requests.reject");
|
||||||
|
Route::post("/requests/{vacationRequest}/cancel", [VacationRequestController::class, "cancel"])
|
||||||
|
->name("vacation.requests.cancel");
|
||||||
|
Route::post("/requests/{vacationRequest}/accept-as-technical", [VacationRequestController::class, "acceptAsTechnical"], )
|
||||||
|
->name("vacation.requests.accept-as-technical");
|
||||||
|
Route::post("/requests/{vacationRequest}/accept-as-administrative", [VacationRequestController::class, "acceptAsAdministrative"], )
|
||||||
|
->name("vacation.requests.accept-as-administrative");
|
||||||
|
|
||||||
|
Route::get("/monthly-usage", MonthlyUsageController::class)
|
||||||
|
->name("vacation.monthly-usage");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
Route::middleware("guest")->group(function (): void {
|
Route::middleware("guest")->group(function (): void {
|
||||||
|
@ -14,19 +14,19 @@ class MonthlyUsageTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testAdministatorCanSeeVacationsMonthlyUsage(): void
|
public function testAdministatorCanSeeVacationsMonthlyUsage(): void
|
||||||
{
|
{
|
||||||
$admin = User::factory()->admin()->createQuietly();
|
$admin = User::factory()->admin()->create();
|
||||||
|
|
||||||
$this->actingAs($admin)
|
$this->actingAs($admin)
|
||||||
->get("/monthly-usage")
|
->get("/vacation/monthly-usage")
|
||||||
->assertOk();
|
->assertOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testEmployeeCannotSeeVacationsMonthlyUsage(): void
|
public function testEmployeeCannotSeeVacationsMonthlyUsage(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->createQuietly();
|
$user = User::factory()->create();
|
||||||
|
|
||||||
$this->actingAs($user)
|
$this->actingAs($user)
|
||||||
->get("/monthly-usage")
|
->get("/vacation/monthly-usage")
|
||||||
->assertForbidden();
|
->assertForbidden();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,19 +14,19 @@ class VacationCalendarTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testAdministrativeApproverCanDownloadTimesheet(): void
|
public function testAdministrativeApproverCanDownloadTimesheet(): void
|
||||||
{
|
{
|
||||||
$administrativeApprover = User::factory()->administrativeApprover()->createQuietly();
|
$administrativeApprover = User::factory()->administrativeApprover()->create();
|
||||||
|
|
||||||
$this->actingAs($administrativeApprover)
|
$this->actingAs($administrativeApprover)
|
||||||
->get("/timesheet/january")
|
->get("/vacation/timesheet/january")
|
||||||
->assertOk();
|
->assertOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testEmployeeCannotDownloadTimesheet(): void
|
public function testEmployeeCannotDownloadTimesheet(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->createQuietly();
|
$user = User::factory()->create();
|
||||||
|
|
||||||
$this->actingAs($user)
|
$this->actingAs($user)
|
||||||
->get("/timesheet/january")
|
->get("/vacation/timesheet/january")
|
||||||
->assertForbidden();
|
->assertForbidden();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ use Inertia\Testing\AssertableInertia as Assert;
|
|||||||
use Tests\FeatureTestCase;
|
use Tests\FeatureTestCase;
|
||||||
use Toby\Eloquent\Models\User;
|
use Toby\Eloquent\Models\User;
|
||||||
use Toby\Eloquent\Models\VacationLimit;
|
use Toby\Eloquent\Models\VacationLimit;
|
||||||
|
use Toby\Eloquent\Models\YearPeriod;
|
||||||
|
|
||||||
class VacationLimitTest extends FeatureTestCase
|
class VacationLimitTest extends FeatureTestCase
|
||||||
{
|
{
|
||||||
@ -16,12 +17,14 @@ class VacationLimitTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testAdminCanSeeVacationLimits(): void
|
public function testAdminCanSeeVacationLimits(): void
|
||||||
{
|
{
|
||||||
$admin = User::factory()->admin()->createQuietly();
|
$admin = User::factory()->admin()->create();
|
||||||
|
|
||||||
User::factory(10)->create();
|
VacationLimit::factory(10)
|
||||||
|
->for(YearPeriod::current())
|
||||||
|
->create();
|
||||||
|
|
||||||
$this->actingAs($admin)
|
$this->actingAs($admin)
|
||||||
->get("/vacation-limits")
|
->get("/vacation/limits")
|
||||||
->assertOk()
|
->assertOk()
|
||||||
->assertInertia(
|
->assertInertia(
|
||||||
fn(Assert $page) => $page
|
fn(Assert $page) => $page
|
||||||
@ -32,9 +35,11 @@ class VacationLimitTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testAdminCanUpdateVacationLimits(): void
|
public function testAdminCanUpdateVacationLimits(): void
|
||||||
{
|
{
|
||||||
$admin = User::factory()->admin()->createQuietly();
|
$admin = User::factory()->admin()->create();
|
||||||
|
|
||||||
User::factory(3)->create();
|
VacationLimit::factory(3)
|
||||||
|
->for(YearPeriod::current())
|
||||||
|
->create();
|
||||||
|
|
||||||
[$limit1, $limit2, $limit3] = VacationLimit::all();
|
[$limit1, $limit2, $limit3] = VacationLimit::all();
|
||||||
|
|
||||||
@ -54,7 +59,7 @@ class VacationLimitTest extends FeatureTestCase
|
|||||||
];
|
];
|
||||||
|
|
||||||
$this->actingAs($admin)
|
$this->actingAs($admin)
|
||||||
->put("/vacation-limits", [
|
->put("/vacation/limits", [
|
||||||
"items" => $data,
|
"items" => $data,
|
||||||
])
|
])
|
||||||
->assertRedirect();
|
->assertRedirect();
|
||||||
|
@ -40,7 +40,7 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testUserCanSeeVacationRequestsList(): void
|
public function testUserCanSeeVacationRequestsList(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->createQuietly();
|
$user = User::factory()->create();
|
||||||
$currentYearPeriod = YearPeriod::current();
|
$currentYearPeriod = YearPeriod::current();
|
||||||
|
|
||||||
VacationRequest::factory()
|
VacationRequest::factory()
|
||||||
@ -50,7 +50,7 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
->create();
|
->create();
|
||||||
|
|
||||||
$this->actingAs($user)
|
$this->actingAs($user)
|
||||||
->get("/vacation-requests/me")
|
->get("/vacation/requests/me")
|
||||||
->assertOk()
|
->assertOk()
|
||||||
->assertInertia(
|
->assertInertia(
|
||||||
fn(Assert $page) => $page
|
fn(Assert $page) => $page
|
||||||
@ -61,7 +61,7 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testUserCanCreateVacationRequest(): void
|
public function testUserCanCreateVacationRequest(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->createQuietly();
|
$user = User::factory()->create();
|
||||||
|
|
||||||
$currentYearPeriod = YearPeriod::current();
|
$currentYearPeriod = YearPeriod::current();
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
->create();
|
->create();
|
||||||
|
|
||||||
$this->actingAs($user)
|
$this->actingAs($user)
|
||||||
->post("/vacation-requests", [
|
->post("/vacation/requests", [
|
||||||
"user" => $user->id,
|
"user" => $user->id,
|
||||||
"type" => VacationType::Vacation->value,
|
"type" => VacationType::Vacation->value,
|
||||||
"from" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(),
|
"from" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(),
|
||||||
@ -95,8 +95,8 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testUserCanCreateVacationRequestOnEmployeeBehalf(): void
|
public function testUserCanCreateVacationRequestOnEmployeeBehalf(): void
|
||||||
{
|
{
|
||||||
$creator = User::factory()->admin()->createQuietly();
|
$creator = User::factory()->admin()->create();
|
||||||
$user = User::factory()->createQuietly();
|
$user = User::factory()->create();
|
||||||
|
|
||||||
$currentYearPeriod = YearPeriod::current();
|
$currentYearPeriod = YearPeriod::current();
|
||||||
|
|
||||||
@ -108,7 +108,7 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
->create();
|
->create();
|
||||||
|
|
||||||
$this->actingAs($creator)
|
$this->actingAs($creator)
|
||||||
->post("/vacation-requests", [
|
->post("/vacation/requests", [
|
||||||
"user" => $user->id,
|
"user" => $user->id,
|
||||||
"type" => VacationType::Vacation->value,
|
"type" => VacationType::Vacation->value,
|
||||||
"from" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(),
|
"from" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(),
|
||||||
@ -131,8 +131,8 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testUserCanCreateVacationRequestOnEmployeeBehalfAndSkipAcceptanceFlow(): void
|
public function testUserCanCreateVacationRequestOnEmployeeBehalfAndSkipAcceptanceFlow(): void
|
||||||
{
|
{
|
||||||
$creator = User::factory()->admin()->createQuietly();
|
$creator = User::factory()->admin()->create();
|
||||||
$user = User::factory()->createQuietly();
|
$user = User::factory()->create();
|
||||||
|
|
||||||
$currentYearPeriod = YearPeriod::current();
|
$currentYearPeriod = YearPeriod::current();
|
||||||
|
|
||||||
@ -144,7 +144,7 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
->create();
|
->create();
|
||||||
|
|
||||||
$this->actingAs($creator)
|
$this->actingAs($creator)
|
||||||
->post("/vacation-requests", [
|
->post("/vacation/requests", [
|
||||||
"user" => $user->id,
|
"user" => $user->id,
|
||||||
"type" => VacationType::Vacation->value,
|
"type" => VacationType::Vacation->value,
|
||||||
"from" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(),
|
"from" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(),
|
||||||
@ -168,8 +168,8 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testTechnicalApproverCanApproveVacationRequest(): void
|
public function testTechnicalApproverCanApproveVacationRequest(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->createQuietly();
|
$user = User::factory()->create();
|
||||||
$technicalApprover = User::factory()->technicalApprover()->createQuietly();
|
$technicalApprover = User::factory()->technicalApprover()->create();
|
||||||
$currentYearPeriod = YearPeriod::current();
|
$currentYearPeriod = YearPeriod::current();
|
||||||
|
|
||||||
$vacationRequest = VacationRequest::factory([
|
$vacationRequest = VacationRequest::factory([
|
||||||
@ -181,7 +181,7 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
->create();
|
->create();
|
||||||
|
|
||||||
$this->actingAs($technicalApprover)
|
$this->actingAs($technicalApprover)
|
||||||
->post("/vacation-requests/{$vacationRequest->id}/accept-as-technical")
|
->post("/vacation/requests/{$vacationRequest->id}/accept-as-technical")
|
||||||
->assertRedirect();
|
->assertRedirect();
|
||||||
|
|
||||||
$vacationRequest->refresh();
|
$vacationRequest->refresh();
|
||||||
@ -191,8 +191,8 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testAdministrativeApproverCanApproveVacationRequest(): void
|
public function testAdministrativeApproverCanApproveVacationRequest(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->createQuietly();
|
$user = User::factory()->create();
|
||||||
$administrativeApprover = User::factory()->administrativeApprover()->createQuietly();
|
$administrativeApprover = User::factory()->administrativeApprover()->create();
|
||||||
|
|
||||||
$currentYearPeriod = YearPeriod::current();
|
$currentYearPeriod = YearPeriod::current();
|
||||||
|
|
||||||
@ -204,7 +204,7 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
->create();
|
->create();
|
||||||
|
|
||||||
$this->actingAs($administrativeApprover)
|
$this->actingAs($administrativeApprover)
|
||||||
->post("/vacation-requests/{$vacationRequest->id}/accept-as-administrative")
|
->post("/vacation/requests/{$vacationRequest->id}/accept-as-administrative")
|
||||||
->assertRedirect();
|
->assertRedirect();
|
||||||
|
|
||||||
$vacationRequest->refresh();
|
$vacationRequest->refresh();
|
||||||
@ -214,8 +214,8 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testTechnicalApproverCanRejectVacationRequest(): void
|
public function testTechnicalApproverCanRejectVacationRequest(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->createQuietly();
|
$user = User::factory()->create();
|
||||||
$technicalApprover = User::factory()->technicalApprover()->createQuietly();
|
$technicalApprover = User::factory()->technicalApprover()->create();
|
||||||
$currentYearPeriod = YearPeriod::current();
|
$currentYearPeriod = YearPeriod::current();
|
||||||
|
|
||||||
VacationLimit::factory([
|
VacationLimit::factory([
|
||||||
@ -235,7 +235,7 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
->create();
|
->create();
|
||||||
|
|
||||||
$this->actingAs($technicalApprover)
|
$this->actingAs($technicalApprover)
|
||||||
->post("/vacation-requests/{$vacationRequest->id}/reject")
|
->post("/vacation/requests/{$vacationRequest->id}/reject")
|
||||||
->assertRedirect();
|
->assertRedirect();
|
||||||
|
|
||||||
$vacationRequest->refresh();
|
$vacationRequest->refresh();
|
||||||
@ -245,7 +245,7 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testUserCannotCreateVacationRequestIfHeExceedsHisVacationLimit(): void
|
public function testUserCannotCreateVacationRequestIfHeExceedsHisVacationLimit(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->createQuietly();
|
$user = User::factory()->create();
|
||||||
$currentYearPeriod = YearPeriod::current();
|
$currentYearPeriod = YearPeriod::current();
|
||||||
|
|
||||||
VacationLimit::factory([
|
VacationLimit::factory([
|
||||||
@ -256,7 +256,7 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
->create();
|
->create();
|
||||||
|
|
||||||
$this->actingAs($user)
|
$this->actingAs($user)
|
||||||
->post("/vacation-requests", [
|
->post("/vacation/requests", [
|
||||||
"user" => $user->id,
|
"user" => $user->id,
|
||||||
"type" => VacationType::Vacation->value,
|
"type" => VacationType::Vacation->value,
|
||||||
"from" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(),
|
"from" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(),
|
||||||
@ -270,7 +270,7 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testUserCannotCreateVacationRequestAtWeekend(): void
|
public function testUserCannotCreateVacationRequestAtWeekend(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->createQuietly();
|
$user = User::factory()->create();
|
||||||
$currentYearPeriod = YearPeriod::current();
|
$currentYearPeriod = YearPeriod::current();
|
||||||
|
|
||||||
VacationLimit::factory([
|
VacationLimit::factory([
|
||||||
@ -281,7 +281,7 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
->create();
|
->create();
|
||||||
|
|
||||||
$this->actingAs($user)
|
$this->actingAs($user)
|
||||||
->post("/vacation-requests", [
|
->post("/vacation/requests", [
|
||||||
"user" => $user->id,
|
"user" => $user->id,
|
||||||
"type" => VacationType::Vacation->value,
|
"type" => VacationType::Vacation->value,
|
||||||
"from" => Carbon::create($currentYearPeriod->year, 2, 5)->toDateString(),
|
"from" => Carbon::create($currentYearPeriod->year, 2, 5)->toDateString(),
|
||||||
@ -295,7 +295,7 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testUserCannotCreateVacationRequestAtHoliday(): void
|
public function testUserCannotCreateVacationRequestAtHoliday(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->createQuietly();
|
$user = User::factory()->create();
|
||||||
$currentYearPeriod = YearPeriod::current();
|
$currentYearPeriod = YearPeriod::current();
|
||||||
|
|
||||||
VacationLimit::factory([
|
VacationLimit::factory([
|
||||||
@ -313,7 +313,7 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->actingAs($user)
|
$this->actingAs($user)
|
||||||
->post("/vacation-requests", [
|
->post("/vacation/requests", [
|
||||||
"user" => $user->id,
|
"user" => $user->id,
|
||||||
"type" => VacationType::Vacation->value,
|
"type" => VacationType::Vacation->value,
|
||||||
"from" => Carbon::create($currentYearPeriod->year, 4, 18)->toDateString(),
|
"from" => Carbon::create($currentYearPeriod->year, 4, 18)->toDateString(),
|
||||||
@ -327,7 +327,7 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testUserCannotCreateVacationRequestIfHeHasPendingVacationRequestInThisRange(): void
|
public function testUserCannotCreateVacationRequestIfHeHasPendingVacationRequestInThisRange(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->createQuietly();
|
$user = User::factory()->create();
|
||||||
$currentYearPeriod = YearPeriod::current();
|
$currentYearPeriod = YearPeriod::current();
|
||||||
|
|
||||||
VacationLimit::factory([
|
VacationLimit::factory([
|
||||||
@ -349,7 +349,7 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
->create();
|
->create();
|
||||||
|
|
||||||
$this->actingAs($user)
|
$this->actingAs($user)
|
||||||
->post("/vacation-requests", [
|
->post("/vacation/requests", [
|
||||||
"user" => $user->id,
|
"user" => $user->id,
|
||||||
"type" => VacationType::Vacation->value,
|
"type" => VacationType::Vacation->value,
|
||||||
"from" => Carbon::create($currentYearPeriod->year, 2, 1)->toDateString(),
|
"from" => Carbon::create($currentYearPeriod->year, 2, 1)->toDateString(),
|
||||||
@ -363,7 +363,7 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testUserCannotCreateVacationRequestIfHeHasApprovedVacationRequestInThisRange(): void
|
public function testUserCannotCreateVacationRequestIfHeHasApprovedVacationRequestInThisRange(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->createQuietly();
|
$user = User::factory()->create();
|
||||||
$currentYearPeriod = YearPeriod::current();
|
$currentYearPeriod = YearPeriod::current();
|
||||||
|
|
||||||
VacationLimit::factory([
|
VacationLimit::factory([
|
||||||
@ -385,7 +385,7 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
->create();
|
->create();
|
||||||
|
|
||||||
$this->actingAs($user)
|
$this->actingAs($user)
|
||||||
->post("/vacation-requests", [
|
->post("/vacation/requests", [
|
||||||
"user" => $user->id,
|
"user" => $user->id,
|
||||||
"type" => VacationType::Vacation->value,
|
"type" => VacationType::Vacation->value,
|
||||||
"from" => Carbon::create($currentYearPeriod->year, 2, 1)->toDateString(),
|
"from" => Carbon::create($currentYearPeriod->year, 2, 1)->toDateString(),
|
||||||
@ -399,10 +399,10 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testUserCannotCreateVacationRequestWithEndDatePriorToTheStartDate(): void
|
public function testUserCannotCreateVacationRequestWithEndDatePriorToTheStartDate(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->createQuietly();
|
$user = User::factory()->create();
|
||||||
$currentYearPeriod = YearPeriod::current();
|
$currentYearPeriod = YearPeriod::current();
|
||||||
$this->actingAs($user)
|
$this->actingAs($user)
|
||||||
->post("/vacation-requests", [
|
->post("/vacation/requests", [
|
||||||
"user" => $user->id,
|
"user" => $user->id,
|
||||||
"type" => VacationType::Vacation->value,
|
"type" => VacationType::Vacation->value,
|
||||||
"from" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(),
|
"from" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(),
|
||||||
@ -416,11 +416,11 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testUserCannotCreateVacationRequestAtTheTurnOfTheYear(): void
|
public function testUserCannotCreateVacationRequestAtTheTurnOfTheYear(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->createQuietly();
|
$user = User::factory()->create();
|
||||||
$currentYearPeriod = YearPeriod::current();
|
$currentYearPeriod = YearPeriod::current();
|
||||||
$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", [
|
||||||
"user" => $user->id,
|
"user" => $user->id,
|
||||||
"type" => VacationType::Vacation->value,
|
"type" => VacationType::Vacation->value,
|
||||||
"from" => Carbon::create($currentYearPeriod->year, 12, 27)->toDateString(),
|
"from" => Carbon::create($currentYearPeriod->year, 12, 27)->toDateString(),
|
||||||
@ -434,22 +434,22 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testEmployeeCanSeeOnlyHisVacationRequests(): void
|
public function testEmployeeCanSeeOnlyHisVacationRequests(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->createQuietly();
|
$user = User::factory()->create();
|
||||||
|
|
||||||
$this->actingAs($user)
|
$this->actingAs($user)
|
||||||
->get("/vacation-requests")
|
->get("/vacation/requests")
|
||||||
->assertRedirect("/vacation-requests/me");
|
->assertRedirect("/vacation/requests/me");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testEmployeeCannotCreateVacationRequestForAnotherEmployee(): void
|
public function testEmployeeCannotCreateVacationRequestForAnotherEmployee(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->createQuietly();
|
$user = User::factory()->create();
|
||||||
$anotherUser = User::factory()->createQuietly();
|
$anotherUser = User::factory()->create();
|
||||||
|
|
||||||
$currentYearPeriod = YearPeriod::current();
|
$currentYearPeriod = YearPeriod::current();
|
||||||
|
|
||||||
$this->actingAs($user)
|
$this->actingAs($user)
|
||||||
->post("/vacation-requests", [
|
->post("/vacation/requests", [
|
||||||
"user" => $anotherUser->id,
|
"user" => $anotherUser->id,
|
||||||
"type" => VacationType::Vacation->value,
|
"type" => VacationType::Vacation->value,
|
||||||
"from" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(),
|
"from" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(),
|
||||||
@ -461,7 +461,7 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testEmployeeCanCancelVacationRequestWithWaitingForAdministrativeStatus(): void
|
public function testEmployeeCanCancelVacationRequestWithWaitingForAdministrativeStatus(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->createQuietly();
|
$user = User::factory()->create();
|
||||||
$currentYearPeriod = YearPeriod::current();
|
$currentYearPeriod = YearPeriod::current();
|
||||||
|
|
||||||
VacationLimit::factory([
|
VacationLimit::factory([
|
||||||
@ -481,7 +481,7 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
->create();
|
->create();
|
||||||
|
|
||||||
$this->actingAs($user)
|
$this->actingAs($user)
|
||||||
->post("/vacation-requests/{$vacationRequest->id}/cancel")
|
->post("/vacation/requests/{$vacationRequest->id}/cancel")
|
||||||
->assertRedirect();
|
->assertRedirect();
|
||||||
|
|
||||||
$vacationRequest->refresh();
|
$vacationRequest->refresh();
|
||||||
@ -491,7 +491,7 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testEmployeeCannotCancelVacationRequestWithApprovedStatus(): void
|
public function testEmployeeCannotCancelVacationRequestWithApprovedStatus(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->createQuietly();
|
$user = User::factory()->create();
|
||||||
$currentYearPeriod = YearPeriod::current();
|
$currentYearPeriod = YearPeriod::current();
|
||||||
|
|
||||||
VacationLimit::factory([
|
VacationLimit::factory([
|
||||||
@ -511,14 +511,14 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
->create();
|
->create();
|
||||||
|
|
||||||
$this->actingAs($user)
|
$this->actingAs($user)
|
||||||
->post("/vacation-requests/{$vacationRequest->id}/cancel")
|
->post("/vacation/requests/{$vacationRequest->id}/cancel")
|
||||||
->assertForbidden();
|
->assertForbidden();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAdministrativeApproverCanCancelVacationRequestWithApprovedStatus(): void
|
public function testAdministrativeApproverCanCancelVacationRequestWithApprovedStatus(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->createQuietly();
|
$user = User::factory()->create();
|
||||||
$administrativeApprover = User::factory()->administrativeApprover()->createQuietly();
|
$administrativeApprover = User::factory()->administrativeApprover()->create();
|
||||||
$currentYearPeriod = YearPeriod::current();
|
$currentYearPeriod = YearPeriod::current();
|
||||||
|
|
||||||
VacationLimit::factory([
|
VacationLimit::factory([
|
||||||
@ -538,7 +538,7 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
->create();
|
->create();
|
||||||
|
|
||||||
$this->actingAs($administrativeApprover)
|
$this->actingAs($administrativeApprover)
|
||||||
->post("/vacation-requests/{$vacationRequest->id}/cancel")
|
->post("/vacation/requests/{$vacationRequest->id}/cancel")
|
||||||
->assertRedirect();
|
->assertRedirect();
|
||||||
|
|
||||||
$vacationRequest->refresh();
|
$vacationRequest->refresh();
|
||||||
@ -548,7 +548,7 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testEmployeeCanDownloadHisVacationRequestAsPdf(): void
|
public function testEmployeeCanDownloadHisVacationRequestAsPdf(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->createQuietly();
|
$user = User::factory()->create();
|
||||||
$currentYearPeriod = YearPeriod::current();
|
$currentYearPeriod = YearPeriod::current();
|
||||||
|
|
||||||
VacationLimit::factory([
|
VacationLimit::factory([
|
||||||
@ -568,14 +568,14 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
->create();
|
->create();
|
||||||
|
|
||||||
$this->actingAs($user)
|
$this->actingAs($user)
|
||||||
->get("/vacation-requests/{$vacationRequest->id}/download")
|
->get("/vacation/requests/{$vacationRequest->id}/download")
|
||||||
->assertSuccessful();
|
->assertSuccessful();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testEmployeeCannotDownloadAnotherEmployeesVacationRequestAsPdf(): void
|
public function testEmployeeCannotDownloadAnotherEmployeesVacationRequestAsPdf(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->createQuietly();
|
$user = User::factory()->create();
|
||||||
$anotherUser = User::factory()->createQuietly();
|
$anotherUser = User::factory()->create();
|
||||||
$currentYearPeriod = YearPeriod::current();
|
$currentYearPeriod = YearPeriod::current();
|
||||||
|
|
||||||
VacationLimit::factory([
|
VacationLimit::factory([
|
||||||
@ -595,7 +595,7 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
->create();
|
->create();
|
||||||
|
|
||||||
$this->actingAs($user)
|
$this->actingAs($user)
|
||||||
->get("/vacation-requests/{$vacationRequest->id}/download")
|
->get("/vacation/requests/{$vacationRequest->id}/download")
|
||||||
->assertForbidden();
|
->assertForbidden();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ trait InteractsWithYearPeriods
|
|||||||
public function createYearPeriod(int $year): YearPeriod
|
public function createYearPeriod(int $year): YearPeriod
|
||||||
{
|
{
|
||||||
/** @var YearPeriod $yearPeriod */
|
/** @var YearPeriod $yearPeriod */
|
||||||
$yearPeriod = YearPeriod::factory()->createQuietly([
|
$yearPeriod = YearPeriod::factory()->create([
|
||||||
"year" => $year,
|
"year" => $year,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
@ -7,6 +7,8 @@ namespace Tests\Unit;
|
|||||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
use Tests\Traits\InteractsWithYearPeriods;
|
use Tests\Traits\InteractsWithYearPeriods;
|
||||||
|
use Toby\Domain\Actions\CreateUserAction;
|
||||||
|
use Toby\Domain\Actions\CreateYearPeriodAction;
|
||||||
use Toby\Eloquent\Models\User;
|
use Toby\Eloquent\Models\User;
|
||||||
use Toby\Eloquent\Models\YearPeriod;
|
use Toby\Eloquent\Models\YearPeriod;
|
||||||
|
|
||||||
@ -27,7 +29,11 @@ class VacationLimitTest extends TestCase
|
|||||||
$this->assertDatabaseCount("vacation_limits", 0);
|
$this->assertDatabaseCount("vacation_limits", 0);
|
||||||
|
|
||||||
$currentYearPeriod = YearPeriod::current();
|
$currentYearPeriod = YearPeriod::current();
|
||||||
$user = User::factory()->create();
|
$createUserAction = $this->app->make(CreateUserAction::class);
|
||||||
|
|
||||||
|
$dumpData = User::factory()->raw();
|
||||||
|
|
||||||
|
$user = $createUserAction->execute($dumpData);
|
||||||
|
|
||||||
$this->assertDatabaseCount("vacation_limits", 1);
|
$this->assertDatabaseCount("vacation_limits", 1);
|
||||||
|
|
||||||
@ -40,10 +46,12 @@ class VacationLimitTest extends TestCase
|
|||||||
public function testWhenYearPeriodIsCreatedThenVacationLimitsForThisYearPeriodAreCreated(): void
|
public function testWhenYearPeriodIsCreatedThenVacationLimitsForThisYearPeriodAreCreated(): void
|
||||||
{
|
{
|
||||||
$this->assertDatabaseCount("vacation_limits", 0);
|
$this->assertDatabaseCount("vacation_limits", 0);
|
||||||
|
$createYearPeriodAction = $this->app->make(CreateYearPeriodAction::class);
|
||||||
|
$lastYear = YearPeriod::query()->max("year") + 1;
|
||||||
|
|
||||||
User::factory(10)->createQuietly();
|
User::factory(10)->create();
|
||||||
|
|
||||||
YearPeriod::factory()->create();
|
$createYearPeriodAction->execute($lastYear);
|
||||||
|
|
||||||
$this->assertDatabaseCount("vacation_limits", 10);
|
$this->assertDatabaseCount("vacation_limits", 10);
|
||||||
}
|
}
|
||||||
|
@ -39,16 +39,16 @@ class VacationRequestNotificationTest extends TestCase
|
|||||||
|
|
||||||
$user = User::factory([
|
$user = User::factory([
|
||||||
"role" => Role::Employee,
|
"role" => Role::Employee,
|
||||||
])->createQuietly();
|
])->create();
|
||||||
$technicalApprover = User::factory([
|
$technicalApprover = User::factory([
|
||||||
"role" => Role::TechnicalApprover,
|
"role" => Role::TechnicalApprover,
|
||||||
])->createQuietly();
|
])->create();
|
||||||
$administrativeApprover = User::factory([
|
$administrativeApprover = User::factory([
|
||||||
"role" => Role::AdministrativeApprover,
|
"role" => Role::AdministrativeApprover,
|
||||||
])->createQuietly();
|
])->create();
|
||||||
$admin = User::factory([
|
$admin = User::factory([
|
||||||
"role" => Role::Administrator,
|
"role" => Role::Administrator,
|
||||||
])->createQuietly();
|
])->create();
|
||||||
|
|
||||||
$currentYearPeriod = YearPeriod::current();
|
$currentYearPeriod = YearPeriod::current();
|
||||||
|
|
||||||
@ -78,13 +78,13 @@ class VacationRequestNotificationTest extends TestCase
|
|||||||
|
|
||||||
$technicalApprover = User::factory([
|
$technicalApprover = User::factory([
|
||||||
"role" => Role::TechnicalApprover,
|
"role" => Role::TechnicalApprover,
|
||||||
])->createQuietly();
|
])->create();
|
||||||
$administrativeApprover = User::factory([
|
$administrativeApprover = User::factory([
|
||||||
"role" => Role::AdministrativeApprover,
|
"role" => Role::AdministrativeApprover,
|
||||||
])->createQuietly();
|
])->create();
|
||||||
$admin = User::factory([
|
$admin = User::factory([
|
||||||
"role" => Role::Administrator,
|
"role" => Role::Administrator,
|
||||||
])->createQuietly();
|
])->create();
|
||||||
|
|
||||||
$currentYearPeriod = YearPeriod::current();
|
$currentYearPeriod = YearPeriod::current();
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ class VacationRequestStatesTest extends TestCase
|
|||||||
|
|
||||||
public function testAfterCreatingVacationRequestOfTypeVacationItTransitsToProperState(): void
|
public function testAfterCreatingVacationRequestOfTypeVacationItTransitsToProperState(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->createQuietly();
|
$user = User::factory()->create();
|
||||||
|
|
||||||
$currentYearPeriod = YearPeriod::current();
|
$currentYearPeriod = YearPeriod::current();
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ class VacationRequestStatesTest extends TestCase
|
|||||||
|
|
||||||
public function testAfterCreatingVacationRequestOfTypeSickVacationItTransitsToProperState(): void
|
public function testAfterCreatingVacationRequestOfTypeSickVacationItTransitsToProperState(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->createQuietly();
|
$user = User::factory()->create();
|
||||||
|
|
||||||
$currentYearPeriod = YearPeriod::current();
|
$currentYearPeriod = YearPeriod::current();
|
||||||
|
|
||||||
@ -85,7 +85,7 @@ class VacationRequestStatesTest extends TestCase
|
|||||||
|
|
||||||
public function testAfterCreatingVacationRequestOfTypeTimeInLieuItTransitsToProperState(): void
|
public function testAfterCreatingVacationRequestOfTypeTimeInLieuItTransitsToProperState(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->createQuietly();
|
$user = User::factory()->create();
|
||||||
|
|
||||||
$currentYearPeriod = YearPeriod::current();
|
$currentYearPeriod = YearPeriod::current();
|
||||||
|
|
||||||
|
@ -60,7 +60,14 @@ class YearPeriodRetrieverTest extends TestCase
|
|||||||
public function testLinks(): void
|
public function testLinks(): void
|
||||||
{
|
{
|
||||||
$expected = [
|
$expected = [
|
||||||
"current" => $this->current->year,
|
"current" => [
|
||||||
|
"year" => $this->currentYearPeriod->year,
|
||||||
|
"link" => route("year-periods.select", $this->currentYearPeriod),
|
||||||
|
],
|
||||||
|
"selected" => [
|
||||||
|
"year" => $this->currentYearPeriod->year,
|
||||||
|
"link" => route("year-periods.select", $this->currentYearPeriod),
|
||||||
|
],
|
||||||
"navigation" => [
|
"navigation" => [
|
||||||
[
|
[
|
||||||
"year" => $this->previousYearPeriod->year,
|
"year" => $this->previousYearPeriod->year,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user