Add delete score buttons and edit scores button to edit entry screen. #22

Merged
okorpheus merged 1 commits from auditionadmin-15 into master 2024-07-15 03:15:47 +00:00
4 changed files with 42 additions and 14 deletions
Showing only changes of commit 9263cf2f80 - Show all commits

View File

@ -67,36 +67,49 @@
<x-card.card class="mx-auto max-w-3xl mt-6"> <x-card.card class="mx-auto max-w-3xl mt-6">
<x-card.heading>Scores</x-card.heading> <x-card.heading>
Scores
<x-slot:right_side>
<x-form.button href="{{route('scores.entryScoreSheet', ['entry_id'=>$entry->id])}}">Edit Scores</x-form.button>
</x-slot:right_side>
</x-card.heading>
<x-card.list.body> <x-card.list.body>
<div class="grid sm:grid-cols-3 space-3 m-3"> <div class="grid sm:grid-cols-3 space-3 m-3">
@foreach($scores as $score) @foreach($scores as $score)
@php($score->isValid()) @php($score->isValid())
<div class="border p-3"> <div class="border p-3">
<p class="font-semibold border-b">{{ $score->judge->full_name() }}</p> <div class="grid grid-cols-2 border-b">
<span class="font-semibold text-sm">{{ $score->judge->full_name() }}</span>
<span class="text-right mb-2">
<x-delete-resource-modal
size="15"
action="{{route('scores.destroy',$score->id)}}"
title="Delete score">
Confirm you would like to delete the {{ $score->entry->audition->name }} score for {{ $score->entry->student->full_name() }} by {{ $score->judge->full_name() }}.
</x-delete-resource-modal>
</span>
</div>
@foreach($score->subscores as $subscore) @foreach($score->subscores as $subscore)
<p class="grid grid-cols-2 border-b"> <p class="grid grid-cols-2 border-b">
<span>{{$subscore['subscore_name'] }}</span> <span class="text-sm">{{$subscore['subscore_name'] }}</span>
<span class="text-right">{{$subscore['score']}}</span> <span class="text-right">{{$subscore['score']}}</span>
</p> </p>
@endforeach @endforeach
<p class="grid grid-cols-2 border-b"> <p class="grid grid-cols-2 border-b">
<span class="font-semibold">{{ auditionSetting('auditionAbbreviation') }} Total</span> <span class="font-semibold text-sm">{{ auditionSetting('auditionAbbreviation') }} Total</span>
<span class="text-right font-semibold">{{ $score->totalScore('seating')[0] }}</span> <span class="text-right font-semibold">{{ $score->totalScore('seating')[0] }}</span>
</p> </p>
@if( auditionSetting('advanceTo')) @if( auditionSetting('advanceTo'))
<p class="grid grid-cols-2 border-b"> <p class="grid grid-cols-2 border-b">
<span class="font-semibold">{{ auditionSetting('advanceTo') }} Total</span> <span class="font-semibold text-sm">{{ auditionSetting('advanceTo') }} Total</span>
<span class="text-right font-semibold">{{ $score->totalScore('advancement')[0] }}</span> <span class="text-right font-semibold">{{ $score->totalScore('advancement')[0] }}</span>
</p> </p>
@endif @endif
@if(! $score->isValid()) @if(! $score->isValid())
<form method="POST" action="{{ route('scores.destroy',['score'=>$score->id]) }}"> <div class="bg-red-500 text-white p-2 rounded mt-2">
@csrf <p class="text-sm">This score is invalid</p>
@method('DELETE') </div>
<button type="submit" class="text-red-500 font-semibold pt-5">Invalid Score - Delete
</button>
@endif @endif
</div> </div>
@endforeach @endforeach

View File

@ -68,8 +68,6 @@ Route::middleware(['auth', 'verified', CheckIfAdmin::class])->prefix('admin/')->
Route::patch('/{audition}', 'update')->name('admin.auditions.update'); Route::patch('/{audition}', 'update')->name('admin.auditions.update');
Route::post('/reorder', 'reorder')->name('admin.auditions.reorder'); Route::post('/reorder', 'reorder')->name('admin.auditions.reorder');
Route::delete('/{audition}', 'destroy')->name('admin.auditions.destroy'); Route::delete('/{audition}', 'destroy')->name('admin.auditions.destroy');
#Route::get('/run_draw', 'prepareDraw')->name('admin.auditions.prepareDraw');
#Route::post('/run_draw', 'runDraw')->name('admin.auditions.runDraw');
}); });
// Admin Audition Draw Routes // Admin Audition Draw Routes

View File

@ -19,8 +19,7 @@ Route::middleware(['auth', 'verified', CheckIfCanTab::class])->group(function ()
Route::get('/choose_entry', 'chooseEntry')->name('scores.chooseEntry'); Route::get('/choose_entry', 'chooseEntry')->name('scores.chooseEntry');
Route::get('/entry', 'entryScoreSheet')->name('scores.entryScoreSheet'); Route::get('/entry', 'entryScoreSheet')->name('scores.entryScoreSheet');
Route::post('/entry/{entry}', 'saveEntryScoreSheet')->name('scores.saveEntryScoreSheet'); Route::post('/entry/{entry}', 'saveEntryScoreSheet')->name('scores.saveEntryScoreSheet');
Route::delete('/{score}', Route::delete('/{score}', 'destroyScore')->name('scores.destroy');
[ScoreController::class, 'destroyScore'])->name('scores.destroy');
}); });
// Entry Flagging // Entry Flagging

View File

@ -3,6 +3,7 @@
use App\Models\Audition; use App\Models\Audition;
use App\Models\Entry; use App\Models\Entry;
use App\Models\Room; use App\Models\Room;
use App\Models\ScoreSheet;
use App\Models\ScoringGuide; use App\Models\ScoringGuide;
use App\Models\SubscoreDefinition; use App\Models\SubscoreDefinition;
use App\Models\User; use App\Models\User;
@ -220,6 +221,23 @@ it('displays scores', function () {
$response->assertSee($subscore->name); $response->assertSee($subscore->name);
} }
}); });
it('has a link to delete scores', function() {
// Arrange
$sg = ScoringGuide::factory()->create();
SubscoreDefinition::factory()->count(5)->create(['scoring_guide_id' => $sg->id]);
$room = Room::factory()->create();
$judge = User::factory()->create();
$room->addJudge($judge);
$audition = Audition::factory()->create(['room_id' => $room->id, 'scoring_guide_id' => $sg->id]);
$entry = Entry::factory()->create(['audition_id' => $audition->id]);
// Run the ScoreAllAuditions seeder
Artisan::call('db:seed', ['--class' => 'ScoreAllAuditions']);
// Act & Assert
$scoreSheet = ScoreSheet::where('entry_id', $entry->id)->first();
actAsAdmin();
$response = get(route('admin.entries.edit', $entry))
->assertSee(route('scores.destroy', ['score'=>$scoreSheet]));
});
// Delete tests // Delete tests
it('does not allow a normal user to delete an entry', function () { it('does not allow a normal user to delete an entry', function () {