Revamp contest settings into tabs
Some checks failed
CI / scan_ruby (push) Successful in 20s
CI / scan_js (push) Successful in 13s
CI / lint (push) Successful in 13s
CI / test (push) Failing after 37s

This commit is contained in:
sto
2025-11-12 11:33:44 +01:00
parent f4136ea58a
commit 86dd0b7b9e
14 changed files with 212 additions and 89 deletions

View File

@@ -1,79 +0,0 @@
h4.mt-5 = t("contests.form.general")
= form_with model: contest do |form|
.row.mb-3
.col
.form-floating
= form.text_field :name, autocomplete: "off", class: "form-control"
= form.label :name, class: "required"
.row.mb-3
.col
.form-floating
= form.select :lang, Languages::AVAILABLE_LANGUAGES.map { |lang| [ lang[:name], lang[:id] ] }, {}, class: "form-select"
= form.label :lang
.row.mb-3
.col
.form-check.form-switch
= form.check_box :public, class: "form-check-input"
= form.label :public
.row.mb-3
.col
- if @contest.puzzles.length <= 1
.form-check.form-switch
= form.check_box :offline_form, class: "form-check-input"
= form.label :offline_form
.form-text = t("activerecord.attributes.contest.offline_form_warning")
.form-text = t("activerecord.attributes.contest.offline_form_description")
- else
.form-check.form-switch
= form.check_box :offline_form_fake, class: "form-check-input", disabled: true
= form.label :offline_form
.form-text = t("activerecord.attributes.contest.offline_form_warning")
.form-text = t("activerecord.attributes.contest.offline_form_description")
.row.mb-3
.col
.form-check.form-switch
= form.check_box :team, class: "form-check-input"
= form.label :team
.form-text = t("activerecord.attributes.contest.team_description")
.row.mb-3 style="display: none"
.col
.form-check.form-switch
= form.check_box :allow_registration, class: "form-check-input"
= form.label :allow_registration
.form-text = t("activerecord.attributes.contest.allow_registration_description")
.row
.col
= form.submit submit_text, class: "btn btn-primary"
h4.mt-5 = t("contests.form.categories")
= form_with model: Category, url: "/contests/#{@contest.id}/categories" do |form|
- if @contest.categories.size > 0
.row
.col-6
table.table.table-striped.table-hover
thead
tr
th
= t("activerecord.attributes.category.name")
th
= t("activerecord.attributes.category.contestant_count")
tbody
- @contest.categories.each do |category|
tr.align-middle scope="row"
td
= category.name
td
= category.contestants.size
td
= link_to t("helpers.buttons.delete"), contest_category_path(@contest, category), data: { turbo_method: :delete }, class: "btn btn-sm btn-danger ms-2"
.row.mt-3
.col-4
.form-floating
= form.text_field :name, autocomplete: "off", value: nil, class: "form-control"
= form.label :name, class: "required"
= t("activerecord.attributes.category.new")
.row.mt-3
.col
= form.submit t("helpers.buttons.add"), class: "btn btn-primary"

View File

@@ -0,0 +1,12 @@
.row
.col
ul.nav.nav-tabs.mb-4
li.nav-item
a.nav-link class=active_page("/contests/#{@contest.id}/settings/general") href="/contests/#{@contest.id}/settings/general"
= t("contests.form.general")
li.nav-item
a.nav-link class=active_page("/contests/#{@contest.id}/settings/offline") href="/contests/#{@contest.id}/settings/offline"
= t("contests.form.offline")
li.nav-item
a.nav-link class=active_page("/contests/#{@contest.id}/settings/categories") href="/contests/#{@contest.id}/settings/categories"
= t("contests.form.categories")

View File

@@ -1 +0,0 @@
= render "form", contest: @contest, submit_text: t("helpers.buttons.save")

View File

@@ -1 +1,9 @@
= render "form", contest: @contest, submit_text: t("helpers.buttons.create")
= form_with model: @contest do |form|
.row.mb-3
.col
.form-floating
= form.text_field :name, autocomplete: "off", class: "form-control"
= form.label :name, class: "required"
.row.mt-4
.col
= form.submit t("helpers.buttons.create"), class: "btn btn-primary"

View File

@@ -0,0 +1,31 @@
= render "settings_nav"
= form_with model: Category, url: "/contests/#{@contest.id}/categories" do |form|
- if @contest.categories.size > 0
.row
.col-6
table.table.table-striped.table-hover
thead
tr
th
= t("activerecord.attributes.category.name")
th
= t("activerecord.attributes.category.contestant_count")
tbody
- @contest.categories.each do |category|
tr.align-middle scope="row"
td
= category.name
td
= category.contestants.size
td
= link_to t("helpers.buttons.delete"), contest_category_path(@contest, category), data: { turbo_method: :delete }, class: "btn btn-sm btn-danger ms-2"
.row.mt-3
.col-4
.form-floating
= form.text_field :name, autocomplete: "off", value: nil, class: "form-control"
= form.label :name, class: "required"
= t("activerecord.attributes.category.new")
.row.mt-3
.col
= form.submit t("helpers.buttons.add"), class: "btn btn-primary"

View File

@@ -0,0 +1,33 @@
= render "settings_nav"
= form_with model: @contest, url: "/contests/#{@contest.id}/settings/general" do |form|
.row.mt-2.mb-3
.col
.form-floating
= form.text_field :name, autocomplete: "off", class: "form-control"
= form.label :name, class: "required"
.row.mb-3
.col
.form-floating
= form.select :lang, Languages::AVAILABLE_LANGUAGES.map { |lang| [ lang[:name], lang[:id] ] }, {}, class: "form-select"
= form.label :lang
.row.mt-4.mb-3
.col
.form-check.form-switch
= form.check_box :public, class: "form-check-input"
= form.label :public
.row.mb-3
.col
.form-check.form-switch
= form.check_box :team, class: "form-check-input"
= form.label :team
.form-text = t("activerecord.attributes.contest.team_description")
.row.mb-3 style="display: none"
.col
.form-check.form-switch
= form.check_box :allow_registration, class: "form-check-input"
= form.label :allow_registration
.form-text = t("activerecord.attributes.contest.allow_registration_description")
.row.mt-4
.col
= form.submit t("helpers.buttons.update"), class: "btn btn-primary"

View File

@@ -0,0 +1,20 @@
= render "settings_nav"
= form_with model: @contest, url: "/contests/#{@contest.id}/settings/offline" do |form|
.row.mt-2.mb-3
.col
- if @contest.puzzles.length <= 1
.form-check.form-switch
= form.check_box :offline_form, class: "form-check-input"
= form.label :offline_form
.form-text = t("activerecord.attributes.contest.offline_form_warning")
.form-text = t("activerecord.attributes.contest.offline_form_description")
- else
.form-check.form-switch
= form.check_box :offline_form_fake, class: "form-check-input", disabled: true
= form.label :offline_form
.form-text = t("activerecord.attributes.contest.offline_form_warning")
.form-text = t("activerecord.attributes.contest.offline_form_description")
.row.mt-4
.col
= form.submit t("helpers.buttons.update"), class: "btn btn-primary"