From c44f154ef5c168acdc6bbdb4b5d1702cb2262659 Mon Sep 17 00:00:00 2001 From: Sharky Date: Sat, 15 Feb 2025 01:25:57 +0100 Subject: [PATCH] feat(invitees): add confirmation dialog before removing shares or assistants (#69) (#106) * feat(invitees): add confirmation dialog before removing shares or assistants (#69) * fix(test): ensure factory tables always seat at least 2 Definitely not a bodge! * fix(invitees): fit text on seat button * chore: fix typo --------- Co-authored-by: Fenrikur <3359222+Fenrikur@users.noreply.github.com> --- .../Applications/InviteesController.php | 22 +++++++++- database/factories/TableTypeFactory.php | 4 +- resources/css/app.scss | 11 +++-- .../application/invitee-delete.blade.php | 41 +++++++++++++++++++ .../views/application/invitees.blade.php | 6 +-- routes/web.php | 1 + 6 files changed, 75 insertions(+), 10 deletions(-) create mode 100644 resources/views/application/invitee-delete.blade.php diff --git a/app/Http/Controllers/Applications/InviteesController.php b/app/Http/Controllers/Applications/InviteesController.php index dc65538..4a32360 100644 --- a/app/Http/Controllers/Applications/InviteesController.php +++ b/app/Http/Controllers/Applications/InviteesController.php @@ -43,6 +43,26 @@ public function view() ]); } + /** + * This is the confirmation page for removing a share/assistant from a dealership. + * It has been added in place of the confirmationless @see InviteesController::destroy(). + */ + public function delete(InviteeRemovalRequest $request) + { + $invitee = Application::findOrFail($request->get('invitee_id')); + // Note: We do not check the end dates here but in the actual destroy handler below. + // Users should not be routed to this view anyway if they are not allowed to do this. + + return view('application.invitee-delete', [ + "invitee" => $invitee, + ]); + } + + /** + * This is the actual destroy function, which was previously executed without a confirmation page. + * @param InviteeRemovalRequest $request + * @return \Illuminate\Http\RedirectResponse + */ public function destroy(InviteeRemovalRequest $request) { $invitee = Application::findOrFail($request->get('invitee_id')); @@ -66,7 +86,7 @@ public function destroy(InviteeRemovalRequest $request) if ($oldParent) { $oldParent->user()->first()->notify(new LeaveNotification($oldApplicationType->value, $invitee->user()->first()->name)); } - return back(); + return Redirect::route('applications.invitees.view'); } public function codes(Request $request) diff --git a/database/factories/TableTypeFactory.php b/database/factories/TableTypeFactory.php index 967a3c2..f85ba45 100644 --- a/database/factories/TableTypeFactory.php +++ b/database/factories/TableTypeFactory.php @@ -14,8 +14,8 @@ public function definition(): array { return [ 'name' => $this->faker->name(), - 'spaces' => $this->faker->randomNumber(), - 'seats' => $this->faker->randomNumber(), + 'spaces' => $this->faker->randomDigitNotZero() + 1, + 'seats' => $this->faker->randomDigitNotZero() + 1, 'price' => $this->faker->randomNumber(), 'package' => $this->faker->word(), 'created_at' => Carbon::now(), diff --git a/resources/css/app.scss b/resources/css/app.scss index e85c633..940bcff 100644 --- a/resources/css/app.scss +++ b/resources/css/app.scss @@ -1,17 +1,22 @@ $primary: #00504b; @import "bootstrap/scss/bootstrap.scss"; -label.required:after, legend.required:after, span.required:after { +label.required:after, +legend.required:after, +span.required:after { content: "*"; color: red; } /* DD Specific */ .dd-table-button { - width: 5ex; - height: 5ex; + width: 5.5ex; + height: 5.5ex; font-weight: bold; margin: 0.25ex; + display: inline-flex; + align-items: center; + justify-content: center; } .dd-table-button.border-danger { diff --git a/resources/views/application/invitee-delete.blade.php b/resources/views/application/invitee-delete.blade.php new file mode 100644 index 0000000..7535e62 --- /dev/null +++ b/resources/views/application/invitee-delete.blade.php @@ -0,0 +1,41 @@ +@extends('layouts.app') +@section('title') + Remove {{ ucfirst($invitee->type->value) }} from your Dealership +@endsection +@section('content') +
+

@yield('title')

+ + + +
+ @method('DELETE') + @csrf + +
+
+
+

You are removing {{ $invitee->user->name }} from your Dealership!

+
+

+ This action will cause them to be completely removed as a {{ ucfirst($invitee->type->value) }} from your dealership.
+ They will be notified of this. +

+
+ + Stop! Take me back! + + +
+
+
+
+
+
+
+@endsection diff --git a/resources/views/application/invitees.blade.php b/resources/views/application/invitees.blade.php index eb95831..8a16669 100644 --- a/resources/views/application/invitees.blade.php +++ b/resources/views/application/invitees.blade.php @@ -61,8 +61,7 @@ @endif @foreach ($shares as $share)
  • -
    - @method('DELETE') + @csrf @if ( @@ -108,9 +107,8 @@ @endif @foreach ($assistants as $assistant)
  • - + @if (config('convention.assistant_end_date')->isFuture()) - @method('DELETE') @csrf diff --git a/routes/web.php b/routes/web.php index b20ad24..f1e6260 100755 --- a/routes/web.php +++ b/routes/web.php @@ -47,6 +47,7 @@ Route::delete('applications', [\App\Http\Controllers\Applications\ApplicationController::class, 'destroy'])->name('applications.destroy'); Route::get('applications/invitees', [\App\Http\Controllers\Applications\InviteesController::class, 'view'])->name('applications.invitees.view'); + Route::post('applications/invitees/delete', [\App\Http\Controllers\Applications\InviteesController::class, 'delete'])->name('applications.invitees.delete'); Route::delete('applications/invitees', [\App\Http\Controllers\Applications\InviteesController::class, 'destroy'])->name('applications.invitees.destroy'); Route::post('applications/invitees/codes', [\App\Http\Controllers\Applications\InviteesController::class, 'codes'])->name('applications.invitees.codes');