From 1e280702eaabbd8dd0ad36cd97342c7f69a47316 Mon Sep 17 00:00:00 2001 From: Matt Young Date: Sat, 22 Jun 2024 09:54:20 -0500 Subject: [PATCH] Move logic for seatable entries to SeatingController. Break out elements of auditionSeating page into separate blade templates --- .../Tabulation/TabulationController.php | 6 ++- app/Providers/AppServiceProvider.php | 4 +- app/Services/SeatingService.php | 14 ++++++- .../views/components/form/footer.blade.php | 2 +- ...> auditionSeating-doubler-block.blade.php} | 0 .../auditionSeating-fill-seats-form.blade.php | 18 ++++++++ ...> auditionSeating-results-table.blade.php} | 2 +- ...itionSeating-show-proposed-seats.blade.php | 17 ++++++++ ...itionSeating-unable-to-seat-card.blade.php | 10 +++++ .../tabulation/auditionSeating.blade.php | 41 +++---------------- 10 files changed, 71 insertions(+), 43 deletions(-) rename resources/views/tabulation/{doubler-block.blade.php => auditionSeating-doubler-block.blade.php} (100%) create mode 100644 resources/views/tabulation/auditionSeating-fill-seats-form.blade.php rename resources/views/tabulation/{audition-results-table.blade.php => auditionSeating-results-table.blade.php} (95%) create mode 100644 resources/views/tabulation/auditionSeating-show-proposed-seats.blade.php create mode 100644 resources/views/tabulation/auditionSeating-unable-to-seat-card.blade.php diff --git a/app/Http/Controllers/Tabulation/TabulationController.php b/app/Http/Controllers/Tabulation/TabulationController.php index e27924c..5d8c093 100644 --- a/app/Http/Controllers/Tabulation/TabulationController.php +++ b/app/Http/Controllers/Tabulation/TabulationController.php @@ -13,7 +13,9 @@ use function compact; class TabulationController extends Controller { protected $tabulationService; + protected $doublerService; + protected $seatingService; public function __construct(TabulationService $tabulationService, DoublerService $doublerService, SeatingService $seatingService) @@ -53,6 +55,8 @@ class TabulationController extends Controller $ensembleLimits = $this->seatingService->getLimitForAudition($audition->id); $auditionComplete = $scoringComplete && $doublerComplete; - return view('tabulation.auditionSeating', compact('audition', 'entries', 'scoringComplete', 'doublerComplete', 'auditionComplete', 'ensembleLimits')); + $seatableEntries = $this->seatingService->getSeatableEntries($audition->id); + + return view('tabulation.auditionSeating', compact('audition', 'entries', 'scoringComplete', 'doublerComplete', 'auditionComplete', 'ensembleLimits', 'seatableEntries')); } } diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 1a4cbf7..e305498 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -50,8 +50,8 @@ class AppServiceProvider extends ServiceProvider return new AuditionCacheService(); }); - $this->app->singleton(SeatingService::class, function () { - return new SeatingService(); + $this->app->singleton(SeatingService::class, function ($app) { + return new SeatingService($app->make(TabulationService::class)); }); $this->app->singleton(EntryCacheService::class, function ($app) { diff --git a/app/Services/SeatingService.php b/app/Services/SeatingService.php index 2a6e224..4c613a1 100644 --- a/app/Services/SeatingService.php +++ b/app/Services/SeatingService.php @@ -9,12 +9,14 @@ class SeatingService { protected $limitsCacheKey = 'acceptanceLimits'; + protected $tabulationService; + /** * Create a new class instance. */ - public function __construct() + public function __construct(TabulationService $tabulationService) { - // + $this->tabulationService = $tabulationService; } public function getAcceptanceLimits() @@ -40,4 +42,12 @@ class SeatingService { Cache::forget($this->limitsCacheKey); } + + public function getSeatableEntries($auditionId) + { + $entries = $this->tabulationService->auditionEntries($auditionId); + return $entries->reject(function ($entry) { + return $entry->hasFlag('declined'); + }); + } } diff --git a/resources/views/components/form/footer.blade.php b/resources/views/components/form/footer.blade.php index 0e8a21a..e6e4860 100644 --- a/resources/views/components/form/footer.blade.php +++ b/resources/views/components/form/footer.blade.php @@ -1,6 +1,6 @@ @props([ 'submitButtonText' => '', - 'buttons' => false + 'buttons' => false, ])
merge(['class' => 'flex items-center justify-end mt-4 gap-x-6 border-t border-gray-900/10 px-0 pt-4']) }}> @if ($slot->isEmpty()) diff --git a/resources/views/tabulation/doubler-block.blade.php b/resources/views/tabulation/auditionSeating-doubler-block.blade.php similarity index 100% rename from resources/views/tabulation/doubler-block.blade.php rename to resources/views/tabulation/auditionSeating-doubler-block.blade.php diff --git a/resources/views/tabulation/auditionSeating-fill-seats-form.blade.php b/resources/views/tabulation/auditionSeating-fill-seats-form.blade.php new file mode 100644 index 0000000..4256499 --- /dev/null +++ b/resources/views/tabulation/auditionSeating-fill-seats-form.blade.php @@ -0,0 +1,18 @@ + + Seating +
+ + @foreach($ensembleLimits as $ensembleLimit) + + @endforeach + + Seat + + +
+
diff --git a/resources/views/tabulation/audition-results-table.blade.php b/resources/views/tabulation/auditionSeating-results-table.blade.php similarity index 95% rename from resources/views/tabulation/audition-results-table.blade.php rename to resources/views/tabulation/auditionSeating-results-table.blade.php index 5b5b0c5..2877e03 100644 --- a/resources/views/tabulation/audition-results-table.blade.php +++ b/resources/views/tabulation/auditionSeating-results-table.blade.php @@ -27,7 +27,7 @@ @if($doublerService->studentIsDoubler($entry->student_id)) - @include('tabulation.doubler-block') + @include('tabulation.auditionSeating-doubler-block') @endif {{ number_format($entry->final_score_array[0] ?? 0,4) }} diff --git a/resources/views/tabulation/auditionSeating-show-proposed-seats.blade.php b/resources/views/tabulation/auditionSeating-show-proposed-seats.blade.php new file mode 100644 index 0000000..7aac373 --- /dev/null +++ b/resources/views/tabulation/auditionSeating-show-proposed-seats.blade.php @@ -0,0 +1,17 @@ +@foreach($ensembleLimits as $ensembleLimit) + + {{ $ensembleLimit->ensemble->name }} + + @for($n=1; $n <= $ensembleLimit->maximum_accepted; $n++) + @php + $entry = $seatableEntries->shift(); + if (is_null($entry)) continue; + @endphp + + + {{ $n }} - {{ $entry->student->full_name() }} + + @endfor + + +@endforeach diff --git a/resources/views/tabulation/auditionSeating-unable-to-seat-card.blade.php b/resources/views/tabulation/auditionSeating-unable-to-seat-card.blade.php new file mode 100644 index 0000000..d243c37 --- /dev/null +++ b/resources/views/tabulation/auditionSeating-unable-to-seat-card.blade.php @@ -0,0 +1,10 @@ + + Unable to seat this audition + @if(! $scoringComplete) +

The audition cannot be seated while it has unscored entries.

+ @endif + + @if(! $doublerComplete) +

The audition cannot be seated while it has unresolved doublers.

+ @endif +
diff --git a/resources/views/tabulation/auditionSeating.blade.php b/resources/views/tabulation/auditionSeating.blade.php index 2091d8b..7e9af3f 100644 --- a/resources/views/tabulation/auditionSeating.blade.php +++ b/resources/views/tabulation/auditionSeating.blade.php @@ -7,50 +7,19 @@
- @include('tabulation.audition-results-table') + @include('tabulation.auditionSeating-results-table')
@if(! $auditionComplete) - - Unable to seat this audition - @if(! $scoringComplete) -

The audition cannot be seated while it has unscored entries.

- @endif - - @if(! $doublerComplete) -

The audition cannot be seated while it has unresolved doublers.

- @endif -
+ @include('tabulation.auditionSeating-unable-to-seat-card') + @else + @include('tabulation.auditionSeating-fill-seats-form') + @include('tabulation.auditionSeating-show-proposed-seats') @endif - @if($auditionComplete) - @php - $entriesToSeat = $entries->reject(function ($entry) { - return $entry->hasFlag('declined'); - }); - @endphp - @foreach($ensembleLimits as $ensembleLimit) - - {{ $ensembleLimit->ensemble->name }} - - @for($n=1; $n <= $ensembleLimit->maximum_accepted; $n++) - @php - $entry = $entriesToSeat->shift(); - if (is_null($entry)) continue; - @endphp - - {{ $n }} - {{ $entry->student->full_name() }} - - @endfor - - - @endforeach - @endif
- -