Add completions
This commit is contained in:
19
app/views/completions/_form.html.slim
Normal file
19
app/views/completions/_form.html.slim
Normal file
@@ -0,0 +1,19 @@
|
||||
= form_with model: completion, url: url, method: method do |form|
|
||||
.row.mb-3
|
||||
.col
|
||||
.form-floating
|
||||
= form.text_field :time_seconds, autocomplete: "off", class: "form-control"
|
||||
= form.label :time_seconds, class: "required"
|
||||
.row.mb-3
|
||||
.col
|
||||
.form-floating
|
||||
= form.select :contestant_id, @contestants.map { |contestant| [contestant.name, contestant.id] }, {}, class: "form-select"
|
||||
= form.label :contestant_id
|
||||
.row.mb-3
|
||||
.col
|
||||
.form-floating
|
||||
= form.select :puzzle_id, @puzzles.map { |puzzle| ["#{puzzle.name} - #{puzzle.brand}", puzzle.id] }, {}, class: "form-select"
|
||||
= form.label :puzzle_id
|
||||
.row
|
||||
.col
|
||||
= form.submit submit_text, class: "btn btn-primary"
|
1
app/views/completions/edit.html.slim
Normal file
1
app/views/completions/edit.html.slim
Normal file
@@ -0,0 +1 @@
|
||||
= render "form", contest: @contest, completion: @completion, submit_text: "Save", method: :patch, url: "/contests/#{@contest.id}/completions/#{@completion.id}"
|
1
app/views/completions/new.html.slim
Normal file
1
app/views/completions/new.html.slim
Normal file
@@ -0,0 +1 @@
|
||||
= render "form", completion: @completion, submit_text: "Create", method: :post, url: "/contests/#{@contest.id}/completions"
|
@@ -1,3 +1,7 @@
|
||||
.row
|
||||
.col
|
||||
h3 Informations
|
||||
|
||||
= form_with model: contestant, url: url, method: method do |form|
|
||||
.row.mb-3
|
||||
.col
|
||||
@@ -14,4 +18,27 @@
|
||||
.col
|
||||
- if method == :patch
|
||||
= link_to "Delete", contest_contestant_path(contest, contestant), data: { turbo_method: :delete }, class: "btn btn-danger me-2"
|
||||
= form.submit submit_text, class: "btn btn-primary"
|
||||
= form.submit submit_text, class: "btn btn-primary"
|
||||
|
||||
- if method == :patch
|
||||
.row.mt-5
|
||||
.col
|
||||
h3 Completions
|
||||
table.table.table-striped.table-hover
|
||||
thead
|
||||
tr
|
||||
th scope="col"
|
||||
| Time since start
|
||||
th scope="col"
|
||||
| Puzzle
|
||||
tbody
|
||||
- @completions.each do |completion|
|
||||
tr scope="row"
|
||||
td
|
||||
= link_to completion.time_seconds, edit_contest_completion_path(@contest, completion, contestant.id)
|
||||
td
|
||||
= completion.puzzle.name
|
||||
.row
|
||||
.col
|
||||
a.btn.btn-primary href=new_contest_completion_path(@contest, contestant_id: contestant.id)
|
||||
| Add completion
|
||||
|
@@ -11,7 +11,7 @@
|
||||
| Edit contest
|
||||
|
||||
.row.mb-4
|
||||
.col-sm-6
|
||||
.col-8
|
||||
.row
|
||||
.col
|
||||
h4
|
||||
@@ -33,21 +33,25 @@
|
||||
.col
|
||||
a.btn.btn-primary href=new_contest_puzzle_path(@contest)
|
||||
| Add puzzle
|
||||
.col-sm-6
|
||||
.col-4
|
||||
.row
|
||||
.col
|
||||
h4
|
||||
| Contestants
|
||||
.row.row-cols-1.row-cols-md-3.g-4.mb-4
|
||||
- @contestants.each do |contestant|
|
||||
.col
|
||||
css:
|
||||
.card:hover { background-color: lightblue; }
|
||||
.card.h-100
|
||||
.card-header
|
||||
= contestant.name
|
||||
.card-body
|
||||
a.stretched-link href=edit_contest_contestant_path(@contest, contestant)
|
||||
table.table.table-striped.table-hover
|
||||
thead
|
||||
tr
|
||||
th scope="col"
|
||||
| Name
|
||||
th scope="col"
|
||||
| Completed puzzles
|
||||
tbody
|
||||
- @contestants.each do |contestant|
|
||||
tr scope="row"
|
||||
td
|
||||
= link_to contestant.name, edit_contest_contestant_path(@contest, contestant)
|
||||
td
|
||||
= contestant.completions.length
|
||||
.row
|
||||
.col
|
||||
a.btn.btn-primary href=new_contest_contestant_path(@contest)
|
||||
|
Reference in New Issue
Block a user