#62 - vacation request list for approvers (#69)

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* #5 - bump dependencies

* #43 - wip

* #43 - add composer script

* #43 - fix

* #43 - fix

* #43 - wip

* #43 - ecs fix

* #43 - cr fix

* #43 - cr fix

* #43 - fix

* #62 - wip

* #62 - wip

* #62 - wip

* #62 - fix

* #62 - fix

* #62 - fix

* #62 - fix

* #62 - fix

* #62 - ecs fix

Co-authored-by: EwelinaLasowy <ewelina.lasowy@blumilk.pl>
This commit is contained in:
Adrian Hopek 2022-03-08 09:25:24 +01:00 committed by GitHub
parent af6f747aa2
commit db4be79c91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
28 changed files with 753 additions and 146 deletions

View File

@ -11,7 +11,6 @@ class AppServiceProvider extends ServiceProvider
{
public function boot(): void
{
Carbon::macro("toDisplayString", fn() => $this->translatedFormat("j F Y"));
Carbon::macro("toDisplayDate", fn() => $this->translatedFormat("d.m.Y"));
Carbon::macro("toDisplayString", fn() => $this->translatedFormat("d.m.Y"));
}
}

View File

@ -45,8 +45,8 @@ class VacationRequestApprovedNotification extends Notification
$user = $this->user->first_name;
$title = $this->vacationRequest->name;
$type = $this->vacationRequest->type->label();
$from = $this->vacationRequest->from->toDisplayDate();
$to = $this->vacationRequest->to->toDisplayDate();
$from = $this->vacationRequest->from->toDisplayString();
$to = $this->vacationRequest->to->toDisplayString();
$days = $this->vacationRequest->vacations()->count();
$requester = $this->vacationRequest->user->fullName;

View File

@ -45,8 +45,8 @@ class VacationRequestCancelledNotification extends Notification
$user = $this->user->first_name;
$title = $this->vacationRequest->name;
$type = $this->vacationRequest->type->label();
$from = $this->vacationRequest->from->toDisplayDate();
$to = $this->vacationRequest->to->toDisplayDate();
$from = $this->vacationRequest->from->toDisplayString();
$to = $this->vacationRequest->to->toDisplayString();
$days = $this->vacationRequest->vacations()->count();
$requester = $this->vacationRequest->user->fullName;

View File

@ -42,8 +42,8 @@ class VacationRequestCreatedNotification extends Notification
$user = $this->vacationRequest->user->first_name;
$title = $this->vacationRequest->name;
$type = $this->vacationRequest->type->label();
$from = $this->vacationRequest->from->toDisplayDate();
$to = $this->vacationRequest->to->toDisplayDate();
$from = $this->vacationRequest->from->toDisplayString();
$to = $this->vacationRequest->to->toDisplayString();
$days = $this->vacationRequest->vacations()->count();
$appName = config("app.name");

View File

@ -43,8 +43,8 @@ class VacationRequestCreatedOnEmployeeBehalf extends Notification
$user = $this->vacationRequest->user->first_name;
$title = $this->vacationRequest->name;
$type = $this->vacationRequest->type->label();
$from = $this->vacationRequest->from->toDisplayDate();
$to = $this->vacationRequest->to->toDisplayDate();
$from = $this->vacationRequest->from->toDisplayString();
$to = $this->vacationRequest->to->toDisplayString();
$days = $this->vacationRequest->vacations()->count();
$appName = config("app.name");

View File

@ -45,8 +45,8 @@ class VacationRequestRejectedNotification extends Notification
$user = $this->user->first_name;
$title = $this->vacationRequest->name;
$type = $this->vacationRequest->type->label();
$from = $this->vacationRequest->from->toDisplayDate();
$to = $this->vacationRequest->to->toDisplayDate();
$from = $this->vacationRequest->from->toDisplayString();
$to = $this->vacationRequest->to->toDisplayString();
$days = $this->vacationRequest->vacations()->count();
$requester = $this->vacationRequest->user->fullName;

View File

@ -46,8 +46,8 @@ class VacationRequestWaitsForAdminApprovalNotification extends Notification
$requester = $this->vacationRequest->user->fullName;
$title = $this->vacationRequest->name;
$type = $this->vacationRequest->type->label();
$from = $this->vacationRequest->from->toDisplayDate();
$to = $this->vacationRequest->to->toDisplayDate();
$from = $this->vacationRequest->from->toDisplayString();
$to = $this->vacationRequest->to->toDisplayString();
$days = $this->vacationRequest->vacations()->count();
return (new MailMessage())

View File

@ -46,8 +46,8 @@ class VacationRequestWaitsForTechApprovalNotification extends Notification
$requester = $this->vacationRequest->user->fullName;
$title = $this->vacationRequest->name;
$type = $this->vacationRequest->type->label();
$from = $this->vacationRequest->from->toDisplayDate();
$to = $this->vacationRequest->to->toDisplayDate();
$from = $this->vacationRequest->from->toDisplayString();
$to = $this->vacationRequest->to->toDisplayString();
$days = $this->vacationRequest->vacations()->count();
return (new MailMessage())

View File

