Merge pull request #22 from okorpheus/auditionadmin-15
Add delete score buttons and edit scores button to edit entry screen. Closes #15
This commit is contained in:
commit
bb3ea6fe5e
|
|
@ -67,36 +67,49 @@
|
|||
|
||||
|
||||
<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>
|
||||
<div class="grid sm:grid-cols-3 space-3 m-3">
|
||||
@foreach($scores as $score)
|
||||
@php($score->isValid())
|
||||
<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)
|
||||
<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>
|
||||
</p>
|
||||
@endforeach
|
||||
<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>
|
||||
</p>
|
||||
|
||||
@if( auditionSetting('advanceTo'))
|
||||
<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>
|
||||
</p>
|
||||
@endif
|
||||
@if(! $score->isValid())
|
||||
<form method="POST" action="{{ route('scores.destroy',['score'=>$score->id]) }}">
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
<button type="submit" class="text-red-500 font-semibold pt-5">Invalid Score - Delete
|
||||
</button>
|
||||
<div class="bg-red-500 text-white p-2 rounded mt-2">
|
||||
<p class="text-sm">This score is invalid</p>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
@endforeach
|
||||
|
|
|
|||
|
|
@ -68,8 +68,6 @@ Route::middleware(['auth', 'verified', CheckIfAdmin::class])->prefix('admin/')->
|
|||
Route::patch('/{audition}', 'update')->name('admin.auditions.update');
|
||||
Route::post('/reorder', 'reorder')->name('admin.auditions.reorder');
|
||||
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
|
||||
|
|
|
|||
|
|
@ -19,8 +19,7 @@ Route::middleware(['auth', 'verified', CheckIfCanTab::class])->group(function ()
|
|||
Route::get('/choose_entry', 'chooseEntry')->name('scores.chooseEntry');
|
||||
Route::get('/entry', 'entryScoreSheet')->name('scores.entryScoreSheet');
|
||||
Route::post('/entry/{entry}', 'saveEntryScoreSheet')->name('scores.saveEntryScoreSheet');
|
||||
Route::delete('/{score}',
|
||||
[ScoreController::class, 'destroyScore'])->name('scores.destroy');
|
||||
Route::delete('/{score}', 'destroyScore')->name('scores.destroy');
|
||||
});
|
||||
|
||||
// Entry Flagging
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
use App\Models\Audition;
|
||||
use App\Models\Entry;
|
||||
use App\Models\Room;
|
||||
use App\Models\ScoreSheet;
|
||||
use App\Models\ScoringGuide;
|
||||
use App\Models\SubscoreDefinition;
|
||||
use App\Models\User;
|
||||
|
|
@ -220,6 +221,23 @@ it('displays scores', function () {
|
|||
$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
|
||||
it('does not allow a normal user to delete an entry', function () {
|
||||
|
|
|
|||
Loading…
Reference in New Issue