Support forcing the order of rooms in the schedule

This commit is contained in:
Michael Ball 2020-07-16 11:25:20 -07:00
parent 02f0d4a254
commit a9d6faf1a3
6 changed files with 17 additions and 6 deletions

View file

@ -48,7 +48,7 @@ module Admin
private
def room_params
params.require(:room).permit(:name, :size, :url)
params.require(:room).permit(:name, :size, :url, :order)
end
end
end

View file

@ -13,6 +13,9 @@ class Room < ApplicationRecord
validates :name, :venue_id, presence: true
validates :size, numericality: { only_integer: true, greater_than: 0 }, allow_nil: true
validates :order, numericality: { only_integer: true, greater_than: 0 }, allow_nil: true
default_scope { order(order: :asc) }
def conference
venue.conference

View file

@ -11,8 +11,7 @@
= semantic_form_for(@room, url: (@room.new_record? ? admin_conference_venue_rooms_path : admin_conference_venue_room_path(@conference.short_title, @room))) do |f|
= f.input :name, input_html: { autofocus: true }
= f.input :size, label: 'Capacity', input_html: {size: 5}
= f.input :url, label: 'URL'
%p.small
The URL is only visible to registered attendees.
= f.input :order, label: 'Order', input_html: {size: 5}, hint: 'Force the order of rooms in the schedule.'
= f.input :url, label: 'URL', hint: 'The URL is only visible to registered attendees.'
%p.text-right
= f.action :submit, as: :button, button_html: { class: 'btn btn-primary' }

View file

@ -12,15 +12,18 @@
%thead
%th Name
%th Capacity
%th Order
%th URL
%th Actions
%tbody
- @rooms.each_with_index do |room, index|
%tr
%td
%th
= room.name
%td
= room.size
%td
= room.order
%td
= room.url
%td

View file

@ -0,0 +1,5 @@
class AddOrderToRooms < ActiveRecord::Migration[5.2]
def change
add_column :rooms, :order, :int
end
end

View file

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2020_07_15_034647) do
ActiveRecord::Schema.define(version: 2020_07_16_181602) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -408,6 +408,7 @@ ActiveRecord::Schema.define(version: 2020_07_15_034647) do
t.integer "size"
t.integer "venue_id", null: false
t.text "url"
t.integer "order"
end
create_table "schedules", force: :cascade do |t|