@ -10,6 +10,11 @@ use Toby\Eloquent\Models\VacationRequest;
class VacationRequestPolicy
{
public function listAll(User $user): bool
{
return in_array($user->role, [Role::AdministrativeApprover, Role::TechnicalApprover], true);
}
public function createOnBehalfOfEmployee(User $user): bool
{
return $user->role === Role::AdministrativeApprover;

View File

@ -24,8 +24,8 @@ use PhpOffice\PhpSpreadsheet\Style\Border;
use PhpOffice\PhpSpreadsheet\Style\Fill;
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
use Toby\Domain\Enums\VacationRequestState;
use Toby\Domain\Enums\VacationType;
use Toby\Domain\States\VacationRequest\Approved;
use Toby\Eloquent\Models\Holiday;
use Toby\Eloquent\Models\User;
use Toby\Eloquent\Models\Vacation;
@ -189,7 +189,7 @@ class TimesheetPerUserSheet implements WithTitle, WithHeadings, WithEvents, With
return $user->vacations()
->with("vacationRequest")
->whereBetween("date", [$period->start, $period->end])
->whereRelation("vacationRequest", "state", VacationRequestState::Approved->value)
->whereRelation("vacationRequest", "state", Approved::$name)
->get()
->groupBy(
[

View File

@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Toby\Domain;
use Toby\Domain\Enums\Role;
use Toby\Domain\States\VacationRequest\AcceptedByAdministrative;
use Toby\Domain\States\VacationRequest\AcceptedByTechnical;
use Toby\Domain\States\VacationRequest\Approved;
@ -12,6 +13,7 @@ use Toby\Domain\States\VacationRequest\Created;
use Toby\Domain\States\VacationRequest\Rejected;
use Toby\Domain\States\VacationRequest\WaitingForAdministrative;
use Toby\Domain\States\VacationRequest\WaitingForTechnical;
use Toby\Eloquent\Models\User;
class VacationRequestStatesRetriever
{
@ -39,6 +41,16 @@ class VacationRequestStatesRetriever
];
}
public static function waitingForUserActionStates(User $user): array
{
return match ($user->role) {
Role::AdministrativeApprover => [WaitingForAdministrative::class],
Role::TechnicalApprover => [WaitingForTechnical::class],
Role::Administrator => [WaitingForAdministrative::class, WaitingForTechnical::class],
default => [],
};
}
public static function all(): array
{
return [
@ -48,12 +60,13 @@ class VacationRequestStatesRetriever
];
}
public static function filterByStatus(string $filter): array
public static function filterByStatusGroup(string $filter, ?User $user = null): array
{
return match ($filter) {
"pending" => self::pendingStates(),
"success" => self::successStates(),
"failed" => self::failedStates(),
"waiting_for_action" => self::waitingForUserActionStates($user),
default => self::all(),
};
}

View File

@ -35,10 +35,18 @@ class DashboardController extends Controller
)
->get();
if ($user->can("listAll", VacationRequest::class)) {
$vacationRequests = VacationRequest::query()
->states(VacationRequestStatesRetriever::waitingForUserActionStates($user))
->latest("updated_at")
->limit(3)
->get();
} else {
$vacationRequests = $user->vacationRequests()
->latest("updated_at")
->limit(3)
->get();
}
$holidays = Holiday::query()
->whereDate("date", ">=", $now)
@ -63,6 +71,9 @@ class DashboardController extends Controller
"pending" => $pending,
"other" => $other,
],
"can" => [
"listAllVacationRequests" => $user->can("listAll", VacationRequest::class),
],
]);
}
}

View File

@ -40,7 +40,7 @@ class VacationRequestController extends Controller
->with("vacations")
->where("year_period_id", $yearPeriodRetriever->selected()->id)
->latest()
->states(VacationRequestStatesRetriever::filterByStatus($status))
->states(VacationRequestStatesRetriever::filterByStatusGroup($status, $request->user()))
->paginate();
return inertia("VacationRequest/Index", [
@ -51,6 +51,45 @@ class VacationRequestController extends Controller
]);
}
public function indexForApprovers(
Request $request,
YearPeriodRetriever $yearPeriodRetriever,
): RedirectResponse|Response {
if ($request->user()->cannot("listAll", VacationRequest::class)) {
return redirect()->route("vacation.requests.index");
}
$yearPeriod = $yearPeriodRetriever->selected();
$status = $request->get("status");
$user = $request->get("user");
$vacationRequests = VacationRequest::query()
->with(["user", "vacations"])
->where("year_period_id", $yearPeriod->id)
->when($user !== null, fn(Builder $query) => $query->where("user_id", $user))
->when($status !== null, fn(Builder $query) => $query->states(VacationRequestStatesRetriever::filterByStatusGroup($status, $request->user())))
->latest()
->paginate();
$users = User::query()
->whereRelation(
"vacationlimits",
fn(Builder $query) => $query->where("year_period_id", $yearPeriod->id)->whereNotNull("days"),
)
->orderBy("last_name")
->orderBy("first_name")
->get();
return inertia("VacationRequest/IndexForApprovers", [
"requests" => VacationRequestResource::collection($vacationRequests),
"users" => UserResource::collection($users),
"filters" => [
"status" => $status,
"user" => $user,
],
]);
}
/**
* @throws AuthorizationException
*/

View File

