Events: initial implementation
This commit is contained in:
22
app/views/events/_form.html.slim
Normal file
22
app/views/events/_form.html.slim
Normal file
@@ -0,0 +1,22 @@
|
||||
= form_with model: event, url: url, method: method 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-check.form-switch
|
||||
= form.check_box :shared_scoreboard, class: "form-check-input"
|
||||
= form.label :shared_scoreboard
|
||||
.form-text = t("activerecord.attributes.event.shared_scoreboard_description")
|
||||
|
||||
.alert.alert-primary role="alert"
|
||||
= t("events.form.shared_scoreboard_message")
|
||||
|
||||
.row.mt-4
|
||||
.col
|
||||
- if method == :patch
|
||||
= link_to t("helpers.buttons.delete"), event_path(event), data: { turbo_method: :delete }, class: "btn btn-danger me-2"
|
||||
= form.submit submit_text, class: "btn btn-primary"
|
||||
36
app/views/events/index.html.slim
Normal file
36
app/views/events/index.html.slim
Normal file
@@ -0,0 +1,36 @@
|
||||
.row
|
||||
.col
|
||||
h4.mb-3
|
||||
= t("events.index.subtitle")
|
||||
.float-end
|
||||
a.btn.btn-primary.mb-4 href=new_event_path
|
||||
= t("events.index.new")
|
||||
|
||||
.alert.alert-primary role="alert"
|
||||
= t("events.index.message")
|
||||
|
||||
- @events.each do |event|
|
||||
.row.mt-3
|
||||
.col
|
||||
css:
|
||||
.card:hover { background-color: lightblue; }
|
||||
.card.h-100
|
||||
.card-header
|
||||
= event.name
|
||||
.card-body
|
||||
.card-text.mb-2
|
||||
= "#{event.contests.size} " + t("events.index.contests") if event.contests.size > 1
|
||||
= "#{event.contests.size} " + t("events.index.contest") if event.contests.size <= 1
|
||||
a.stretched-link href=event_path(event)
|
||||
.row.mt-3
|
||||
.col
|
||||
css:
|
||||
.card:hover { background-color: lightblue; }
|
||||
.card.h-100
|
||||
.card-header
|
||||
= t("events.index.my_contests_outside_events")
|
||||
.card-body
|
||||
.card-text.mb-2
|
||||
= "#{@contests_without_event} " + t("events.index.contests") if @contests_without_event > 1
|
||||
= "#{@contests_without_event} " + t("events.index.contest") if @contests_without_event <= 1
|
||||
a.stretched-link href=contests_path
|
||||
1
app/views/events/new.html.slim
Normal file
1
app/views/events/new.html.slim
Normal file
@@ -0,0 +1 @@
|
||||
= render "form", event: @event, submit_text: t("helpers.buttons.add"), method: :post, url: "/events"
|
||||
28
app/views/events/show.html.slim
Normal file
28
app/views/events/show.html.slim
Normal file
@@ -0,0 +1,28 @@
|
||||
.row
|
||||
.col
|
||||
h4.mb-3
|
||||
= t("contests.index.manage_contests")
|
||||
.float-end
|
||||
a.btn.btn-primary.mb-4 href=new_contest_path
|
||||
= t("contests.index.new_contest")
|
||||
|
||||
.row.row-cols-1.row-cols-md-3.g-4
|
||||
- @contests.each do |contest|
|
||||
.col
|
||||
css:
|
||||
.card:hover { background-color: lightblue; }
|
||||
.card.h-100
|
||||
.card-header
|
||||
= contest.name
|
||||
.card-body
|
||||
.card-text.mb-2
|
||||
= "#{contest.puzzles.length} #{t('puzzles.singular')}" if contest.puzzles.length <= 1
|
||||
= "#{contest.puzzles.length} #{t('puzzles.plural')}" if contest.puzzles.length > 1
|
||||
= " - #{contest.contestants.length} #{t('contestants.singular')}" if contest.contestants.length <= 1
|
||||
= " - #{contest.contestants.length} #{t('contestants.plural')}" if contest.contestants.length > 1
|
||||
.row
|
||||
.col
|
||||
- contest.puzzles.each do |puzzle|
|
||||
- if puzzle.image.attached?
|
||||
= image_tag puzzle.image, style: "max-height: 50px;", class: "mb-2 me-2"
|
||||
a.stretched-link href=contest_path(contest)
|
||||
Reference in New Issue
Block a user