From 90e8812a98e47459dbe28b50843eef8f931b3f33 Mon Sep 17 00:00:00 2001 From: Adrian Hopek Date: Mon, 11 Apr 2022 08:47:35 +0200 Subject: [PATCH 01/15] fix css focuses --- resources/js/Composables/vacationTypeInfo.js | 4 ++-- resources/js/Pages/AnnualSummary.vue | 6 +++--- resources/js/Pages/Calendar.vue | 10 +++++----- resources/js/Pages/Users/Create.vue | 4 ++-- resources/js/Pages/Users/Edit.vue | 4 ++-- resources/js/Pages/VacationRequest/Create.vue | 4 ++-- resources/js/Pages/VacationRequest/Index.vue | 8 ++++---- .../js/Pages/VacationRequest/IndexForApprovers.vue | 6 +++--- resources/js/Shared/MainMenu.vue | 6 +++--- resources/lang/pl.json | 4 ++-- 10 files changed, 28 insertions(+), 28 deletions(-) diff --git a/resources/js/Composables/vacationTypeInfo.js b/resources/js/Composables/vacationTypeInfo.js index 1091b25..4f154cb 100644 --- a/resources/js/Composables/vacationTypeInfo.js +++ b/resources/js/Composables/vacationTypeInfo.js @@ -14,8 +14,8 @@ const types = [ text: 'Urlop wypoczynkowy', value: 'vacation', icon: WhiteBalanceSunnyIcon, - color: 'text-amber-300', - border: 'border-amber-300', + color: 'text-yellow-500', + border: 'border-yellow-500', }, { text: 'Urlop na żądanie', diff --git a/resources/js/Pages/AnnualSummary.vue b/resources/js/Pages/AnnualSummary.vue index 72b7dba..46f434b 100644 --- a/resources/js/Pages/AnnualSummary.vue +++ b/resources/js/Pages/AnnualSummary.vue @@ -39,7 +39,7 @@ offset-distance="0" >
-
diff --git a/resources/js/Shared/ActionButton.vue b/resources/js/Shared/ActionButton.vue deleted file mode 100644 index c47272e..0000000 --- a/resources/js/Shared/ActionButton.vue +++ /dev/null @@ -1,18 +0,0 @@ - - - diff --git a/resources/js/Shared/InertiaLink.js b/resources/js/Shared/InertiaLink.js new file mode 100644 index 0000000..d279539 --- /dev/null +++ b/resources/js/Shared/InertiaLink.js @@ -0,0 +1,65 @@ +import { h, ref } from 'vue' +import { Inertia, mergeDataIntoQueryString, shouldIntercept } from '@inertiajs/inertia' + +export default { + name: 'InertiaLink', + props: { + as: { + type: String, + default: 'a', + }, + data: { + type: Object, + default: () => ({}), + }, + href: { + type: String, + }, + method: { + type: String, + default: 'get', + }, + replace: { + type: Boolean, + default: false, + }, + preserveScroll: { + type: Boolean, + default: false, + }, + preserveState: { + type: Boolean, + default: null, + }, + }, + setup(props, { slots, attrs }) { + const processing = ref(false) + + return props => { + const as = props.as.toLowerCase() + const method = props.method.toLowerCase() + const [href, data] = mergeDataIntoQueryString(method, props.href || '', props.data, 'brackets') + + return h(props.as, { + ...attrs, + ...as === 'a' ? { href } : {}, + onClick: (event) => { + if (shouldIntercept(event)) { + event.preventDefault() + + Inertia.visit(href, { + data: data, + method: method, + replace: props.replace, + preserveScroll: props.preserveScroll, + preserveState: props.preserveState ?? (method !== 'get'), + onBefore: () => ! processing.value, + onStart: () => processing.value = true, + onFinish: () => processing.value = false, + }) + } + }, + }, slots) + } + }, +} diff --git a/resources/js/app.js b/resources/js/app.js index 1792ed7..22aee25 100644 --- a/resources/js/app.js +++ b/resources/js/app.js @@ -1,12 +1,12 @@ import { createApp, h } from 'vue' -import { createInertiaApp, Head, Link } from '@inertiajs/inertia-vue3' +import { createInertiaApp, Head } from '@inertiajs/inertia-vue3' import { InertiaProgress } from '@inertiajs/progress' import AppLayout from '@/Shared/Layout/AppLayout' import Flatpickr from 'flatpickr' import { Settings } from 'luxon' import { Polish } from 'flatpickr/dist/l10n/pl.js' import Toast from 'vue-toastification' -import ActionButton from '@/Shared/ActionButton' +import InertiaLink from '@/Shared/InertiaLink' createInertiaApp({ resolve: name => { @@ -25,8 +25,7 @@ createInertiaApp({ timeout: 3000, pauseOnFocusLoss: false, }) - .component('InertiaLink', Link) - .component('ActionButton', ActionButton) + .component('InertiaLink', InertiaLink) .component('InertiaHead', Head) .mount(el) }, -- 2.52.0 From 25c13c027e0f23af47d91835424a46ecc9c57948 Mon Sep 17 00:00:00 2001 From: Adrian Hopek Date: Thu, 14 Apr 2022 09:14:39 +0200 Subject: [PATCH 06/15] #90 - wip --- resources/js/Pages/Calendar.vue | 1 + 1 file changed, 1 insertion(+) diff --git a/resources/js/Pages/Calendar.vue b/resources/js/Pages/Calendar.vue index 46d84e1..6a759ae 100644 --- a/resources/js/Pages/Calendar.vue +++ b/resources/js/Pages/Calendar.vue @@ -22,6 +22,7 @@ @@ -39,7 +39,7 @@ -- 2.52.0 From 5356b0fc8cceed804d7471dc0650456eb8a258a4 Mon Sep 17 00:00:00 2001 From: Adrian Hopek Date: Thu, 14 Apr 2022 10:36:39 +0200 Subject: [PATCH 09/15] #90 - wip --- app/Architecture/ExceptionHandler.php | 2 +- .../Commands/MoveUserDataToProfile.php | 30 ++++++++ .../Http/Controllers/DashboardController.php | 2 +- .../Http/Middleware/HandleInertiaRequests.php | 3 +- ..._remove_profile_columns_in_users_table.php | 3 + database/seeders/DemoSeeder.php | 76 ++++++++----------- 6 files changed, 68 insertions(+), 48 deletions(-) create mode 100644 app/Infrastructure/Console/Commands/MoveUserDataToProfile.php diff --git a/app/Architecture/ExceptionHandler.php b/app/Architecture/ExceptionHandler.php index 52f1e4c..34869a2 100644 --- a/app/Architecture/ExceptionHandler.php +++ b/app/Architecture/ExceptionHandler.php @@ -21,7 +21,7 @@ class ExceptionHandler extends Handler { $response = parent::render($request, $e); - if (! app()->environment("production")) { + if (!app()->environment("production")) { return $response; } diff --git a/app/Infrastructure/Console/Commands/MoveUserDataToProfile.php b/app/Infrastructure/Console/Commands/MoveUserDataToProfile.php new file mode 100644 index 0000000..7272268 --- /dev/null +++ b/app/Infrastructure/Console/Commands/MoveUserDataToProfile.php @@ -0,0 +1,30 @@ +profile()->updateOrCreate(["user_id" => $user->id], [ + "first_name" => $user->first_name, + "last_name" => $user->last_name, + "position" => $user->position, + "employment_form" => $user->employment_form, + "employment_date" => $user->employment_date, + ]); + } + } +} diff --git a/app/Infrastructure/Http/Controllers/DashboardController.php b/app/Infrastructure/Http/Controllers/DashboardController.php index 2e4ab04..a0fb994 100644 --- a/app/Infrastructure/Http/Controllers/DashboardController.php +++ b/app/Infrastructure/Http/Controllers/DashboardController.php @@ -21,7 +21,7 @@ class DashboardController extends Controller public function __invoke( Request $request, YearPeriodRetriever $yearPeriodRetriever, - UserVacationStatsRetriever $vacationStatsRetriever + UserVacationStatsRetriever $vacationStatsRetriever, ): Response { $user = $request->user(); $now = Carbon::now(); diff --git a/app/Infrastructure/Http/Middleware/HandleInertiaRequests.php b/app/Infrastructure/Http/Middleware/HandleInertiaRequests.php index 6ebadd2..09c845d 100644 --- a/app/Infrastructure/Http/Middleware/HandleInertiaRequests.php +++ b/app/Infrastructure/Http/Middleware/HandleInertiaRequests.php @@ -16,8 +16,7 @@ class HandleInertiaRequests extends Middleware { public function __construct( protected YearPeriodRetriever $yearPeriodRetriever, - ) { - } + ) {} public function share(Request $request): array { diff --git a/database/migrations/2022_04_08_112108_remove_profile_columns_in_users_table.php b/database/migrations/2022_04_08_112108_remove_profile_columns_in_users_table.php index d8f3b8e..e863201 100644 --- a/database/migrations/2022_04_08_112108_remove_profile_columns_in_users_table.php +++ b/database/migrations/2022_04_08_112108_remove_profile_columns_in_users_table.php @@ -4,11 +4,14 @@ declare(strict_types=1); use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; +use Illuminate\Support\Facades\Artisan; use Illuminate\Support\Facades\Schema; return new class() extends Migration { public function up(): void { + Artisan::call("toby:move-user-data-to-profile"); + Schema::table("users", function (Blueprint $table): void { $table->dropColumn("first_name"); $table->dropColumn("last_name"); diff --git a/database/seeders/DemoSeeder.php b/database/seeders/DemoSeeder.php index 53454e2..b884cb9 100644 --- a/database/seeders/DemoSeeder.php +++ b/database/seeders/DemoSeeder.php @@ -30,87 +30,75 @@ class DemoSeeder extends Seeder public function run(): void { $user = User::factory([ + "first_name" => "Jan", + "last_name" => "Kowalski", "email" => env("LOCAL_EMAIL_FOR_LOGIN_VIA_GOOGLE"), + "employment_form" => EmploymentForm::EmploymentContract, + "position" => "programista", "role" => Role::Administrator, + "employment_date" => Carbon::createFromDate(2021, 12, 31), "remember_token" => Str::random(10), ]) - ->hasProfile([ - "first_name" => "Jan", - "last_name" => "Kowalski", - "employment_form" => EmploymentForm::EmploymentContract, - "position" => "programista", - "employment_date" => Carbon::createFromDate(2021, 12, 31), - ]) ->create(); User::factory([ + "first_name" => "Anna", + "last_name" => "Nowak", "email" => "anna.nowak@example.com", + "employment_form" => EmploymentForm::CommissionContract, + "position" => "tester", "role" => Role::Employee, + "employment_date" => Carbon::createFromDate(2021, 5, 10), "remember_token" => Str::random(10), ]) - ->hasProfile([ - "first_name" => "Anna", - "last_name" => "Nowak", - "employment_form" => EmploymentForm::CommissionContract, - "position" => "tester", - "employment_date" => Carbon::createFromDate(2021, 5, 10), - ]) ->create(); User::factory([ + "first_name" => "Tola", + "last_name" => "Sawicka", "email" => "tola.sawicka@example.com", + "employment_form" => EmploymentForm::B2bContract, + "position" => "programista", "role" => Role::Employee, + "employment_date" => Carbon::createFromDate(2021, 1, 4), "remember_token" => Str::random(10), ]) - ->hasProfile([ - "first_name" => "Tola", - "last_name" => "Sawicka", - "employment_form" => EmploymentForm::B2bContract, - "position" => "programista", - "employment_date" => Carbon::createFromDate(2021, 1, 4), - ]) ->create(); $technicalApprover = User::factory([ + "first_name" => "Maciej", + "last_name" => "Ziółkowski", "email" => "maciej.ziolkowski@example.com", + "employment_form" => EmploymentForm::BoardMemberContract, + "position" => "programista", "role" => Role::TechnicalApprover, + "employment_date" => Carbon::createFromDate(2021, 1, 4), "remember_token" => Str::random(10), ]) - ->hasProfile([ - "first_name" => "Maciej", - "last_name" => "Ziółkowski", - "employment_form" => EmploymentForm::BoardMemberContract, - "position" => "programista", - "employment_date" => Carbon::createFromDate(2021, 1, 4), - ]) ->create(); $administrativeApprover = User::factory([ + "first_name" => "Katarzyna", + "last_name" => "Zając", "email" => "katarzyna.zajac@example.com", + "employment_form" => EmploymentForm::EmploymentContract, + "position" => "dyrektor", "role" => Role::AdministrativeApprover, + "employment_date" => Carbon::createFromDate(2021, 1, 4), "remember_token" => Str::random(10), ]) - ->hasProfile([ - "first_name" => "Katarzyna", - "last_name" => "Zając", - "employment_form" => EmploymentForm::EmploymentContract, - "position" => "dyrektor", - "employment_date" => Carbon::createFromDate(2021, 1, 4), - ]) ->create(); User::factory([ + "first_name" => "Miłosz", + "last_name" => "Borowski", "email" => "milosz.borowski@example.com", + "employment_form" => EmploymentForm::EmploymentContract, + "position" => "administrator", "role" => Role::Administrator, + "employment_date" => Carbon::createFromDate(2021, 1, 4), "remember_token" => Str::random(10), ]) - ->hasProfile([ - "first_name" => "Miłosz", - "last_name" => "Borowski", - "employment_form" => EmploymentForm::EmploymentContract, - "position" => "administrator", - "employment_date" => Carbon::createFromDate(2021, 1, 4), - ]) ->create(); $users = User::all(); @@ -130,7 +118,7 @@ class DemoSeeder extends Seeder ->afterCreating(function (YearPeriod $yearPeriod) use ($users): void { foreach ($users as $user) { VacationLimit::factory([ - "days" => $user->profile->employment_form === EmploymentForm::EmploymentContract ? 26 : null, + "days" => $user->employment_form === EmploymentForm::EmploymentContract ? 26 : null, ]) ->for($yearPeriod) ->for($user) @@ -329,4 +317,4 @@ class DemoSeeder extends Seeder $vacationRequestRejected->state = new Rejected($vacationRequestRejected); $vacationRequestRejected->save(); } -} +} \ No newline at end of file -- 2.52.0 From 71772dbb091a6884b4e1bb1b911e451160574f8b Mon Sep 17 00:00:00 2001 From: Adrian Hopek Date: Thu, 14 Apr 2022 10:37:29 +0200 Subject: [PATCH 10/15] #90 - fix --- database/seeders/DemoSeeder.php | 76 +++++++++++++++++++-------------- 1 file changed, 44 insertions(+), 32 deletions(-) diff --git a/database/seeders/DemoSeeder.php b/database/seeders/DemoSeeder.php index b884cb9..53454e2 100644 --- a/database/seeders/DemoSeeder.php +++ b/database/seeders/DemoSeeder.php @@ -30,75 +30,87 @@ class DemoSeeder extends Seeder public function run(): void { $user = User::factory([ - "first_name" => "Jan", - "last_name" => "Kowalski", "email" => env("LOCAL_EMAIL_FOR_LOGIN_VIA_GOOGLE"), - "employment_form" => EmploymentForm::EmploymentContract, - "position" => "programista", "role" => Role::Administrator, - "employment_date" => Carbon::createFromDate(2021, 12, 31), "remember_token" => Str::random(10), ]) + ->hasProfile([ + "first_name" => "Jan", + "last_name" => "Kowalski", + "employment_form" => EmploymentForm::EmploymentContract, + "position" => "programista", + "employment_date" => Carbon::createFromDate(2021, 12, 31), + ]) ->create(); User::factory([ - "first_name" => "Anna", - "last_name" => "Nowak", "email" => "anna.nowak@example.com", - "employment_form" => EmploymentForm::CommissionContract, - "position" => "tester", "role" => Role::Employee, - "employment_date" => Carbon::createFromDate(2021, 5, 10), "remember_token" => Str::random(10), ]) + ->hasProfile([ + "first_name" => "Anna", + "last_name" => "Nowak", + "employment_form" => EmploymentForm::CommissionContract, + "position" => "tester", + "employment_date" => Carbon::createFromDate(2021, 5, 10), + ]) ->create(); User::factory([ - "first_name" => "Tola", - "last_name" => "Sawicka", "email" => "tola.sawicka@example.com", - "employment_form" => EmploymentForm::B2bContract, - "position" => "programista", "role" => Role::Employee, - "employment_date" => Carbon::createFromDate(2021, 1, 4), "remember_token" => Str::random(10), ]) + ->hasProfile([ + "first_name" => "Tola", + "last_name" => "Sawicka", + "employment_form" => EmploymentForm::B2bContract, + "position" => "programista", + "employment_date" => Carbon::createFromDate(2021, 1, 4), + ]) ->create(); $technicalApprover = User::factory([ - "first_name" => "Maciej", - "last_name" => "Ziółkowski", "email" => "maciej.ziolkowski@example.com", - "employment_form" => EmploymentForm::BoardMemberContract, - "position" => "programista", "role" => Role::TechnicalApprover, - "employment_date" => Carbon::createFromDate(2021, 1, 4), "remember_token" => Str::random(10), ]) + ->hasProfile([ + "first_name" => "Maciej", + "last_name" => "Ziółkowski", + "employment_form" => EmploymentForm::BoardMemberContract, + "position" => "programista", + "employment_date" => Carbon::createFromDate(2021, 1, 4), + ]) ->create(); $administrativeApprover = User::factory([ - "first_name" => "Katarzyna", - "last_name" => "Zając", "email" => "katarzyna.zajac@example.com", - "employment_form" => EmploymentForm::EmploymentContract, - "position" => "dyrektor", "role" => Role::AdministrativeApprover, - "employment_date" => Carbon::createFromDate(2021, 1, 4), "remember_token" => Str::random(10), ]) + ->hasProfile([ + "first_name" => "Katarzyna", + "last_name" => "Zając", + "employment_form" => EmploymentForm::EmploymentContract, + "position" => "dyrektor", + "employment_date" => Carbon::createFromDate(2021, 1, 4), + ]) ->create(); User::factory([ - "first_name" => "Miłosz", - "last_name" => "Borowski", "email" => "milosz.borowski@example.com", - "employment_form" => EmploymentForm::EmploymentContract, - "position" => "administrator", "role" => Role::Administrator, - "employment_date" => Carbon::createFromDate(2021, 1, 4), "remember_token" => Str::random(10), ]) + ->hasProfile([ + "first_name" => "Miłosz", + "last_name" => "Borowski", + "employment_form" => EmploymentForm::EmploymentContract, + "position" => "administrator", + "employment_date" => Carbon::createFromDate(2021, 1, 4), + ]) ->create(); $users = User::all(); @@ -118,7 +130,7 @@ class DemoSeeder extends Seeder ->afterCreating(function (YearPeriod $yearPeriod) use ($users): void { foreach ($users as $user) { VacationLimit::factory([ - "days" => $user->employment_form === EmploymentForm::EmploymentContract ? 26 : null, + "days" => $user->profile->employment_form === EmploymentForm::EmploymentContract ? 26 : null, ]) ->for($yearPeriod) ->for($user) @@ -317,4 +329,4 @@ class DemoSeeder extends Seeder $vacationRequestRejected->state = new Rejected($vacationRequestRejected); $vacationRequestRejected->save(); } -} \ No newline at end of file +} -- 2.52.0 From 8a8905c9d70fae9bb05c2effe2cae3fe734d1185 Mon Sep 17 00:00:00 2001 From: Adrian Hopek Date: Thu, 14 Apr 2022 10:58:33 +0200 Subject: [PATCH 11/15] #90 - fix lint --- resources/js/Pages/Calendar.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/js/Pages/Calendar.vue b/resources/js/Pages/Calendar.vue index 1ca9901..8c6a18e 100644 --- a/resources/js/Pages/Calendar.vue +++ b/resources/js/Pages/Calendar.vue @@ -17,7 +17,7 @@ -- 2.52.0 From 4059b101f53515bf48d764a71a3b928be90298a8 Mon Sep 17 00:00:00 2001 From: Adrian Hopek Date: Thu, 14 Apr 2022 11:14:51 +0200 Subject: [PATCH 12/15] #90 - fix --- .../Notifications/VacationRequestCreatedNotification.php | 2 +- resources/lang/pl.json | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Domain/Notifications/VacationRequestCreatedNotification.php b/app/Domain/Notifications/VacationRequestCreatedNotification.php index 291c3c1..a9a54c3 100644 --- a/app/Domain/Notifications/VacationRequestCreatedNotification.php +++ b/app/Domain/Notifications/VacationRequestCreatedNotification.php @@ -92,7 +92,7 @@ class VacationRequestCreatedNotification extends Notification return __("The vacation request :title has been created correctly by user :creator on your behalf in the :appName.", [ "title" => $this->vacationRequest->name, "appName" => $appName, - "creator" => $this->vacationRequest->creator->fullName, + "creator" => $this->vacationRequest->creator->profile->fullName, ]); } } diff --git a/resources/lang/pl.json b/resources/lang/pl.json index 69cdf97..f95dbeb 100644 --- a/resources/lang/pl.json +++ b/resources/lang/pl.json @@ -61,10 +61,10 @@ "Click here for details": "Kliknij, aby zobaczyć szczegóły", "Vacation request :title is waiting for your technical approval": "Wniosek urlopowy :title czeka na akceptację techniczną", "Vacation request :title is waiting for your administrative approval": "Wniosek urlopowy :title czeka na akceptację administracyjną", - "The vacation request :title from user :requester is waiting for your technical approval.": "Wniosek urlopowy :title od użytkownika :requester czeka na Twoją akceptację techniczną.", - "The vacation request :title from user :requester is waiting for your administrative approval.": "Wniosek urlopowy :title od użytkownika :requester czeka na Twoją akceptację administracyjną.", + "The vacation request :title from user :requester is waiting for your technical approval.": "Wniosek urlopowy :title użytkownika :requester czeka na Twoją akceptację techniczną.", + "The vacation request :title from user :requester is waiting for your administrative approval.": "Wniosek urlopowy :title użytkownika :requester czeka na Twoją akceptację administracyjną.", "Vacation request :title has been :status": "Wniosek urlopowy :title został :status", - "The vacation request :title for user :requester has been :status.": "Wniosek urlopowy :title od użytkownika :requester został :status.", + "The vacation request :title for user :requester has been :status.": "Wniosek urlopowy :title użytkownika :requester został :status.", "Vacation request :title has been created on your behalf": "Wniosek urlopowy :title został utworzony w Twoim imieniu", "The vacation request :title has been created correctly by user :creator on your behalf in the :appName.": "W systemie :appName został poprawnie utworzony wniosek urlopowy :title w Twoim imieniu przez użytkownika :creator." } -- 2.52.0 From ab92f285bab18c5a7c83703034f2dff164493618 Mon Sep 17 00:00:00 2001 From: Adrian Hopek Date: Thu, 14 Apr 2022 11:35:00 +0200 Subject: [PATCH 13/15] Apply suggestions from code review Co-authored-by: Krzysztof Rewak Co-authored-by: Ewelina Lasowy <56546832+EwelinaLasowy@users.noreply.github.com> --- app/Infrastructure/Http/Middleware/HandleInertiaRequests.php | 4 ++-- resources/js/Shared/InertiaLink.js | 2 +- resources/js/app.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Infrastructure/Http/Middleware/HandleInertiaRequests.php b/app/Infrastructure/Http/Middleware/HandleInertiaRequests.php index 09c845d..7344b7f 100644 --- a/app/Infrastructure/Http/Middleware/HandleInertiaRequests.php +++ b/app/Infrastructure/Http/Middleware/HandleInertiaRequests.php @@ -54,14 +54,14 @@ class HandleInertiaRequests extends Middleware protected function getYearsData(Request $request): Closure { - return fn() => $request->user() ? $this->yearPeriodRetriever->links() : []; + return fn(): array => $request->user() ? $this->yearPeriodRetriever->links() : []; } protected function getVacationRequestsCount(Request $request): Closure { $user = $request->user(); - return fn() => $user && $user->can("listAll", VacationRequest::class) + return fn(): ?int => $user && $user->can("listAll", VacationRequest::class) ? VacationRequest::query() ->whereBelongsTo($this->yearPeriodRetriever->selected()) ->states( diff --git a/resources/js/Shared/InertiaLink.js b/resources/js/Shared/InertiaLink.js index d279539..360d9c3 100644 --- a/resources/js/Shared/InertiaLink.js +++ b/resources/js/Shared/InertiaLink.js @@ -53,7 +53,7 @@ export default { replace: props.replace, preserveScroll: props.preserveScroll, preserveState: props.preserveState ?? (method !== 'get'), - onBefore: () => ! processing.value, + onBefore: () => !processing.value, onStart: () => processing.value = true, onFinish: () => processing.value = false, }) diff --git a/resources/js/app.js b/resources/js/app.js index 22aee25..47fe130 100644 --- a/resources/js/app.js +++ b/resources/js/app.js @@ -46,4 +46,4 @@ Flatpickr.setDefaults({ disableMobile: true, }) -Settings.defaultLocale = 'pl' \ No newline at end of file +Settings.defaultLocale = 'pl' -- 2.52.0 From 1129f1ebc62ffddc4a19f0495121b3330d798a8b Mon Sep 17 00:00:00 2001 From: Adrian Hopek Date: Thu, 14 Apr 2022 11:37:07 +0200 Subject: [PATCH 14/15] #90 - cr fixes --- app/Architecture/ExceptionHandler.php | 16 +++++++++++++--- .../VacationRequestCreatedNotification.php | 2 +- .../VacationRequestStatusChangedNotification.php | 2 +- ...cationRequestWaitsForApprovalNotification.php | 2 +- app/Domain/TimesheetPerUserSheet.php | 2 +- app/Eloquent/Models/Profile.php | 4 ++-- .../Console/Commands/MoveUserDataToProfile.php | 1 - .../Http/Resources/SimpleUserResource.php | 2 +- .../Http/Resources/UserResource.php | 2 +- .../VacationRequestActivityResource.php | 2 +- .../SendVacationRequestDaysToGoogleCalendar.php | 2 +- resources/js/Pages/Calendar.vue | 2 +- 12 files changed, 24 insertions(+), 15 deletions(-) diff --git a/app/Architecture/ExceptionHandler.php b/app/Architecture/ExceptionHandler.php index 34869a2..b286bd1 100644 --- a/app/Architecture/ExceptionHandler.php +++ b/app/Architecture/ExceptionHandler.php @@ -17,6 +17,16 @@ class ExceptionHandler extends Handler "password_confirmation", ]; + protected array $handleByInertia = [ + Response::HTTP_INTERNAL_SERVER_ERROR, + Response::HTTP_SERVICE_UNAVAILABLE, + Response::HTTP_TOO_MANY_REQUESTS, + 419, // CSRF + Response::HTTP_NOT_FOUND, + Response::HTTP_FORBIDDEN, + Response::HTTP_UNAUTHORIZED, + ]; + public function render($request, Throwable $e): Response { $response = parent::render($request, $e); @@ -25,11 +35,11 @@ class ExceptionHandler extends Handler return $response; } - if ($response->status() === 405) { - $response->setStatusCode(404); + if ($response->status() === Response::HTTP_METHOD_NOT_ALLOWED) { + $response->setStatusCode(Response::HTTP_NOT_FOUND); } - if (in_array($response->status(), [500, 503, 429, 419, 404, 403, 401], true)) { + if (in_array($response->status(), $this->handleByInertia, true)) { return Inertia::render("Error", [ "status" => $response->status(), ]) diff --git a/app/Domain/Notifications/VacationRequestCreatedNotification.php b/app/Domain/Notifications/VacationRequestCreatedNotification.php index a9a54c3..d84d108 100644 --- a/app/Domain/Notifications/VacationRequestCreatedNotification.php +++ b/app/Domain/Notifications/VacationRequestCreatedNotification.php @@ -92,7 +92,7 @@ class VacationRequestCreatedNotification extends Notification return __("The vacation request :title has been created correctly by user :creator on your behalf in the :appName.", [ "title" => $this->vacationRequest->name, "appName" => $appName, - "creator" => $this->vacationRequest->creator->profile->fullName, + "creator" => $this->vacationRequest->creator->profile->full_name, ]); } } diff --git a/app/Domain/Notifications/VacationRequestStatusChangedNotification.php b/app/Domain/Notifications/VacationRequestStatusChangedNotification.php index 1f0329e..afbe01e 100644 --- a/app/Domain/Notifications/VacationRequestStatusChangedNotification.php +++ b/app/Domain/Notifications/VacationRequestStatusChangedNotification.php @@ -49,7 +49,7 @@ class VacationRequestStatusChangedNotification extends Notification $from = $this->vacationRequest->from->toDisplayString(); $to = $this->vacationRequest->to->toDisplayString(); $days = $this->vacationRequest->vacations()->count(); - $requester = $this->vacationRequest->user->profile->fullName; + $requester = $this->vacationRequest->user->profile->full_name; return (new MailMessage()) ->greeting(__("Hi :user!", [ diff --git a/app/Domain/Notifications/VacationRequestWaitsForApprovalNotification.php b/app/Domain/Notifications/VacationRequestWaitsForApprovalNotification.php index 847fd19..109eef9 100644 --- a/app/Domain/Notifications/VacationRequestWaitsForApprovalNotification.php +++ b/app/Domain/Notifications/VacationRequestWaitsForApprovalNotification.php @@ -84,7 +84,7 @@ class VacationRequestWaitsForApprovalNotification extends Notification protected function buildDescription(): string { $title = $this->vacationRequest->name; - $requester = $this->vacationRequest->user->profile->fullName; + $requester = $this->vacationRequest->user->profile->full_name; if ($this->vacationRequest->state->equals(WaitingForTechnical::class)) { return __("The vacation request :title from user :requester is waiting for your technical approval.", [ diff --git a/app/Domain/TimesheetPerUserSheet.php b/app/Domain/TimesheetPerUserSheet.php index 87d2c75..8547a5e 100644 --- a/app/Domain/TimesheetPerUserSheet.php +++ b/app/Domain/TimesheetPerUserSheet.php @@ -46,7 +46,7 @@ class TimesheetPerUserSheet implements WithTitle, WithHeadings, WithEvents, With public function title(): string { - return $this->user->profile->fullName; + return $this->user->profile->full_name; } public function headings(): array diff --git a/app/Eloquent/Models/Profile.php b/app/Eloquent/Models/Profile.php index cc28a59..df237e9 100644 --- a/app/Eloquent/Models/Profile.php +++ b/app/Eloquent/Models/Profile.php @@ -42,11 +42,11 @@ class Profile extends Model public function getAvatar(): string { return $this->getAvatarGenerator() - ->backgroundColor(ColorGenerator::generate($this->fullName)) + ->backgroundColor(ColorGenerator::generate($this->full_name)) ->image(); } - public function getFullNameAttribute(): string + public function getfullNameAttribute(): string { return "{$this->first_name} {$this->last_name}"; } diff --git a/app/Infrastructure/Console/Commands/MoveUserDataToProfile.php b/app/Infrastructure/Console/Commands/MoveUserDataToProfile.php index 7272268..565d244 100644 --- a/app/Infrastructure/Console/Commands/MoveUserDataToProfile.php +++ b/app/Infrastructure/Console/Commands/MoveUserDataToProfile.php @@ -16,7 +16,6 @@ class MoveUserDataToProfile extends Command { $users = User::all(); - /** @var User $user */ foreach ($users as $user) { $user->profile()->updateOrCreate(["user_id" => $user->id], [ "first_name" => $user->first_name, diff --git a/app/Infrastructure/Http/Resources/SimpleUserResource.php b/app/Infrastructure/Http/Resources/SimpleUserResource.php index 5807587..00a34fb 100644 --- a/app/Infrastructure/Http/Resources/SimpleUserResource.php +++ b/app/Infrastructure/Http/Resources/SimpleUserResource.php @@ -14,7 +14,7 @@ class SimpleUserResource extends JsonResource { return [ "id" => $this->id, - "name" => $this->profile->fullName, + "name" => $this->profile->full_name, "email" => $this->email, "avatar" => $this->profile->getAvatar(), ]; diff --git a/app/Infrastructure/Http/Resources/UserResource.php b/app/Infrastructure/Http/Resources/UserResource.php index fbec442..142aafe 100644 --- a/app/Infrastructure/Http/Resources/UserResource.php +++ b/app/Infrastructure/Http/Resources/UserResource.php @@ -14,7 +14,7 @@ class UserResource extends JsonResource { return [ "id" => $this->id, - "name" => $this->profile->fullName, + "name" => $this->profile->full_name, "email" => $this->email, "role" => $this->role->label(), "position" => $this->profile->position, diff --git a/app/Infrastructure/Http/Resources/VacationRequestActivityResource.php b/app/Infrastructure/Http/Resources/VacationRequestActivityResource.php index e1ab117..491468c 100644 --- a/app/Infrastructure/Http/Resources/VacationRequestActivityResource.php +++ b/app/Infrastructure/Http/Resources/VacationRequestActivityResource.php @@ -15,7 +15,7 @@ class VacationRequestActivityResource extends JsonResource return [ "date" => $this->created_at->toDisplayString(), "time" => $this->created_at->format("H:i"), - "user" => $this->user ? $this->user->profile->fullName : __("System"), + "user" => $this->user ? $this->user->profile->full_name : __("System"), "state" => $this->to, ]; } diff --git a/app/Infrastructure/Jobs/SendVacationRequestDaysToGoogleCalendar.php b/app/Infrastructure/Jobs/SendVacationRequestDaysToGoogleCalendar.php index a1dbe12..9510f72 100644 --- a/app/Infrastructure/Jobs/SendVacationRequestDaysToGoogleCalendar.php +++ b/app/Infrastructure/Jobs/SendVacationRequestDaysToGoogleCalendar.php @@ -32,7 +32,7 @@ class SendVacationRequestDaysToGoogleCalendar implements ShouldQueue $ranges = $this->prepareRanges($days); foreach ($ranges as $range) { - $text = "{$this->vacationRequest->type->label()} - {$this->vacationRequest->user->profile->fullName} [{$this->vacationRequest->name}]"; + $text = "{$this->vacationRequest->type->label()} - {$this->vacationRequest->user->profile->full_name} [{$this->vacationRequest->name}]"; $event = Event::create([ "name" => $text, diff --git a/resources/js/Pages/Calendar.vue b/resources/js/Pages/Calendar.vue index 8c6a18e..b913c2c 100644 --- a/resources/js/Pages/Calendar.vue +++ b/resources/js/Pages/Calendar.vue @@ -17,7 +17,7 @@ -- 2.52.0 From 8bd2046ccb1ac0110d7b894c34d2414159234700 Mon Sep 17 00:00:00 2001 From: Adrian Hopek Date: Thu, 14 Apr 2022 11:46:18 +0200 Subject: [PATCH 15/15] #90 - fix --- .../Notifications/VacationRequestStatusChangedNotification.php | 2 +- resources/lang/pl.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Domain/Notifications/VacationRequestStatusChangedNotification.php b/app/Domain/Notifications/VacationRequestStatusChangedNotification.php index afbe01e..11594a1 100644 --- a/app/Domain/Notifications/VacationRequestStatusChangedNotification.php +++ b/app/Domain/Notifications/VacationRequestStatusChangedNotification.php @@ -59,7 +59,7 @@ class VacationRequestStatusChangedNotification extends Notification "title" => $title, "status" => $status, ])) - ->line(__("The vacation request :title for user :requester has been :status.", [ + ->line(__("The vacation request :title from user :requester has been :status.", [ "title" => $title, "requester" => $requester, "status" => $status, diff --git a/resources/lang/pl.json b/resources/lang/pl.json index f95dbeb..9cc41ae 100644 --- a/resources/lang/pl.json +++ b/resources/lang/pl.json @@ -64,7 +64,7 @@ "The vacation request :title from user :requester is waiting for your technical approval.": "Wniosek urlopowy :title użytkownika :requester czeka na Twoją akceptację techniczną.", "The vacation request :title from user :requester is waiting for your administrative approval.": "Wniosek urlopowy :title użytkownika :requester czeka na Twoją akceptację administracyjną.", "Vacation request :title has been :status": "Wniosek urlopowy :title został :status", - "The vacation request :title for user :requester has been :status.": "Wniosek urlopowy :title użytkownika :requester został :status.", + "The vacation request :title from user :requester has been :status.": "Wniosek urlopowy :title użytkownika :requester został :status.", "Vacation request :title has been created on your behalf": "Wniosek urlopowy :title został utworzony w Twoim imieniu", "The vacation request :title has been created correctly by user :creator on your behalf in the :appName.": "W systemie :appName został poprawnie utworzony wniosek urlopowy :title w Twoim imieniu przez użytkownika :creator." } -- 2.52.0