@ -7,6 +7,7 @@ namespace Toby\Infrastructure\Http\Middleware;
use Illuminate\Http\Request;
use Inertia\Middleware;
use Toby\Eloquent\Helpers\YearPeriodRetriever;
use Toby\Eloquent\Models\VacationRequest;
use Toby\Infrastructure\Http\Resources\UserResource;
class HandleInertiaRequests extends Middleware
@ -25,6 +26,7 @@ class HandleInertiaRequests extends Middleware
"can" => [
"manageVacationLimits" => $user ? $user->can("manageVacationLimits") : false,
"manageUsers" => $user ? $user->can("manageUsers") : false,
"listAllVacationRequests" => $user ? $user->can("listAll", VacationRequest::class) : false,
],
],
"flash" => fn() => [

View File

@ -13,7 +13,7 @@ class VacationRequestActivityResource extends JsonResource
public function toArray($request): array
{
return [
"date" => $this->created_at->toDisplayDate(),
"date" => $this->created_at->toDisplayString(),
"time" => $this->created_at->format("H:i"),
"user" => $this->user ? $this->user->fullName : __("System"),
"state" => $this->to,

158
composer.lock generated
View File

@ -1093,16 +1093,16 @@
},
{
"name": "google/apiclient-services",
"version": "v0.237.0",
"version": "v0.238.0",
"source": {
"type": "git",
"url": "https://github.com/googleapis/google-api-php-client-services.git",
"reference": "c10652adc29b4242237075acde318e83f88ab918"
"reference": "627e6cda424d690640504e03f3e2e1259d952363"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/googleapis/google-api-php-client-services/zipball/c10652adc29b4242237075acde318e83f88ab918",
"reference": "c10652adc29b4242237075acde318e83f88ab918",
"url": "https://api.github.com/repos/googleapis/google-api-php-client-services/zipball/627e6cda424d690640504e03f3e2e1259d952363",
"reference": "627e6cda424d690640504e03f3e2e1259d952363",
"shasum": ""
},
"require": {
@ -1131,9 +1131,9 @@
],
"support": {
"issues": "https://github.com/googleapis/google-api-php-client-services/issues",
"source": "https://github.com/googleapis/google-api-php-client-services/tree/v0.237.0"
"source": "https://github.com/googleapis/google-api-php-client-services/tree/v0.238.0"
},
"time": "2022-02-23T22:58:02+00:00"
"time": "2022-03-06T01:18:12+00:00"
},
{
"name": "google/auth",
@ -2587,16 +2587,16 @@
},
{
"name": "league/flysystem",
"version": "3.0.10",
"version": "3.0.11",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/flysystem.git",
"reference": "bbc5026adb5a423dfcdcecec74c7e15943ff6115"
"reference": "1ca148713c23cadeb9d7526973f81fb4a04090a3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/flysystem/zipball/bbc5026adb5a423dfcdcecec74c7e15943ff6115",
"reference": "bbc5026adb5a423dfcdcecec74c7e15943ff6115",
"url": "https://api.github.com/repos/thephpleague/flysystem/zipball/1ca148713c23cadeb9d7526973f81fb4a04090a3",
"reference": "1ca148713c23cadeb9d7526973f81fb4a04090a3",
"shasum": ""
},
"require": {
@ -2657,7 +2657,7 @@
],
"support": {
"issues": "https://github.com/thephpleague/flysystem/issues",
"source": "https://github.com/thephpleague/flysystem/tree/3.0.10"
"source": "https://github.com/thephpleague/flysystem/tree/3.0.11"
},
"funding": [
{
@ -2673,7 +2673,7 @@
"type": "tidelift"
}
],
"time": "2022-02-26T11:09:13+00:00"
"time": "2022-03-04T16:40:17+00:00"
},
{
"name": "league/mime-type-detection",
@ -5697,16 +5697,16 @@
},
{
"name": "symfony/http-foundation",
"version": "v6.0.5",
"version": "v6.0.6",
"source": {
"type": "git",
"url": "https://github.com/symfony/http-foundation.git",
"reference": "b460fb15905eef449c4c43a4f0c113eccee103b9"
"reference": "a000fcf2298a1bc79a1dcff22608792506534719"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/http-foundation/zipball/b460fb15905eef449c4c43a4f0c113eccee103b9",
"reference": "b460fb15905eef449c4c43a4f0c113eccee103b9",
"url": "https://api.github.com/repos/symfony/http-foundation/zipball/a000fcf2298a1bc79a1dcff22608792506534719",
"reference": "a000fcf2298a1bc79a1dcff22608792506534719",
"shasum": ""
},
"require": {
@ -5749,7 +5749,7 @@
"description": "Defines an object-oriented layer for the HTTP specification",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/http-foundation/tree/v6.0.5"
"source": "https://github.com/symfony/http-foundation/tree/v6.0.6"
},
"funding": [
{
@ -5765,20 +5765,20 @@
"type": "tidelift"
}
],
"time": "2022-02-21T17:15:17+00:00"
"time": "2022-03-05T21:04:00+00:00"
},
{
"name": "symfony/http-kernel",
"version": "v6.0.5",
"version": "v6.0.6",
"source": {
"type": "git",
"url": "https://github.com/symfony/http-kernel.git",
"reference": "5ad3f5e5fa772a8b5c6bb217f8379b533afac2ba"
"reference": "f9e49ad9fe16895b24cd7a09dc28d3364282e21a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/http-kernel/zipball/5ad3f5e5fa772a8b5c6bb217f8379b533afac2ba",
"reference": "5ad3f5e5fa772a8b5c6bb217f8379b533afac2ba",
"url": "https://api.github.com/repos/symfony/http-kernel/zipball/f9e49ad9fe16895b24cd7a09dc28d3364282e21a",
"reference": "f9e49ad9fe16895b24cd7a09dc28d3364282e21a",
"shasum": ""
},
"require": {
@ -5858,7 +5858,7 @@
"description": "Provides a structured process for converting a Request into a Response",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/http-kernel/tree/v6.0.5"
"source": "https://github.com/symfony/http-kernel/tree/v6.0.6"
},
"funding": [
{
@ -5874,7 +5874,7 @@
"type": "tidelift"
}
],
"time": "2022-02-28T08:05:03+00:00"
"time": "2022-03-05T21:19:20+00:00"
},
{
"name": "symfony/mailer",
@ -6033,7 +6033,7 @@
},
{
"name": "symfony/polyfill-ctype",
"version": "v1.24.0",
"version": "v1.25.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-ctype.git",
@ -6095,7 +6095,7 @@
"portable"
],
"support": {
"source": "https://github.com/symfony/polyfill-ctype/tree/v1.24.0"
"source": "https://github.com/symfony/polyfill-ctype/tree/v1.25.0"
},
"funding": [
{
@ -6115,7 +6115,7 @@
},
{
"name": "symfony/polyfill-intl-grapheme",
"version": "v1.24.0",
"version": "v1.25.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-intl-grapheme.git",
@ -6176,7 +6176,7 @@
"shim"
],
"support": {
"source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.24.0"
"source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.25.0"
},
"funding": [
{
@ -6196,7 +6196,7 @@
},
{
"name": "symfony/polyfill-intl-idn",
"version": "v1.24.0",
"version": "v1.25.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-intl-idn.git",
@ -6263,7 +6263,7 @@
"shim"
],
"support": {
"source": "https://github.com/symfony/polyfill-intl-idn/tree/v1.24.0"
"source": "https://github.com/symfony/polyfill-intl-idn/tree/v1.25.0"
},
"funding": [
{
@ -6283,7 +6283,7 @@
},
{
"name": "symfony/polyfill-intl-normalizer",
"version": "v1.24.0",
"version": "v1.25.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-intl-normalizer.git",
@ -6347,7 +6347,7 @@
"shim"
],
"support": {
"source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.24.0"
"source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.25.0"
},
"funding": [
{
@ -6367,7 +6367,7 @@
},
{
"name": "symfony/polyfill-mbstring",
"version": "v1.24.0",
"version": "v1.25.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-mbstring.git",
@ -6430,7 +6430,7 @@
"shim"
],
"support": {
"source": "https://github.com/symfony/polyfill-mbstring/tree/v1.24.0"
"source": "https://github.com/symfony/polyfill-mbstring/tree/v1.25.0"
},
"funding": [
{
@ -6450,7 +6450,7 @@
},
{
"name": "symfony/polyfill-php72",
"version": "v1.24.0",
"version": "v1.25.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-php72.git",
@ -6506,7 +6506,7 @@
"shim"
],
"support": {
"source": "https://github.com/symfony/polyfill-php72/tree/v1.24.0"
"source": "https://github.com/symfony/polyfill-php72/tree/v1.25.0"
},
"funding": [
{
@ -6526,16 +6526,16 @@
},
{
"name": "symfony/polyfill-php80",
"version": "v1.24.0",
"version": "v1.25.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-php80.git",
"reference": "57b712b08eddb97c762a8caa32c84e037892d2e9"
"reference": "4407588e0d3f1f52efb65fbe92babe41f37fe50c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/57b712b08eddb97c762a8caa32c84e037892d2e9",
"reference": "57b712b08eddb97c762a8caa32c84e037892d2e9",
"url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/4407588e0d3f1f52efb65fbe92babe41f37fe50c",
"reference": "4407588e0d3f1f52efb65fbe92babe41f37fe50c",
"shasum": ""
},
"require": {
@ -6589,7 +6589,7 @@
"shim"
],
"support": {
"source": "https://github.com/symfony/polyfill-php80/tree/v1.24.0"
"source": "https://github.com/symfony/polyfill-php80/tree/v1.25.0"
},
"funding": [
{
@ -6605,11 +6605,11 @@
"type": "tidelift"
}
],
"time": "2021-09-13T13:58:33+00:00"
"time": "2022-03-04T08:16:47+00:00"
},
{
"name": "symfony/polyfill-php81",
"version": "v1.24.0",
"version": "v1.25.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-php81.git",
@ -6668,7 +6668,7 @@
"shim"
],
"support": {
"source": "https://github.com/symfony/polyfill-php81/tree/v1.24.0"
"source": "https://github.com/symfony/polyfill-php81/tree/v1.25.0"
},
"funding": [
{
@ -7004,16 +7004,16 @@
},
{
"name": "symfony/translation",
"version": "v6.0.5",
"version": "v6.0.6",
"source": {
"type": "git",
"url": "https://github.com/symfony/translation.git",
"reference": "e69501c71107cc3146b32aaa45f4edd0c3427875"
"reference": "f6639cb9b5e0c57fe31e3263b900a77eedb0c908"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/translation/zipball/e69501c71107cc3146b32aaa45f4edd0c3427875",
"reference": "e69501c71107cc3146b32aaa45f4edd0c3427875",
"url": "https://api.github.com/repos/symfony/translation/zipball/f6639cb9b5e0c57fe31e3263b900a77eedb0c908",
"reference": "f6639cb9b5e0c57fe31e3263b900a77eedb0c908",
"shasum": ""
},
"require": {
@ -7079,7 +7079,7 @@
"description": "Provides tools to internationalize your application",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/translation/tree/v6.0.5"
"source": "https://github.com/symfony/translation/tree/v6.0.6"
},
"funding": [
{
@ -7095,7 +7095,7 @@
"type": "tidelift"
}
],
"time": "2022-02-09T15:52:48+00:00"
"time": "2022-03-02T12:58:14+00:00"
},
{
"name": "symfony/translation-contracts",
@ -7177,16 +7177,16 @@
},
{
"name": "symfony/var-dumper",
"version": "v6.0.5",
"version": "v6.0.6",
"source": {
"type": "git",
"url": "https://github.com/symfony/var-dumper.git",
"reference": "60d6a756d5f485df5e6e40b337334848f79f61ce"
"reference": "38358405ae948963c50a3aae3dfea598223ba15e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/var-dumper/zipball/60d6a756d5f485df5e6e40b337334848f79f61ce",
"reference": "60d6a756d5f485df5e6e40b337334848f79f61ce",
"url": "https://api.github.com/repos/symfony/var-dumper/zipball/38358405ae948963c50a3aae3dfea598223ba15e",
"reference": "38358405ae948963c50a3aae3dfea598223ba15e",
"shasum": ""
},
"require": {
@ -7245,7 +7245,7 @@
"dump"
],
"support": {
"source": "https://github.com/symfony/var-dumper/tree/v6.0.5"
"source": "https://github.com/symfony/var-dumper/tree/v6.0.6"
},
"funding": [
{
@ -7261,7 +7261,7 @@
"type": "tidelift"
}
],
"time": "2022-02-21T17:15:17+00:00"
"time": "2022-03-02T12:58:14+00:00"
},
{
"name": "tijsverkoyen/css-to-inline-styles",
@ -9011,16 +9011,16 @@
},
{
"name": "phpunit/php-code-coverage",
"version": "9.2.14",
"version": "9.2.15",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
"reference": "9f4d60b6afe5546421462b76cd4e633ebc364ab4"
"reference": "2e9da11878c4202f97915c1cb4bb1ca318a63f5f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/9f4d60b6afe5546421462b76cd4e633ebc364ab4",
"reference": "9f4d60b6afe5546421462b76cd4e633ebc364ab4",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/2e9da11878c4202f97915c1cb4bb1ca318a63f5f",
"reference": "2e9da11878c4202f97915c1cb4bb1ca318a63f5f",
"shasum": ""
},
"require": {
@ -9076,7 +9076,7 @@
],
"support": {
"issues": "https://github.com/sebastianbergmann/php-code-coverage/issues",
"source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.14"
"source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.15"
},
"funding": [
{
@ -9084,7 +9084,7 @@
"type": "github"
}
],
"time": "2022-02-28T12:38:02+00:00"
"time": "2022-03-07T09:28:20+00:00"
},
{
"name": "phpunit/php-file-iterator",
@ -9329,16 +9329,16 @@
},
{
"name": "phpunit/phpunit",
"version": "9.5.16",
"version": "9.5.17",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "5ff8c545a50226c569310a35f4fa89d79f1ddfdc"
"reference": "5c5abcfaa2cbd44b2203995d7a339ef910fe0c8f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/5ff8c545a50226c569310a35f4fa89d79f1ddfdc",
"reference": "5ff8c545a50226c569310a35f4fa89d79f1ddfdc",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/5c5abcfaa2cbd44b2203995d7a339ef910fe0c8f",
"reference": "5c5abcfaa2cbd44b2203995d7a339ef910fe0c8f",
"shasum": ""
},
"require": {
@ -9416,7 +9416,7 @@
],
"support": {
"issues": "https://github.com/sebastianbergmann/phpunit/issues",
"source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.16"
"source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.17"
},
"funding": [
{
@ -9428,7 +9428,7 @@
"type": "github"
}
],
"time": "2022-02-23T17:10:58+00:00"
"time": "2022-03-05T16:54:31+00:00"
},
{
"name": "sebastian/cli-parser",
@ -10522,16 +10522,16 @@
},
{
"name": "spatie/ignition",
"version": "1.1.1",
"version": "1.2.1",
"source": {
"type": "git",
"url": "https://github.com/spatie/ignition.git",
"reference": "5c554067887b7080bc58977fa30a488624d85d20"
"reference": "090518ff676e17a038dfe77490018363ff66af20"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/spatie/ignition/zipball/5c554067887b7080bc58977fa30a488624d85d20",
"reference": "5c554067887b7080bc58977fa30a488624d85d20",
"url": "https://api.github.com/repos/spatie/ignition/zipball/090518ff676e17a038dfe77490018363ff66af20",
"reference": "090518ff676e17a038dfe77490018363ff66af20",
"shasum": ""
},
"require": {
@ -10589,7 +10589,7 @@
"type": "github"
}
],
"time": "2022-03-02T10:51:55+00:00"
"time": "2022-03-04T12:52:17+00:00"
},
{
"name": "spatie/laravel-ignition",
@ -10680,16 +10680,16 @@
},
{
"name": "symfony/filesystem",
"version": "v6.0.5",
"version": "v6.0.6",
"source": {
"type": "git",
"url": "https://github.com/symfony/filesystem.git",
"reference": "6646c13f787057d64701a3a0235cf9567c6ccbbd"
"reference": "52b888523545b0b4049ab9ce48766802484d7046"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/filesystem/zipball/6646c13f787057d64701a3a0235cf9567c6ccbbd",
"reference": "6646c13f787057d64701a3a0235cf9567c6ccbbd",
"url": "https://api.github.com/repos/symfony/filesystem/zipball/52b888523545b0b4049ab9ce48766802484d7046",
"reference": "52b888523545b0b4049ab9ce48766802484d7046",
"shasum": ""
},
"require": {
@ -10723,7 +10723,7 @@
"description": "Provides basic utilities for the filesystem",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/filesystem/tree/v6.0.5"
"source": "https://github.com/symfony/filesystem/tree/v6.0.6"
},
"funding": [
{
@ -10739,7 +10739,7 @@
"type": "tidelift"
}
],
"time": "2022-02-28T07:42:30+00:00"
"time": "2022-03-02T12:58:14+00:00"
},
{
"name": "symfony/options-resolver",

View File

@ -9,14 +9,16 @@ RUN if [ ${INSTALL_XDEBUG} = true ]; then \
&& docker-php-ext-enable xdebug \
;fi
RUN pecl install redis \
&& apk --no-cache add \
RUN apk add --no-cache pcre-dev $PHPIZE_DEPS \
postgresql-dev \
zip \
libzip-dev \
libpng-dev \
&& pecl install redis \
&& docker-php-ext-install \
pdo_pgsql \
zip \
gd \
&& docker-php-ext-configure \
zip \
&& docker-php-ext-enable \

View File

@ -123,6 +123,12 @@ const statuses = [
},
]
export function useStatusInfo(status) {
return statuses.find(statusInfo => statusInfo.value === status)
export function useStatusInfo() {
const getStatues = () => statuses
const findStatus = value => statuses.find(month => month.value === value)
return {
getStatues,
findStatus,
}
}

View File

@ -11,7 +11,6 @@
<img
class="mx-auto h-20 w-20 rounded-full"
:src="user.avatar"
alt=""
>
</div>
<div class="mt-4 text-center sm:mt-0 sm:pt-1 sm:text-left">
@ -98,7 +97,73 @@
</section>
</div>
<div class="grid grid-cols-1 gap-4">
<section>
<section v-if="can.listAllVacationRequests">
<div class="bg-white shadow-md">
<div class="p-4 sm:px-6">
<h2 class="text-lg leading-6 font-medium text-gray-900">
Wnioski oczekujące na akcje
</h2>
</div>
<div class="border-t border-gray-200 pb-5 px-4 sm:px-6">
<div class="flow-root mt-6">
<ul class="-my-5 divide-y divide-gray-200">
<li
v-for="request in vacationRequests.data"
:key="request.id"
class="py-5"
>
<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">
<InertiaLink
:href="`/vacation-requests/${request.id}`"
class="hover:underline focus:outline-none"
>
<span class="absolute inset-0" />
Wniosek o {{ request.type.toLowerCase() }}
[{{ request.name }}]
</InertiaLink>
</h3>
<p class="mt-1 text-sm text-gray-600">
{{ request.from }} - {{ request.to }}
</p>
<div class="mt-3 text-sm text-gray-600">
<div class="flex">
<img
class="h-10 w-10 rounded-full"
:src="request.user.avatar"
>
<div class="ml-3">
<p class="text-sm font-medium text-gray-900">
{{ request.user.name }}
</p>
<p class="text-sm text-gray-500">
{{ request.user.email }}
</p>
</div>
</div>
</div>
</div>
</li>
<li v-if="! vacationRequests.data.length">
<p class="py-2">
Brak danych
</p>
</li>
</ul>
</div>
<div class="mt-6">
<InertiaLink
href="/vacation-requests"
: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"
>
Zobacz wszystkie
</InertiaLink>
</div>
</div>
</div>
</section>
<section v-else>
<div class="bg-white shadow-md">
<div class="p-4 sm:px-6">
<h2 class="text-lg leading-6 font-medium text-gray-900">
@ -113,7 +178,7 @@
:key="request.id"
class="py-5"
>
<div class="relative focus-within:ring-2 focus-within:ring-cyan-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">
<InertiaLink
:href="`/vacation-requests/${request.id}`"
@ -132,12 +197,17 @@
</p>
</div>
</li>
<li v-if="! vacationRequests.data.length">
<p class="py-2">
Brak danych
</p>
</li>
</ul>
</div>
<div class="mt-6">
<InertiaLink
href="/vacation-requests"
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"
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"
>
Zobacz wszystkie
</InertiaLink>
@ -205,11 +275,16 @@
</p>
</div>
</li>
<li v-if="! holidays.data.length">
<p class="py-2">
Brak danych
</p>
</li>
</ul>
<div>
<InertiaLink
href="/holidays"
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"
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
</InertiaLink>
@ -244,6 +319,10 @@ export default {
type: Object,
default: null,
},
can: {
type: Object,
default: null,
},
stats: {
type: Object,
default: () => ({

View File

@ -9,7 +9,7 @@
</div>
<div>
<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"
>
Dodaj wniosek
@ -74,7 +74,7 @@
<tr
v-for="request in requests.data"
:key="request.id"
class="hover:bg-blumilk-25"
class="hover:bg-blumilk-25 relative"
>
<td class="px-4 py-4 whitespace-nowrap text-sm text-gray-500">
<InertiaLink
@ -106,6 +106,10 @@
>
<ChevronRightIcon class="block w-6 h-6 fill-blumilk-500" />
</InertiaLink>
<InertiaLink
:href="`/vacation-requests/${request.id}`"
class="absolute inset-0"
/>
</td>
</tr>
<tr

View File

@ -0,0 +1,436 @@
<template>
<InertiaHead title="Wnioski urlopowe" />
<div class="bg-white shadow-md">
<div class="flex justify-between items-center p-4 sm:px-6">
<div>
<h2 class="text-lg leading-6 font-medium text-gray-900">
Wnioski urlopowe
</h2>
</div>
<div>
<InertiaLink
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"
>
Dodaj wniosek
</InertiaLink>
</div>
</div>
<div class="overflow-x-auto xl:overflow-x-visible overflow-y-auto xl:overflow-y-visible">
<div class="border-t border-gray-200">
<div class="px-4 grid grid-cols-2 gap-4">
<div>
<Listbox
v-model="form.user"
as="div"
class="py-4 items-center"
>
<ListboxLabel class="block text-sm font-medium text-gray-700 mb-2">
Pracownik
</ListboxLabel>
<div class="mt-1 relative sm:mt-0">
<ListboxButton
class="bg-white relative w-full max-w-lg border rounded-md shadow-sm pl-3 pr-10 py-2 text-left cursor-default sm:text-sm focus:ring-1 focus:ring-blumilk-500 focus:border-blumilk-500 sm:text-sm border-gray-300"
>
<span v-if="form.user === null">
Wszyscy
</span>
<span
v-else
class="flex items-center"
>
<img
:src="form.user.avatar"
class="flex-shrink-0 h-6 w-6 rounded-full"
>
<span class="ml-3 block truncate">{{ form.user.name }}</span>
</span>
<span class="absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none">
<SelectorIcon class="h-5 w-5 text-gray-400" />
</span>
</ListboxButton>
<transition
leave-active-class="transition ease-in duration-100"
leave-from-class="opacity-100"
leave-to-class="opacity-0"
>
<ListboxOptions
class="absolute z-10 mt-1 w-full max-w-lg bg-white shadow-lg max-h-60 rounded-md py-1 text-base ring-1 ring-black ring-opacity-5 overflow-auto focus:outline-none sm:text-sm"
>
<ListboxOption
v-slot="{ active }"
as="template"
:value="null"
>
<li
:class="[active ? 'text-white bg-blumilk-600' : 'text-gray-900', 'cursor-default select-none relative py-2 pl-3 pr-9']"
>
<div class="flex items-center">
Wszyscy pracownicy
</div>
<span
v-if="form.user === null"
:class="[active ? 'text-white' : 'text-blumilk-600', 'absolute inset-y-0 right-0 flex items-center pr-4']"
>
<CheckIcon class="h-5 w-5" />
</span>
</li>
</ListboxOption>
<ListboxOption
v-for="user in users.data"
:key="user.id"
v-slot="{ active }"
as="template"
:value="user"
>
<li
:class="[active ? 'text-white bg-blumilk-600' : 'text-gray-900', 'cursor-default select-none relative py-2 pl-3 pr-9']"
>
<div class="flex items-center">
<img
:src="user.avatar"
class="flex-shrink-0 h-6 w-6 rounded-full"
>
<span :class="[form.user?.id === user.id ? 'font-semibold' : 'font-normal', 'ml-3 block truncate']">
{{ user.name }}
</span>
</div>
<span
v-if="form.user?.id === user.id"
:class="[active ? 'text-white' : 'text-blumilk-600', 'absolute inset-y-0 right-0 flex items-center pr-4']"
>
<CheckIcon class="h-5 w-5" />
</span>
</li>
</ListboxOption>
</ListboxOptions>
</transition>
</div>
</Listbox>
</div>
<div>
<Listbox
v-model="form.status"
as="div"
class="py-4 items-center"
>
<ListboxLabel class="block text-sm font-medium text-gray-700 mb-2">
Status
</ListboxLabel>
<div class="mt-1 relative sm:mt-0">
<ListboxButton
class="bg-white relative w-full max-w-lg border rounded-md shadow-sm pl-3 pr-10 py-2 text-left cursor-default sm:text-sm focus:ring-1 focus:ring-blumilk-500 focus:border-blumilk-500 sm:text-sm border-gray-300"
>
<span
class="flex items-center"
>
{{ form.status.name }}
</span>
<span class="absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none">
<SelectorIcon class="h-5 w-5 text-gray-400" />
</span>
</ListboxButton>
<transition
leave-active-class="transition ease-in duration-100"
leave-from-class="opacity-100"
leave-to-class="opacity-0"
>
<ListboxOptions
class="absolute z-10 mt-1 w-full max-w-lg bg-white shadow-lg max-h-60 rounded-md py-1 text-base ring-1 ring-black ring-opacity-5 overflow-auto focus:outline-none sm:text-sm"
>
<ListboxOption
v-for="status in statuses"
:key="status.value"
v-slot="{ active, selected }"
as="template"
:value="status"
>
<li
:class="[active ? 'text-white bg-blumilk-600' : 'text-gray-900', 'cursor-default select-none relative py-2 pl-3 pr-9']"
>
{{ status.name }}
<span
v-if="selected"
:class="[active ? 'text-white' : 'text-blumilk-600', 'absolute inset-y-0 right-0 flex items-center pr-4']"
>
<CheckIcon class="h-5 w-5" />
</span>
</li>
</ListboxOption>
</ListboxOptions>
</transition>
</div>
</Listbox>
</div>
</div>
</div>
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th
scope="col"
class="px-4 py-3 text-left text-xs font-semibold text-gray-500 uppercase tracking-wider"
>
Numer
</th>
<th
scope="col"
class="px-4 py-3 text-left text-xs font-semibold text-gray-500 uppercase tracking-wider"
>
Pracownik
</th>
<th
scope="col"
class="px-4 py-3 text-left text-xs font-semibold text-gray-500 uppercase tracking-wider"
>
Rodzaj urlopu
</th>
<th
scope="col"
class="px-4 py-3 text-left text-xs font-semibold text-gray-500 uppercase tracking-wider"
>
Od
</th>
<th
scope="col"
class="px-4 py-3 text-left text-xs font-semibold text-gray-500 uppercase tracking-wider"
>
Do
</th>
<th
scope="col"
class="px-4 py-3 text-left text-xs font-semibold text-gray-500 uppercase tracking-wider"
>
Dni urlopu
</th>
<th
scope="col"
class="px-4 py-3 text-left text-xs font-semibold text-gray-500 uppercase tracking-wider"
>
Status
</th>
<th scope="col" />
</tr>
</thead>
<tbody class="bg-white divide-y divide-gray-100">
<tr
v-for="request in requests.data"
:key="request.id"
class="hover:bg-blumilk-25 relative"
>
<td class="px-4 py-4 whitespace-nowrap text-sm text-gray-500">
<InertiaLink
:href="`/vacation-requests/${request.id}`"
class="font-semibold text-blumilk-600 hover:text-blumilk-500 hover:underline"
>
{{ request.name }}
</InertiaLink>
</td>
<td class="px-4 py-4 whitespace-nowrap text-sm font-medium text-gray-500">
<div class="flex">
<img
class="h-10 w-10 rounded-full"
:src="request.user.avatar"
>
<div class="ml-3">
<p class="text-sm font-medium text-gray-900">
{{ request.user.name }}
</p>
<p class="text-sm text-gray-500">
{{ request.user.email }}
</p>
</div>
</div>
</td>
<td class="px-4 py-4 whitespace-nowrap text-sm font-medium text-gray-500">
{{ request.type }}
</td>
<td class="px-4 py-4 whitespace-nowrap text-sm text-gray-500">
{{ request.from }}
</td>
<td class="px-4 py-4 whitespace-nowrap text-sm text-gray-500">
{{ request.to }}
</td>
<td class="px-4 py-4 whitespace-nowrap text-sm text-gray-500">
{{ request.days.length }}
</td>
<td class="px-4 py-4 whitespace-nowrap text-sm text-gray-500">
<Status :status="request.state" />
</td>
<td class="px-4 py-4 whitespace-nowrap text-sm text-gray-500">
<InertiaLink
:href="`/vacation-requests/${request.id}`"
class="flex justify-around"
>
<ChevronRightIcon class="block w-6 h-6 fill-blumilk-500" />
</InertiaLink>
<InertiaLink
:href="`/vacation-requests/${request.id}`"
class="absolute inset-0"
/>
</td>
</tr>
<tr
v-if="! requests.data.length"
>
<td
colspan="100%"
class="text-center py-4 text-xl leading-5 text-gray-700"
>
Brak danych
</td>
</tr>
</tbody>
</table>
<div
v-if="requests.data.length && requests.meta.last_page !== 1"
class="bg-white px-4 py-3 flex items-center justify-between border-t border-gray-200 sm:px-6 rounded-b-lg"
>
<div class="flex-1 flex justify-between sm:hidden">
<InertiaLink
:is="requests.links.prev ? 'InertiaLink': 'span'"
:href="requests.links.prev"
class="relative inline-flex items-center px-4 py-2 border border-gray-300 text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50"
>
Poprzednia
</InertiaLink>
<Component
:is="requests.links.next ? 'InertiaLink': 'span'"
:href="requests.links.next"
class="ml-3 relative inline-flex items-center px-4 py-2 border border-gray-300 text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50"
>
Następna
</Component>
</div>
<div class="hidden sm:flex-1 sm:flex sm:items-center sm:justify-between">
<div class="text-sm text-gray-700">
Wyświetlanie
<span class="font-medium">{{ requests.meta.from }}</span>
od
<span class="font-medium">{{ requests.meta.to }}</span>
do
<span class="font-medium">{{ requests.meta.total }}</span>
wyników
</div>
<nav class="relative z-0 inline-flex space-x-1">
<template
v-for="(link, index) in requests.meta.links"
:key="index"
>
<Component
:is="link.url ? 'InertiaLink' : 'span'"
:href="link.url"
:preserve-scroll="true"
class="relative inline-flex items-center px-4 py-2 border rounded-md text-sm font-medium"
:class="{ 'z-10 bg-blumilk-25 border-blumilk-500 text-blumilk-600': link.active, 'bg-white border-gray-300 text-gray-500': !link.active, 'hover:bg-blumilk-25': link.url, 'border-none': !link.url}"
v-text="link.label"
/>
</template>
</nav>
</div>
</div>
</div>
</div>
</template>
<script>
import {
CheckIcon,
ChevronRightIcon,
ClockIcon,
DocumentTextIcon,
DotsVerticalIcon,
PencilIcon,
SelectorIcon,
ThumbDownIcon,
ThumbUpIcon,
TrashIcon,
XCircleIcon,
XIcon,
} from '@heroicons/vue/solid'
import Status from '@/Shared/Status'
import {watch, reactive} from 'vue'
import {debounce} from 'lodash'
import {Inertia} from '@inertiajs/inertia'
import {Listbox, ListboxButton, ListboxLabel, ListboxOption, ListboxOptions} from '@headlessui/vue'
export default {
name: 'VacationRequestIndex',
components: {
Listbox,
ListboxButton,
ListboxLabel,
ListboxOption,
ListboxOptions,
DotsVerticalIcon,
PencilIcon,
TrashIcon,
ChevronRightIcon,
ThumbUpIcon,
ClockIcon,
XIcon,
CheckIcon,
DocumentTextIcon,
ThumbDownIcon,
Status,
SelectorIcon,
XCircleIcon,
},
props: {
requests: {
type: Object,
default: () => null,
},
users: {
type: Object,
default: () => null,
},
filters: {
type: Object,
default: () => null,
},
},
setup(props) {
const statuses = [
{
name: 'Wszystkie',
value: 'all',
},
{
name: 'Oczekujące na akcje',
value: 'waiting_for_action',
},
{
name: 'W trakcie',
value: 'pending',
},
{
name: 'Zatwierdzone',
value: 'success',
},
{
name: 'Odrzucone/anulowane',
value: 'failed',
},
]
const form = reactive({
user: props.users.data.find(user => user.id === props.filters.user) ?? null,
status: statuses.find(status => status.value === props.filters.status) ?? statuses[0],
})
watch(form, debounce(() => {
Inertia.get('/vacation-requests', {user: form.user?.id, status: form.status.value}, {
preserveState: true,
replace: true,
})
}, 300))
return {form, statuses}
},
}
</script>

View File

@ -19,11 +19,24 @@
</dd>
</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">
<dt class="text-sm font-medium text-gray-500 flex items-center">
Pracownik
</dt>
<dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
<div class="flex">
<img
class="h-10 w-10 rounded-full"
:src="request.user.avatar"
>
<div class="ml-3">
<p class="text-sm font-medium text-gray-900">
{{ request.user.name }}
</p>
<p class="text-sm text-gray-500">
{{ request.user.email }}
</p>
</div>
</div>
</dd>
</div>
<div class="py-4 sm:py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
@ -44,26 +57,17 @@
</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">
Urlop od
Data
</dt>
<dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
<span class="font-semibold">
<template v-if="request.days.length > 1">
{{ request.from }} - {{ request.to }} [Liczba dni: {{ request.days.length }}]
</template>
<template v-else>
{{ request.from }}
</dd>
</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">
Urlop do
</dt>
<dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
{{ request.to }}
</dd>
</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">
Dni urlopu
</dt>
<dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
{{ request.days.length }}
</template>
</span>
</dd>
</div>
<div class="py-4 sm:py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
@ -84,7 +88,7 @@
</dd>
</div>
<div class="bg-white px-4 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 flex items-center">
Załączniki
</dt>
<dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">

View File

@ -48,7 +48,9 @@ export default {
},
},
setup(props) {
const statusInfo = computed(() => useStatusInfo(props.activity.state))
const { findStatus } = useStatusInfo()
const statusInfo = computed(() => findStatus(props.activity.state))
return {
statusInfo,

View File

@ -74,7 +74,7 @@
v-for="item in navigation"
:key="item.name"
:href="item.href"
:class="[$page.url.startsWith(item.href) ? 'bg-blumilk-800 text-white' : 'text-blumilk-100 hover:text-white hover:bg-blumilk-600', 'group flex items-center px-2 py-2 text-base font-medium rounded-md']"
:class="[$page.url === item.href ? 'bg-blumilk-800 text-white' : 'text-blumilk-100 hover:text-white hover:bg-blumilk-600', 'group flex items-center px-2 py-2 text-base font-medium rounded-md']"
>
<component
:is="item.icon"
@ -119,7 +119,7 @@
v-for="item in navigation"
:key="item.name"
:href="item.href"
:class="[$page.url.startsWith(item.href) ? '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']"
:class="[$page.url === item.href ? '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"
@ -281,7 +281,7 @@ import {
XIcon,
SunIcon,
StarIcon,
CalendarIcon,
CalendarIcon, DocumentTextIcon,
} from '@heroicons/vue/outline'
import {
CashIcon,
@ -329,7 +329,8 @@ export default {
const navigation = computed(() =>
[
{name: 'Wnioski urlopowe', href: '/vacation-requests', icon: CollectionIcon, can: true},
{name: 'Moje wnioski', href: '/vacation-requests/me', icon: DocumentTextIcon, can: true},
{name: 'Wnioski urlopowe', href: '/vacation-requests', icon: CollectionIcon, can: auth.value.can.listAllVacationRequests},
{name: 'Kalendarz urlopów', href: '/vacation-calendar', icon: CalendarIcon, can: true},
{name: 'Dni wolne', href: '/holidays', icon: StarIcon, can: true},
{name: 'Limity urlopów', href: '/vacation-limits', icon: SunIcon, can: auth.value.can.manageVacationLimits},

View File

@ -25,7 +25,9 @@ export default {
},
},
setup(props) {
const statusInfo = computed(() => useStatusInfo(props.status))
const { findStatus } = useStatusInfo()
const statusInfo = computed(() => findStatus(props.status))
return {
statusInfo,

View File

@ -38,7 +38,7 @@ Flatpickr.localize(Polish)
Flatpickr.setDefaults({
dateFormat: 'Y-m-d',
enableTime: false,
altFormat: 'j F Y',
altFormat: 'd.m.Y',
altInput: true,
})

View File

@ -34,8 +34,10 @@ Route::middleware("auth")->group(function (): void {
Route::get("/vacation-limits", [VacationLimitController::class, "edit"])->name("vacation.limits");
Route::put("/vacation-limits", [VacationLimitController::class, "update"]);
Route::get("/vacation-requests", [VacationRequestController::class, "index"])
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"])

View File

@ -49,7 +49,7 @@ class VacationRequestTest extends FeatureTestCase
->create();
$this->actingAs($user)
->get("/vacation-requests")
->get("/vacation-requests/me")
->assertOk()
->assertInertia(
fn(Assert $page) => $page