Add number of pieces to puzzles
This commit is contained in:
@@ -61,6 +61,6 @@ class PuzzlesController < ApplicationController
|
||||
end
|
||||
|
||||
def puzzle_params
|
||||
params.expect(puzzle: [ :brand, :name, :image ])
|
||||
params.expect(puzzle: [ :brand, :name, :image, :pieces ])
|
||||
end
|
||||
end
|
||||
|
@@ -5,6 +5,7 @@
|
||||
# id :integer not null, primary key
|
||||
# brand :string
|
||||
# name :string
|
||||
# pieces :integer not null
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# contest_id :integer not null
|
||||
@@ -24,4 +25,5 @@ class Puzzle < ApplicationRecord
|
||||
has_one_attached :image
|
||||
|
||||
validates :name, presence: true
|
||||
validates :pieces, presence: true
|
||||
end
|
||||
|
@@ -29,16 +29,9 @@ css:
|
||||
= image_tag(puzzle.image, style: "max-height: 200px; object-fit: contain") if puzzle.image.attached?
|
||||
.mt-2.fs-6 style="text-align: center"
|
||||
=> "#{puzzle.name} -"
|
||||
= puzzle.brand
|
||||
= "#{puzzle.brand} #{puzzle.pieces}p"
|
||||
.row
|
||||
.col-6.d-flex.flex-column style="height: calc(100vh - 180px)"
|
||||
/ = form_with model: Contest do |form|
|
||||
/ .row.mb-3
|
||||
/ .col
|
||||
/ .form-check.form-switch
|
||||
/ = form.check_box :refresh, class: "form-check-input"
|
||||
/ = form.label t("contests.scoreboard.refresh")
|
||||
|
||||
.d-flex.flex-column style="overflow-y: auto"
|
||||
table.table.table-striped.table-hover
|
||||
thead
|
||||
@@ -76,7 +69,7 @@ css:
|
||||
= puzzle.name
|
||||
.fs-6 style="margin-left: 15px"
|
||||
b
|
||||
= puzzle.brand
|
||||
= "#{puzzle.brand} - #{puzzle.pieces}p"
|
||||
|
||||
- else
|
||||
.d-flex.flex-column style="height: calc(100vh - 180px)"
|
||||
@@ -84,17 +77,6 @@ css:
|
||||
- @contest.puzzles.each do |puzzle|
|
||||
= image_tag(puzzle.image, class: "img-fluid ms-3 me-3", style: "max-height: 220px") if puzzle.image.attached?
|
||||
|
||||
.mb-3 style="display: inline-flex"
|
||||
a.btn.btn-primary href="/public/#{@contest.friendly_id}"
|
||||
= t("helpers.buttons.refresh")
|
||||
|
||||
/ = form_with model: Contest do |form|
|
||||
/ .row.mb-3
|
||||
/ .col
|
||||
/ .form-check.form-switch
|
||||
/ = form.check_box :refresh, class: "form-check-input"
|
||||
/ = form.label t("contests.scoreboard.refresh")
|
||||
|
||||
.d-flex.flex-column style="overflow-y: auto"
|
||||
table.table.table-striped.table-hover
|
||||
thead
|
||||
|
@@ -43,12 +43,14 @@ javascript:
|
||||
table.table.table-striped.table-hover
|
||||
thead
|
||||
tr
|
||||
th scope="col"
|
||||
th
|
||||
= t("activerecord.attributes.puzzle.image")
|
||||
th scope="col"
|
||||
th
|
||||
= t("activerecord.attributes.puzzle.name")
|
||||
th scope="col"
|
||||
th
|
||||
= t("activerecord.attributes.puzzle.brand")
|
||||
th
|
||||
= t("activerecord.attributes.puzzle.pieces")
|
||||
tbody
|
||||
- @puzzles.each do |puzzle|
|
||||
tr.align-middle scope="row"
|
||||
@@ -58,6 +60,8 @@ javascript:
|
||||
= puzzle.name
|
||||
td
|
||||
= puzzle.brand
|
||||
td
|
||||
= puzzle.pieces
|
||||
td
|
||||
a.btn.btn-sm.btn-secondary href=edit_contest_puzzle_path(@contest, puzzle)
|
||||
= t("helpers.buttons.edit")
|
||||
|
@@ -15,6 +15,11 @@
|
||||
.form-floating
|
||||
= form.text_field :brand, autocomplete: "off", class: "form-control"
|
||||
= form.label :brand, class: "required"
|
||||
.row.mb-3
|
||||
.col
|
||||
.form-floating
|
||||
= form.number_field :pieces, autocomplete: "off", class: "form-control"
|
||||
= form.label :pieces, class: "required"
|
||||
.row.mb-3
|
||||
.col
|
||||
.form-text.mb-1
|
||||
|
Reference in New Issue
Block a user