Completions: notice when no puzzles defined
Some checks failed
CI / scan_ruby (push) Successful in 18s
CI / scan_js (push) Successful in 13s
CI / lint (push) Successful in 13s
CI / test (push) Failing after 39s

This commit is contained in:
sto
2025-11-18 11:57:48 +01:00
parent 3dd153d587
commit bf127bb932
3 changed files with 63 additions and 55 deletions

View File

@@ -29,66 +29,72 @@
.row.mt-5 .row.mt-5
.col .col
h3 Completions h3 Completions
.row - if @contest.puzzles.length == 0
.col .row
.alert.alert-info .col
= t("contestants.edit.completions_note") .alert.alert-warning
table.table.table-striped.table-hover = t("contestants.edit.no_puzzles_note")
thead - else
tr .row
th scope="col" .col
= t("activerecord.attributes.completion.completed") .alert.alert-info
- if @contest.puzzles.size > 1 = t("contestants.edit.completions_note")
table.table.table-striped.table-hover
thead
tr
th scope="col" th scope="col"
= t("activerecord.attributes.completion.display_time_from_start") = t("activerecord.attributes.completion.completed")
th scope="col"
= t("activerecord.attributes.completion.display_relative_time")
- else
th scope="col"
= t("activerecord.attributes.completion.display_time")
th scope="col"
= t("activerecord.attributes.completion.projected_time")
th scope="col"
= t("activerecord.attributes.completion.missing_pieces")
th scope="col"
= t("activerecord.attributes.completion.remaining_pieces")
th scope="col"
= t("activerecord.attributes.completion.puzzle")
tbody
- @completions.each do |completion|
tr scope="row"
td
- if completion.completed
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-check-square" viewBox="0 0 16 16">
<path d="M14 1a1 1 0 0 1 1 1v12a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1zM2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2z"/>
<path d="M10.97 4.97a.75.75 0 0 1 1.071 1.05l-3.992 4.99a.75.75 0 0 1-1.08.02L4.324 8.384a.75.75 0 1 1 1.06-1.06l2.094 2.093 3.473-4.425z"/>
</svg>
td
= display_time(completion.time_seconds)
- if @contest.puzzles.size > 1 - if @contest.puzzles.size > 1
td th scope="col"
= completion.display_relative_time = t("activerecord.attributes.completion.display_time_from_start")
th scope="col"
= t("activerecord.attributes.completion.display_relative_time")
- else - else
th scope="col"
= t("activerecord.attributes.completion.display_time")
th scope="col"
= t("activerecord.attributes.completion.projected_time")
th scope="col"
= t("activerecord.attributes.completion.missing_pieces")
th scope="col"
= t("activerecord.attributes.completion.remaining_pieces")
th scope="col"
= t("activerecord.attributes.completion.puzzle")
tbody
- @completions.each do |completion|
tr scope="row"
td td
= display_time(completion.projected_time) - if completion.completed
td <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-check-square" viewBox="0 0 16 16">
= completion.missing_pieces <path d="M14 1a1 1 0 0 1 1 1v12a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1zM2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2z"/>
td <path d="M10.97 4.97a.75.75 0 0 1 1.071 1.05l-3.992 4.99a.75.75 0 0 1-1.08.02L4.324 8.384a.75.75 0 1 1 1.06-1.06l2.094 2.093 3.473-4.425z"/>
= completion.remaining_pieces </svg>
td td
- if !completion.puzzle.brand.blank? = display_time(completion.time_seconds)
| #{completion.puzzle.name} - #{completion.puzzle.brand} - if @contest.puzzles.size > 1
td
= completion.display_relative_time
- else - else
| #{completion.puzzle.name} td
td = display_time(completion.projected_time)
a.btn.btn-sm.btn-secondary.me-2 href=edit_contest_completion_path(@contest, completion, contestant_id: contestant.id) td
= t("helpers.buttons.edit") = completion.missing_pieces
= link_to t("helpers.buttons.delete"), contest_completion_path(contest, completion, contestant_id: contestant.id), td
data: { turbo_method: :delete }, class: "btn btn-sm btn-secondary" = completion.remaining_pieces
.row td
.col - if !completion.puzzle.brand.blank?
a.btn.btn-primary href=new_contest_completion_path(@contest, contestant_id: contestant.id) | #{completion.puzzle.name} - #{completion.puzzle.brand}
= t("helpers.buttons.add") - else
| #{completion.puzzle.name}
td
a.btn.btn-sm.btn-secondary.me-2 href=edit_contest_completion_path(@contest, completion, contestant_id: contestant.id)
= t("helpers.buttons.edit")
= link_to t("helpers.buttons.delete"), contest_completion_path(contest, completion, contestant_id: contestant.id),
data: { turbo_method: :delete }, class: "btn btn-sm btn-secondary"
.row
.col
a.btn.btn-primary href=new_contest_completion_path(@contest, contestant_id: contestant.id)
= t("helpers.buttons.add")
- if contestant.offline.present? - if contestant.offline.present?
.row.mt-5.mb-2 .row.mt-5.mb-2

View File

@@ -217,6 +217,7 @@ en:
end_image: End image end_image: End image
notice: Participant updated notice: Participant updated
not_finished: Not yet finished not_finished: Not yet finished
no_puzzles_note: No puzzles were added yet
offline_participation: Offline participation offline_participation: Offline participation
start_image: Start image start_image: Start image
title: Participant title: Participant

View File

@@ -188,6 +188,7 @@ fr:
end_image: Image de fin end_image: Image de fin
notice: Participant.e modifié.e notice: Participant.e modifié.e
not_finished: Non terminé not_finished: Non terminé
no_puzzles_note: Aucun puzzle n'a été défini encore pour ce concours
offline_participation: Participation hors-ligne offline_participation: Participation hors-ligne
start_image: Image de début start_image: Image de début
title: Participant.e title: Participant.e