Support forcing the order of rooms in the schedule
This commit is contained in:
parent
02f0d4a254
commit
a9d6faf1a3
6 changed files with 17 additions and 6 deletions
|
|
@ -48,7 +48,7 @@ module Admin
|
||||||
private
|
private
|
||||||
|
|
||||||
def room_params
|
def room_params
|
||||||
params.require(:room).permit(:name, :size, :url)
|
params.require(:room).permit(:name, :size, :url, :order)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,9 @@ class Room < ApplicationRecord
|
||||||
validates :name, :venue_id, presence: true
|
validates :name, :venue_id, presence: true
|
||||||
|
|
||||||
validates :size, numericality: { only_integer: true, greater_than: 0 }, allow_nil: 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
|
def conference
|
||||||
venue.conference
|
venue.conference
|
||||||
|
|
|
||||||
|
|
@ -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|
|
= 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 :name, input_html: { autofocus: true }
|
||||||
= f.input :size, label: 'Capacity', input_html: {size: 5}
|
= f.input :size, label: 'Capacity', input_html: {size: 5}
|
||||||
= f.input :url, label: 'URL'
|
= f.input :order, label: 'Order', input_html: {size: 5}, hint: 'Force the order of rooms in the schedule.'
|
||||||
%p.small
|
= f.input :url, label: 'URL', hint: 'The URL is only visible to registered attendees.'
|
||||||
The URL is only visible to registered attendees.
|
|
||||||
%p.text-right
|
%p.text-right
|
||||||
= f.action :submit, as: :button, button_html: { class: 'btn btn-primary' }
|
= f.action :submit, as: :button, button_html: { class: 'btn btn-primary' }
|
||||||
|
|
|
||||||
|
|
@ -12,15 +12,18 @@
|
||||||
%thead
|
%thead
|
||||||
%th Name
|
%th Name
|
||||||
%th Capacity
|
%th Capacity
|
||||||
|
%th Order
|
||||||
%th URL
|
%th URL
|
||||||
%th Actions
|
%th Actions
|
||||||
%tbody
|
%tbody
|
||||||
- @rooms.each_with_index do |room, index|
|
- @rooms.each_with_index do |room, index|
|
||||||
%tr
|
%tr
|
||||||
%td
|
%th
|
||||||
= room.name
|
= room.name
|
||||||
%td
|
%td
|
||||||
= room.size
|
= room.size
|
||||||
|
%td
|
||||||
|
= room.order
|
||||||
%td
|
%td
|
||||||
= room.url
|
= room.url
|
||||||
%td
|
%td
|
||||||
|
|
|
||||||
5
db/migrate/20200716181602_add_order_to_rooms.rb
Normal file
5
db/migrate/20200716181602_add_order_to_rooms.rb
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
class AddOrderToRooms < ActiveRecord::Migration[5.2]
|
||||||
|
def change
|
||||||
|
add_column :rooms, :order, :int
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# 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
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
|
|
@ -408,6 +408,7 @@ ActiveRecord::Schema.define(version: 2020_07_15_034647) do
|
||||||
t.integer "size"
|
t.integer "size"
|
||||||
t.integer "venue_id", null: false
|
t.integer "venue_id", null: false
|
||||||
t.text "url"
|
t.text "url"
|
||||||
|
t.integer "order"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "schedules", force: :cascade do |t|
|
create_table "schedules", force: :cascade do |t|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue