Internal scoreboard: add category filter
All checks were successful
CI / scan_ruby (push) Successful in 18s
CI / scan_js (push) Successful in 13s
CI / lint (push) Successful in 14s
CI / test (push) Successful in 34s

This commit is contained in:
sto
2025-07-15 18:23:26 +02:00
parent 502649620b
commit 657c5ac47b
2 changed files with 33 additions and 5 deletions

View File

@@ -42,17 +42,38 @@ javascript:
| + #{t("helpers.buttons.add")}
a.ms-2.btn-sm.btn.btn-primary href=contest_import_path(@contest) style="margin-top: -3px"
| #{t("helpers.buttons.import")}
- if @contest.categories.size > 0
.row
.col
select.mt-2.mb-2 id="categories" style="padding: 5px"
option value=-1
| Tous.tes les participant.e.s
option value=-2
| Participant.e.s sans catégorie
- @contest.categories.each do |category|
option value=category.id
= category.name
javascript:
const select = document.getElementById('categories');
const urlParams = new URLSearchParams(window.location.search);
const selectedCategory = urlParams.get('category');
Array.from(select.children).forEach((option) => {
if (option.value == selectedCategory) option.selected = true;
});
select.addEventListener('change', (e) => {
window.location.href = `#{contest_path(@contest)}?category=${e.target.value}`
})
.d-flex.flex-column style="overflow-y: auto"
table.table.table-striped.table-hover
thead
tr
th scope="col"
th
= t("helpers.rank")
th scope="col"
th
= t("activerecord.attributes.contestant.name")
th scope="col"
th
= t("activerecord.attributes.contestant.completions")
th scope="col"
th
= t("activerecord.attributes.contestant.display_time")
tbody
- @contestants.each_with_index do |contestant, index|
@@ -144,4 +165,4 @@ javascript:
- else
a.btn.btn-sm.btn-secondary.disabled href=contest_message_convert_path(@contest, message) style="white-space: nowrap;"
= t("helpers.buttons.add_completion")
= link_to t("helpers.buttons.delete"), contest_message_path(@contest, message), data: { turbo_method: :delete }, class: "btn btn-sm btn-danger ms-2"
= link_to "x", contest_message_path(@contest, message), data: { turbo_method: :delete }, class: "btn btn-sm btn-danger ms-2"