From 4de50fee52933d0a87ffce97f207aaa363674e61 Mon Sep 17 00:00:00 2001 From: Adrian Hopek Date: Mon, 28 Oct 2024 12:55:48 +0100 Subject: [PATCH 1/5] #484 - user page navigation --- app/Http/Controllers/PermissionController.php | 2 +- app/Http/Controllers/UserController.php | 5 +- .../Controllers/UserHistoryController.php | 5 +- app/Http/Resources/UserFormDataResource.php | 2 + resources/js/Pages/AnnualSummary.vue | 3 +- .../AssignedBenefits/AssignedBenefits.vue | 3 +- resources/js/Pages/Benefits/Benefits.vue | 3 +- resources/js/Pages/BenefitsReport/Index.vue | 3 +- resources/js/Pages/BenefitsReport/Show.vue | 3 +- resources/js/Pages/Calendar.vue | 3 +- resources/js/Pages/Dashboard.vue | 3 +- resources/js/Pages/EmployeesMilestones.vue | 3 +- resources/js/Pages/Equipment/Create.vue | 3 +- resources/js/Pages/Equipment/Edit.vue | 3 +- resources/js/Pages/Equipment/Index.vue | 3 +- .../js/Pages/Equipment/IndexForEmployee.vue | 3 +- resources/js/Pages/EquipmentLabels.vue | 3 +- resources/js/Pages/Holidays/Create.vue | 3 +- resources/js/Pages/Holidays/Edit.vue | 3 +- resources/js/Pages/Holidays/Index.vue | 3 +- resources/js/Pages/Keys.vue | 3 +- resources/js/Pages/MonthlyUsage.vue | 3 +- .../Pages/OvertimeRequest/ApproversIndex.vue | 3 +- resources/js/Pages/OvertimeRequest/Create.vue | 3 +- resources/js/Pages/OvertimeRequest/Index.vue | 3 +- .../OvertimeRequest/IndexForApprovers.vue | 3 +- resources/js/Pages/OvertimeRequest/Show.vue | 3 +- resources/js/Pages/Permissions/Edit.vue | 44 ++-------- resources/js/Pages/Resumes/Create.vue | 3 +- resources/js/Pages/Resumes/Edit.vue | 3 +- resources/js/Pages/Resumes/Index.vue | 3 +- resources/js/Pages/Technologies.vue | 3 +- resources/js/Pages/UserHistory/Create.vue | 3 +- resources/js/Pages/UserHistory/Edit.vue | 3 +- resources/js/Pages/UserHistory/Index.vue | 13 ++- resources/js/Pages/Users/Create.vue | 3 +- resources/js/Pages/Users/Edit.vue | 31 +++---- resources/js/Pages/Users/Index.vue | 3 +- resources/js/Pages/Users/Show.vue | 33 ++------ resources/js/Pages/VacationLimits.vue | 3 +- resources/js/Pages/VacationRequest/Create.vue | 3 +- resources/js/Pages/VacationRequest/Index.vue | 3 +- .../VacationRequest/IndexForApprovers.vue | 3 +- resources/js/Pages/VacationRequest/Show.vue | 3 +- resources/js/Shared/Layout/AppLayout.vue | 8 +- resources/js/Shared/Layout/UserLayout.vue | 82 +++++++++++++++++++ 46 files changed, 161 insertions(+), 172 deletions(-) create mode 100644 resources/js/Shared/Layout/UserLayout.vue diff --git a/app/Http/Controllers/PermissionController.php b/app/Http/Controllers/PermissionController.php index 3bbff54f..7541aadc 100644 --- a/app/Http/Controllers/PermissionController.php +++ b/app/Http/Controllers/PermissionController.php @@ -42,7 +42,7 @@ public function update(PermissionRequest $request, UpdateUserPermissionsAction $ $action->execute($user, $request->input("permissions")); return redirect() - ->route("users.index") + ->back() ->with("success", __("Permissions updated.")); } } diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index 05776d0b..a026c3ec 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -94,7 +94,8 @@ public function edit(User $user): Response $this->authorize("manageUsers"); return inertia("Users/Edit", [ - "user" => new UserFormDataResource($user), + "user" => new UserResource($user), + "form" => new UserFormDataResource($user), "employmentForms" => EmploymentForm::casesToSelect(), "roles" => Role::casesToSelect(), ]); @@ -120,7 +121,7 @@ public function update( } return redirect() - ->route("users.index") + ->back() ->with("success", __("User updated.")); } diff --git a/app/Http/Controllers/UserHistoryController.php b/app/Http/Controllers/UserHistoryController.php index 6e3c5efc..f5bf9a80 100644 --- a/app/Http/Controllers/UserHistoryController.php +++ b/app/Http/Controllers/UserHistoryController.php @@ -10,6 +10,7 @@ use Toby\Enums\UserHistoryType; use Toby\Http\Requests\UserHistoryRequest; use Toby\Http\Resources\UserHistoryResource; +use Toby\Http\Resources\UserResource; use Toby\Models\User; use Toby\Models\UserHistory; @@ -25,7 +26,7 @@ public function index(User $user): Response return inertia("UserHistory/Index", [ "history" => UserHistoryResource::collection($history), - "userId" => $user->id, + "user" => new UserResource($user), ]); } @@ -47,7 +48,7 @@ public function store(UserHistoryRequest $request, User $user): RedirectResponse $user->histories()->create($request->data()); return redirect() - ->route("users.history", $user) + ->back("users.history", $user) ->with("success", __("User history created.")); } diff --git a/app/Http/Resources/UserFormDataResource.php b/app/Http/Resources/UserFormDataResource.php index 437ecd8e..fa9dee42 100644 --- a/app/Http/Resources/UserFormDataResource.php +++ b/app/Http/Resources/UserFormDataResource.php @@ -16,6 +16,8 @@ public function toArray($request): array "id" => $this->id, "firstName" => $this->profile->first_name, "lastName" => $this->profile->last_name, + "name" => $this->profile->full_name, + "avatar" => $this->profile->getAvatar(), "email" => $this->email, "role" => $this->role, "position" => $this->profile->position, diff --git a/resources/js/Pages/AnnualSummary.vue b/resources/js/Pages/AnnualSummary.vue index d885495e..10ae2f24 100644 --- a/resources/js/Pages/AnnualSummary.vue +++ b/resources/js/Pages/AnnualSummary.vue @@ -27,8 +27,7 @@ watch(selectedYear, (value, oldValue) => {