Now able to edit subscores on scoring guides
This commit is contained in:
parent
0347897592
commit
4a21fb39ce
|
|
@ -76,6 +76,21 @@ class ScoringGuideController extends Controller
|
||||||
return redirect('/admin/scoring/guides/'.$guide->id.'/edit')->with('success', 'Scoring guide updated');
|
return redirect('/admin/scoring/guides/'.$guide->id.'/edit')->with('success', 'Scoring guide updated');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function destroy(ScoringGuide $guide)
|
||||||
|
{
|
||||||
|
if (! Auth::user()->is_admin) {
|
||||||
|
abort(403);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($guide->auditions()->count() > 0) {
|
||||||
|
return redirect('/admin/scoring')->with('error', 'Cannot delete scoring guide with auditions');
|
||||||
|
}
|
||||||
|
|
||||||
|
$guide->delete();
|
||||||
|
|
||||||
|
return redirect('/admin/scoring')->with('success', 'Scoring guide deleted');
|
||||||
|
}
|
||||||
|
|
||||||
public function subscore_store(Request $request, ScoringGuide $guide)
|
public function subscore_store(Request $request, ScoringGuide $guide)
|
||||||
{
|
{
|
||||||
if (! Auth::user()->is_admin) {
|
if (! Auth::user()->is_admin) {
|
||||||
|
|
@ -112,6 +127,37 @@ class ScoringGuideController extends Controller
|
||||||
return redirect('/admin/scoring/guides/'.$guide->id.'/edit')->with('success', 'Subscore added');
|
return redirect('/admin/scoring/guides/'.$guide->id.'/edit')->with('success', 'Subscore added');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function subscore_update(ScoringGuide $guide, SubscoreDefinition $subscore)
|
||||||
|
{
|
||||||
|
if (! Auth::user()->is_admin) {
|
||||||
|
abort(403);
|
||||||
|
}
|
||||||
|
if (! $guide->exists() || ! $subscore->exists()) {
|
||||||
|
abort(409);
|
||||||
|
}
|
||||||
|
$validateData = request()->validate([
|
||||||
|
'name' => ['required'],
|
||||||
|
'max_score' => ['required', 'integer'],
|
||||||
|
'weight' => ['required', 'integer'],
|
||||||
|
'for_seating' => ['nullable', 'boolean'],
|
||||||
|
'for_advance' => ['nullable', 'boolean'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$for_seating = request()->has('for_seating') ? (bool) request()->input('for_seating') : false;
|
||||||
|
$for_advance = request()->has('for_advance') ? (bool) request()->input('for_advance') : false;
|
||||||
|
|
||||||
|
$subscore->update([
|
||||||
|
'name' => $validateData['name'],
|
||||||
|
'max_score' => $validateData['max_score'],
|
||||||
|
'weight' => $validateData['weight'],
|
||||||
|
'for_seating' => $for_seating,
|
||||||
|
'for_advance' => $for_advance,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return redirect('/admin/scoring/guides/'.$guide->id.'/edit')->with('success', 'Subscore updated');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function reorder_display(Request $request)
|
public function reorder_display(Request $request)
|
||||||
{
|
{
|
||||||
if (! Auth::user()->is_admin) {
|
if (! Auth::user()->is_admin) {
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ class ScoringGuideObserver
|
||||||
/**
|
/**
|
||||||
* Handle the ScoringGuide "created" event.
|
* Handle the ScoringGuide "created" event.
|
||||||
*/
|
*/
|
||||||
public function created(ScoringGuideObserver $scoringGuide): void
|
public function created(ScoringGuide $scoringGuide): void
|
||||||
{
|
{
|
||||||
ScoringGuideChange::dispatch();
|
ScoringGuideChange::dispatch();
|
||||||
}
|
}
|
||||||
|
|
@ -19,7 +19,7 @@ class ScoringGuideObserver
|
||||||
/**
|
/**
|
||||||
* Handle the ScoringGuide "updated" event.
|
* Handle the ScoringGuide "updated" event.
|
||||||
*/
|
*/
|
||||||
public function updated(ScoringGuideObserver $scoringGuide): void
|
public function updated(ScoringGuide $scoringGuide): void
|
||||||
{
|
{
|
||||||
AuditionChange::dispatch();
|
AuditionChange::dispatch();
|
||||||
ScoringGuideChange::dispatch();
|
ScoringGuideChange::dispatch();
|
||||||
|
|
@ -28,7 +28,7 @@ class ScoringGuideObserver
|
||||||
/**
|
/**
|
||||||
* Handle the ScoringGuide "deleted" event.
|
* Handle the ScoringGuide "deleted" event.
|
||||||
*/
|
*/
|
||||||
public function deleted(ScoringGuideObserver $scoringGuide): void
|
public function deleted(ScoringGuide $scoringGuide): void
|
||||||
{
|
{
|
||||||
AuditionChange::dispatch();
|
AuditionChange::dispatch();
|
||||||
ScoringGuideChange::dispatch();
|
ScoringGuideChange::dispatch();
|
||||||
|
|
@ -37,7 +37,7 @@ class ScoringGuideObserver
|
||||||
/**
|
/**
|
||||||
* Handle the ScoringGuide "restored" event.
|
* Handle the ScoringGuide "restored" event.
|
||||||
*/
|
*/
|
||||||
public function restored(ScoringGuideObserver $scoringGuide): void
|
public function restored(ScoringGuide $scoringGuide): void
|
||||||
{
|
{
|
||||||
AuditionChange::dispatch();
|
AuditionChange::dispatch();
|
||||||
ScoringGuideChange::dispatch();
|
ScoringGuideChange::dispatch();
|
||||||
|
|
@ -46,7 +46,7 @@ class ScoringGuideObserver
|
||||||
/**
|
/**
|
||||||
* Handle the ScoringGuide "force deleted" event.
|
* Handle the ScoringGuide "force deleted" event.
|
||||||
*/
|
*/
|
||||||
public function forceDeleted(ScoringGuideObserver $scoringGuide): void
|
public function forceDeleted(ScoringGuide $scoringGuide): void
|
||||||
{
|
{
|
||||||
AuditionChange::dispatch();
|
AuditionChange::dispatch();
|
||||||
ScoringGuideChange::dispatch();
|
ScoringGuideChange::dispatch();
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,8 @@
|
||||||
<x-table.th>Name</x-table.th>
|
<x-table.th>Name</x-table.th>
|
||||||
<x-table.th>Max Score</x-table.th>
|
<x-table.th>Max Score</x-table.th>
|
||||||
<x-table.th>Weight</x-table.th>
|
<x-table.th>Weight</x-table.th>
|
||||||
<x-table.th>For Seating</x-table.th>
|
|
||||||
@if(Settings::advanceTo())
|
@if(Settings::advanceTo())
|
||||||
|
<x-table.th>For Seating</x-table.th>
|
||||||
<x-table.th>For {{ Settings::advanceTo() }}</x-table.th>
|
<x-table.th>For {{ Settings::advanceTo() }}</x-table.th>
|
||||||
@endif
|
@endif
|
||||||
<x-table.th spacer_only></x-table.th>
|
<x-table.th spacer_only></x-table.th>
|
||||||
|
|
@ -17,36 +17,31 @@
|
||||||
</thead>
|
</thead>
|
||||||
<x-table.body>
|
<x-table.body>
|
||||||
@foreach ($subscores as $subscore)
|
@foreach ($subscores as $subscore)
|
||||||
<tr>
|
<tr x-data="{ showModal: false }">
|
||||||
|
|
||||||
<x-table.td>{{ $subscore->name }}</x-table.td>
|
<x-table.td>{{ $subscore->name }}</x-table.td>
|
||||||
<x-table.td>{{ $subscore->max_score }}</x-table.td>
|
<x-table.td>{{ $subscore->max_score }}</x-table.td>
|
||||||
<x-table.td>{{ $subscore->weight }}</x-table.td>
|
<x-table.td>{{ $subscore->weight }}</x-table.td>
|
||||||
<x-table.td>{{ $subscore->for_seating ? 'Yes' : 'No' }}</x-table.td>
|
|
||||||
@if(Settings::advanceTo())
|
@if(Settings::advanceTo())
|
||||||
|
<x-table.td>{{ $subscore->for_seating ? 'Yes' : 'No' }}</x-table.td>
|
||||||
<x-table.td>{{ $subscore->for_advance ? 'Yes' : 'No' }}</x-table.td>
|
<x-table.td>{{ $subscore->for_advance ? 'Yes' : 'No' }}</x-table.td>
|
||||||
@endif
|
@endif
|
||||||
<x-table.td>
|
<x-table.td>
|
||||||
{{-- This came from AI, consider--}}
|
<p @click="showModal = ! showModal">[ edit ]</p>
|
||||||
{{-- <x-form.form method="PATCH" action="/admin/scoring/guides/{{ $guide->id }}/subscore/{{ $subscore->id }}">--}}
|
@include('admin.scoring.edit-modify-subscore-modal')
|
||||||
{{-- <x-table.button>Save</x-table.button>--}}
|
|
||||||
{{-- <x-table.button @click="if(confirm('Are you sure?')) { $dispatch('delete', {id: {{ $subscore->id }} }) }">Delete</x-table.button>--}}
|
|
||||||
{{-- <x-table.button @click="rename = ! rename">Rename</x-table.button>--}}
|
|
||||||
{{-- </x-form.form>--}}
|
|
||||||
|
|
||||||
</x-table.td>
|
</x-table.td>
|
||||||
</tr>
|
</tr>
|
||||||
{{-- WHERE DID THIS EVEN COME FROM???--}}
|
|
||||||
{{-- <template x-on:delete.window="document.querySelector('form[action=\'/admin/scoring/guides/{{ $guide->id }}/subscore/\'+event.detail.id+\'\']').submit()"></template>--}}
|
|
||||||
@endforeach
|
@endforeach
|
||||||
</x-table.body>
|
</x-table.body>
|
||||||
<tfoot>
|
<tfoot>
|
||||||
<tr><x-table.th class="!pb-0">Add Subscore</x-table.th></tr><tr>
|
<tr><x-table.th class="!pb-0" colspan="3">Add Subscore</x-table.th></tr><tr>
|
||||||
<x-form.form method="POST" action="/admin/scoring/guides/{{ $guide->id }}/subscore">
|
<x-form.form method="POST" action="/admin/scoring/guides/{{ $guide->id }}/subscore">
|
||||||
<x-table.td><x-form.field name="name"></x-form.field></x-table.td>
|
<x-table.td><x-form.field name="name"></x-form.field></x-table.td>
|
||||||
<x-table.td><x-form.field name="max_score" type="number"></x-form.field></x-table.td>
|
<x-table.td><x-form.field name="max_score" type="number"></x-form.field></x-table.td>
|
||||||
<x-table.td><x-form.field name="weight" type="number"></x-form.field></x-table.td>
|
<x-table.td><x-form.field name="weight" type="number"></x-form.field></x-table.td>
|
||||||
<x-table.td><x-form.toggle-checkbox name="for_seating" checked></x-form.toggle-checkbox></x-table.td>
|
|
||||||
@if(Settings::advanceTo())
|
@if(Settings::advanceTo())
|
||||||
|
<x-table.td><x-form.toggle-checkbox name="for_seating" checked></x-form.toggle-checkbox></x-table.td>
|
||||||
<x-table.td><x-form.toggle-checkbox name="for_advance" checked></x-form.toggle-checkbox></x-table.td>
|
<x-table.td><x-form.toggle-checkbox name="for_advance" checked></x-form.toggle-checkbox></x-table.td>
|
||||||
@endif
|
@endif
|
||||||
<td><x-table.button>Save</x-table.button></td>
|
<td><x-table.button>Save</x-table.button></td>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
<x-modal-body>
|
||||||
|
<x-slot:title>Edit Subscore</x-slot:title>
|
||||||
|
<x-table.table>
|
||||||
|
<thead><tr>
|
||||||
|
<x-table.th>Name</x-table.th>
|
||||||
|
<x-table.th>Max Score</x-table.th>
|
||||||
|
<x-table.th>Weight</x-table.th>
|
||||||
|
@if(auditionSetting('advanceTo'))
|
||||||
|
<x-table.th>For Seating</x-table.th>
|
||||||
|
<x-table.th>For {{ auditionSetting('advanceTo') }}</x-table.th>
|
||||||
|
@endif
|
||||||
|
<x-table.th spacer_only></x-table.th>
|
||||||
|
</tr></thead>
|
||||||
|
<x-table.body>
|
||||||
|
<x-form.form method="PATCH" action="{{ route('admin.scoring.subscore_update',['guide'=> $guide->id,'subscore'=>$subscore->id]) }}">
|
||||||
|
<x-table.td><x-form.field name="name" value="{{ $subscore->name }}"/></x-table.td>
|
||||||
|
<x-table.td><x-form.field name="max_score" type="number" value="{{ $subscore->max_score }}" /></x-table.td>
|
||||||
|
<x-table.td><x-form.field name="weight" type="number" value="{{ $subscore->weight }}" /></x-table.td>
|
||||||
|
|
||||||
|
@if(auditionSetting('advanceTo'))
|
||||||
|
<x-table.td>
|
||||||
|
<x-form.toggle-checkbox name="for_seating" checked="{{ $subscore->for_seating }}"/>
|
||||||
|
</x-table.td>
|
||||||
|
<x-table.td>
|
||||||
|
<x-form.toggle-checkbox name="for_advance" checked="{{ $subscore->for_advance }}" />
|
||||||
|
</x-table.td>
|
||||||
|
@endif
|
||||||
|
<td><x-table.button>Save</x-table.button></td>
|
||||||
|
</x-form.form>
|
||||||
|
</x-table.body>
|
||||||
|
</x-table.table>
|
||||||
|
</x-modal-body>
|
||||||
|
|
@ -6,7 +6,6 @@
|
||||||
<x-card.heading>
|
<x-card.heading>
|
||||||
<x-slot:subheading @click="rename = ! rename">Click here to rename</x-slot:subheading>
|
<x-slot:subheading @click="rename = ! rename">Click here to rename</x-slot:subheading>
|
||||||
Scoring Guide: {{ $guide->name }}
|
Scoring Guide: {{ $guide->name }}
|
||||||
|
|
||||||
</x-card.heading>
|
</x-card.heading>
|
||||||
@include('admin.scoring.edit-tabs')
|
@include('admin.scoring.edit-tabs')
|
||||||
<div class="ml-6 -mt-2 mr-6">
|
<div class="ml-6 -mt-2 mr-6">
|
||||||
|
|
@ -31,7 +30,7 @@
|
||||||
<x-card.heading>Rename</x-card.heading>
|
<x-card.heading>Rename</x-card.heading>
|
||||||
<x-form.form method="PATCH" action="/admin/scoring/guides/{{ $guide->id }}/edit" class="!pt-2">
|
<x-form.form method="PATCH" action="/admin/scoring/guides/{{ $guide->id }}/edit" class="!pt-2">
|
||||||
<x-form.field name="name" label_text="New Name" value=""/>
|
<x-form.field name="name" label_text="New Name" value=""/>
|
||||||
<x-form.footer submit-button-text="Rename"></x-form.footer>
|
<x-form.footer submit-button-text="Rename" class="mb-3"></x-form.footer>
|
||||||
</x-form.form>
|
</x-form.form>
|
||||||
</x-card.card>
|
</x-card.card>
|
||||||
<div class="mt-20">
|
<div class="mt-20">
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
<div x-data="sortableData()">
|
<div x-data="sortableData()">
|
||||||
@foreach($guides as $guide)
|
{{-- Unassigned auditions first --}}
|
||||||
|
@php($guide = $guides->find(0))
|
||||||
<x-card.card class="mb-4">
|
<x-card.card class="mb-4">
|
||||||
<x-card.heading>{{ $guide->name }}</x-card.heading>
|
<x-card.heading>{{ $guide->name }}</x-card.heading>
|
||||||
|
|
||||||
|
|
@ -9,6 +10,30 @@
|
||||||
@endforeach
|
@endforeach
|
||||||
</div>
|
</div>
|
||||||
</x-card.card>
|
</x-card.card>
|
||||||
|
|
||||||
|
|
||||||
|
@foreach($guides as $guide)
|
||||||
|
@continue($guide->id === 0)
|
||||||
|
<x-card.card class="mb-4">
|
||||||
|
<x-card.heading>
|
||||||
|
{{ $guide->name }}
|
||||||
|
@if($guide->auditions()->count() === 0)
|
||||||
|
<x-slot:right_side>
|
||||||
|
<x-form.form method="DELETE"
|
||||||
|
action="{{route('admin.scoring.destroy', ['guide'=>$guide->id])}}"
|
||||||
|
class="!pr-0 !-mr-6 !-mt-2">
|
||||||
|
<x-form.red-trash-button type="submit"/>
|
||||||
|
</x-form.form>
|
||||||
|
</x-slot:right_side>
|
||||||
|
@endif
|
||||||
|
</x-card.heading>
|
||||||
|
|
||||||
|
<div class="grid md:grid-cols-4 sm:grid-cols-2 mx-6 gap-2 mt-3 mb-3 guide-list" id="guide-{{ $guide->id }}" data-guide-id="{{ $guide->id }}">
|
||||||
|
@foreach($guide->auditions as $audition)
|
||||||
|
<div class="px-3 py-3 border border-indigo-300 bg-gray-100" data-id="{{ $audition->id }}">{{ $audition->name }}</div>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
</x-card.card>
|
||||||
@endforeach
|
@endforeach
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -52,8 +52,10 @@ Route::middleware(['auth', 'verified', CheckIfAdmin::class])->prefix('admin/')->
|
||||||
Route::get('/guides/{guide}/edit', 'edit')->name('admin.scoring.edit'); // Edit scoring guide
|
Route::get('/guides/{guide}/edit', 'edit')->name('admin.scoring.edit'); // Edit scoring guide
|
||||||
Route::patch('/guides/{guide}/edit', 'update')->name('admin.scoring.update'); // Save changes to audition guide (rename)
|
Route::patch('/guides/{guide}/edit', 'update')->name('admin.scoring.update'); // Save changes to audition guide (rename)
|
||||||
Route::post('/guides/{guide}/subscore', 'subscore_store')->name('admin.scoring.subscore_store'); // Save a new subscore
|
Route::post('/guides/{guide}/subscore', 'subscore_store')->name('admin.scoring.subscore_store'); // Save a new subscore
|
||||||
|
Route::patch('/guides/{guide}/subscore/{subscore}', 'subscore_update')->name('admin.scoring.subscore_update'); // Save a new subscore
|
||||||
Route::post('/reorder-display', 'reorder_display')->name('admin.scoring.reorder_display');
|
Route::post('/reorder-display', 'reorder_display')->name('admin.scoring.reorder_display');
|
||||||
Route::post('/reorder-tiebreak', 'reorder_tiebreak')->name('admin.scoring.reorder_tiebreak');
|
Route::post('/reorder-tiebreak', 'reorder_tiebreak')->name('admin.scoring.reorder_tiebreak');
|
||||||
|
Route::delete('/guides/{guide}', 'destroy')->name('admin.scoring.destroy'); // Delete a scoring guide
|
||||||
});
|
});
|
||||||
|
|
||||||
// Admin Auditions Routes
|
// Admin Auditions Routes
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue