Make asking for missing pieces in forms optional
This commit is contained in:
@@ -328,7 +328,7 @@ class ContestsController < ApplicationController
|
||||
end
|
||||
|
||||
def settings_onsite_params
|
||||
params.expect(contest: [ :code, :organizer_form ])
|
||||
params.expect(contest: [ :code, :organizer_form, :missing_pieces ])
|
||||
end
|
||||
|
||||
def settings_online_params
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
# duration :string
|
||||
# duration_seconds :integer
|
||||
# lang :string default("en")
|
||||
# missing_pieces :boolean
|
||||
# name :string
|
||||
# offline_form :boolean default(FALSE)
|
||||
# organizer_form :boolean
|
||||
|
||||
@@ -78,6 +78,7 @@
|
||||
javascript:
|
||||
savetime = "";
|
||||
ispatch = #{method == :patch};
|
||||
showMissingPieces = #{@completion.contest.missing_pieces}
|
||||
|
||||
// Actions for radio buttons.
|
||||
completed_radio_yes_el = document.getElementById('completed_radio_yes');
|
||||
@@ -90,7 +91,7 @@
|
||||
if (ispatch) timeEl.value = '#{@completion.display_time_from_start}';
|
||||
else timeEl.value = savetime;
|
||||
timeEl.parentElement.parentElement.parentElement.style.display = '';
|
||||
missingPiecesEl.style.display = 'block';
|
||||
if (showMissingPieces) missingPiecesEl.style.display = 'block';
|
||||
remainingPiecesEl.style.display = 'none';
|
||||
submitEl.style.display = '';
|
||||
if (refreshEl) refreshEl.style.display = '';
|
||||
@@ -150,7 +151,7 @@
|
||||
updateTime();
|
||||
|
||||
/ Text field for recording the missing pieces, if any.
|
||||
.row.mt-3 id="missing_pieces" style="display: #{@completion.completed ? "" : "none"};"
|
||||
.row.mt-3 id="missing_pieces" style="display: #{@completion.completed && @completion.contest.missing_pieces ? "" : "none"};"
|
||||
.col
|
||||
.form-floating
|
||||
= form.text_field :missing_pieces, autocomplete: "off", class: "form-control"
|
||||
|
||||
@@ -10,13 +10,17 @@
|
||||
.form-check.form-switch
|
||||
= form.check_box :organizer_form, class: "form-check-input"
|
||||
= form.label :organizer_form
|
||||
.form-text = t("activerecord.attributes.contest.organizer_form")
|
||||
.row.mt-3.mb-3
|
||||
.col
|
||||
.form-floating
|
||||
= form.text_field :code, autocomplete: "off", class: "form-control"
|
||||
= form.label :code, class: "required"
|
||||
.form-text = t("activerecord.attributes.contest.code_description")
|
||||
.row.mt-1
|
||||
.col
|
||||
.form-check.form-switch
|
||||
= form.check_box :missing_pieces, class: "form-check-input"
|
||||
= form.label :missing_pieces
|
||||
.row.mt-4
|
||||
.col
|
||||
= form.submit t("helpers.buttons.update"), class: "btn btn-primary"
|
||||
@@ -59,6 +59,7 @@ en:
|
||||
duration: Duration
|
||||
duration_description: Format h:mm or hh:mm
|
||||
lang: Language for the public scoreboard
|
||||
missing_pieces: Ask for missing pieces for completed puzzles
|
||||
name: Name
|
||||
offline_form: Enable the offline participation form
|
||||
offline_form_description: Offline participants will have to fill the form by providing an image taken of the puzzle before starting solving it, and validate their finish time with an upload of an image of the completed puzzle
|
||||
|
||||
@@ -30,6 +30,7 @@ fr:
|
||||
duration: Durée
|
||||
duration_description: Format h:mm ou hh:mm
|
||||
lang: Langue pour le classement public
|
||||
missing_pieces: Demander le nombre de pièces manquantes pour les puzzles complétés
|
||||
name: Nom
|
||||
offline_form: Activer le formulaire de participation hors-ligne
|
||||
offline_form_description: Les participant.e.s hors-ligne pourront participer en prenant une photo du puzzle avant de le commencer, puis valider leur temps avec une photo du puzzle une fois complété
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
class AddMissingPiecesToContest < ActiveRecord::Migration[8.0]
|
||||
def change
|
||||
add_column :contests, :missing_pieces, :boolean
|
||||
end
|
||||
end
|
||||
3
db/schema.rb
generated
3
db/schema.rb
generated
@@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[8.0].define(version: 2026_07_30_055752) do
|
||||
ActiveRecord::Schema[8.0].define(version: 2026_08_25_071844) do
|
||||
create_table "active_storage_attachments", force: :cascade do |t|
|
||||
t.string "name", null: false
|
||||
t.string "record_type", null: false
|
||||
@@ -107,6 +107,7 @@ ActiveRecord::Schema[8.0].define(version: 2026_07_30_055752) do
|
||||
t.boolean "show_stopwatch"
|
||||
t.boolean "organizer_form"
|
||||
t.integer "event_id"
|
||||
t.boolean "missing_pieces"
|
||||
t.index ["event_id"], name: "index_contests_on_event_id"
|
||||
t.index ["slug"], name: "index_contests_on_slug", unique: true
|
||||
t.index ["user_id"], name: "index_contests_on_user_id"
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
# duration :string
|
||||
# duration_seconds :integer
|
||||
# lang :string default("en")
|
||||
# missing_pieces :boolean
|
||||
# name :string
|
||||
# offline_form :boolean default(FALSE)
|
||||
# organizer_form :boolean
|
||||
|
||||
Reference in New Issue
Block a user