Move logic for seatable entries to SeatingController. Break out elements of auditionSeating page into separate blade templates
This commit is contained in:
parent
a8db4832ce
commit
1e280702ea
|
|
@ -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'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
@props([
|
||||
'submitButtonText' => '',
|
||||
'buttons' => false
|
||||
'buttons' => false,
|
||||
])
|
||||
<div {{ $attributes->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())
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
<x-card.card class="mb-3">
|
||||
<x-card.heading>Seating</x-card.heading>
|
||||
<div class="py-3 px-5">
|
||||
<form.form method="POST" action="#">
|
||||
@foreach($ensembleLimits as $ensembleLimit)
|
||||
<x-form.field name="ensemble{{ $ensembleLimit->ensemble->id }}"
|
||||
label_text="{{ $ensembleLimit->ensemble->name }} - Max: {{ $ensembleLimit->maximum_accepted }}"
|
||||
type="number"
|
||||
max="{{ $ensembleLimit->maximum_accepted }}"
|
||||
value="{{ $ensembleLimit->maximum_accepted }}"
|
||||
class="mb-3"/>
|
||||
@endforeach
|
||||
<x-form.footer>
|
||||
<x-form.button>Seat</x-form.button>
|
||||
</x-form.footer>
|
||||
</form.form>
|
||||
</div>
|
||||
</x-card.card>
|
||||
|
|
@ -27,7 +27,7 @@
|
|||
</x-table.td>
|
||||
<x-table.td class="!py-0">
|
||||
@if($doublerService->studentIsDoubler($entry->student_id))
|
||||
@include('tabulation.doubler-block')
|
||||
@include('tabulation.auditionSeating-doubler-block')
|
||||
@endif
|
||||
</x-table.td>
|
||||
<x-table.td>{{ number_format($entry->final_score_array[0] ?? 0,4) }}</x-table.td>
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
@foreach($ensembleLimits as $ensembleLimit)
|
||||
<x-card.card class="mb-3">
|
||||
<x-card.heading>{{ $ensembleLimit->ensemble->name }}</x-card.heading>
|
||||
<x-card.list.body>
|
||||
@for($n=1; $n <= $ensembleLimit->maximum_accepted; $n++)
|
||||
@php
|
||||
$entry = $seatableEntries->shift();
|
||||
if (is_null($entry)) continue;
|
||||
@endphp
|
||||
|
||||
<x-card.list.row class="!py-2">
|
||||
{{ $n }} - {{ $entry->student->full_name() }}
|
||||
</x-card.list.row>
|
||||
@endfor
|
||||
</x-card.list.body>
|
||||
</x-card.card>
|
||||
@endforeach
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
<x-card.card>
|
||||
<x-card.heading>Unable to seat this audition</x-card.heading>
|
||||
@if(! $scoringComplete)
|
||||
<p class="text-sm px-5 py-2">The audition cannot be seated while it has unscored entries.</p>
|
||||
@endif
|
||||
|
||||
@if(! $doublerComplete)
|
||||
<p class="text-sm px-5 py-2">The audition cannot be seated while it has unresolved doublers.</p>
|
||||
@endif
|
||||
</x-card.card>
|
||||
|
|
@ -7,50 +7,19 @@
|
|||
<div class="grid grid-cols-4"></div>
|
||||
<div class="grid grid-cols-4">
|
||||
<div class="col-span-3">
|
||||
@include('tabulation.audition-results-table')
|
||||
@include('tabulation.auditionSeating-results-table')
|
||||
</div>
|
||||
<div class="ml-4">
|
||||
@if(! $auditionComplete)
|
||||
<x-card.card>
|
||||
<x-card.heading>Unable to seat this audition</x-card.heading>
|
||||
@if(! $scoringComplete)
|
||||
<p class="text-sm px-5 py-2">The audition cannot be seated while it has unscored entries.</p>
|
||||
@include('tabulation.auditionSeating-unable-to-seat-card')
|
||||
@else
|
||||
@include('tabulation.auditionSeating-fill-seats-form')
|
||||
@include('tabulation.auditionSeating-show-proposed-seats')
|
||||
@endif
|
||||
|
||||
@if(! $doublerComplete)
|
||||
<p class="text-sm px-5 py-2">The audition cannot be seated while it has unresolved doublers.</p>
|
||||
@endif
|
||||
</x-card.card>
|
||||
@endif
|
||||
|
||||
@if($auditionComplete)
|
||||
@php
|
||||
$entriesToSeat = $entries->reject(function ($entry) {
|
||||
return $entry->hasFlag('declined');
|
||||
});
|
||||
@endphp
|
||||
@foreach($ensembleLimits as $ensembleLimit)
|
||||
<x-card.card class="mb-3">
|
||||
<x-card.heading>{{ $ensembleLimit->ensemble->name }}</x-card.heading>
|
||||
<x-card.list.body>
|
||||
@for($n=1; $n <= $ensembleLimit->maximum_accepted; $n++)
|
||||
@php
|
||||
$entry = $entriesToSeat->shift();
|
||||
if (is_null($entry)) continue;
|
||||
@endphp
|
||||
|
||||
<x-card.list.row class="!py-2">
|
||||
{{ $n }} - {{ $entry->student->full_name() }}
|
||||
</x-card.list.row>
|
||||
@endfor
|
||||
</x-card.list.body>
|
||||
</x-card.card>
|
||||
@endforeach
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
</x-layout.app>
|
||||
|
|
|
|||
Loading…
Reference in New Issue