Add Halls to the Conference form
This commit is contained in:
parent
999da93b41
commit
ac5b1e2d4d
|
@ -1,11 +1,12 @@
|
||||||
module Management
|
module Management
|
||||||
class ConferencesController < ManagementController
|
class ConferencesController < ManagementController
|
||||||
before_action :assign_conference, only: [:edit, :open_call_for_papers, :close_call_for_papers]
|
before_action :assign_conference, only: [:edit, :update, :open_call_for_papers, :close_call_for_papers]
|
||||||
before_action :assign_conferences, only: [:index, :open_call_for_papers, :close_call_for_papers]
|
before_action :assign_conferences, only: [:index, :open_call_for_papers, :close_call_for_papers]
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@conference = Conference.new
|
@conference = Conference.new
|
||||||
3.times { @conference.tracks.build }
|
3.times { @conference.tracks.build }
|
||||||
|
@conference.halls.build(name: 'Hall 1')
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
|
@ -14,6 +15,12 @@ module Management
|
||||||
render :new
|
render :new
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
@conference.update conference_params
|
||||||
|
@conference.save
|
||||||
|
render :edit
|
||||||
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -45,7 +52,20 @@ module Management
|
||||||
end
|
end
|
||||||
|
|
||||||
def conference_params
|
def conference_params
|
||||||
params.require(:conference).permit [:title, :email, :start_date, :end_date, :description, tracks_attributes: [:id, :name, :color, :description, :_destroy]]
|
params.require(:conference).permit [:title,
|
||||||
|
:email,
|
||||||
|
:start_date,
|
||||||
|
:end_date,
|
||||||
|
:description,
|
||||||
|
tracks_attributes: [:id,
|
||||||
|
:name,
|
||||||
|
:color,
|
||||||
|
:description,
|
||||||
|
:_destroy],
|
||||||
|
halls_attributes: [:id,
|
||||||
|
:name,
|
||||||
|
:_destroy]
|
||||||
|
]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,8 +11,9 @@ class Conference < ActiveRecord::Base
|
||||||
has_many :tracks, -> { order('id asc') }
|
has_many :tracks, -> { order('id asc') }
|
||||||
has_many :events, through: :tracks
|
has_many :events, through: :tracks
|
||||||
has_many :candidate_speakers, through: :events
|
has_many :candidate_speakers, through: :events
|
||||||
|
has_many :halls
|
||||||
|
|
||||||
accepts_nested_attributes_for :tracks
|
accepts_nested_attributes_for :tracks, :halls, allow_destroy: true
|
||||||
|
|
||||||
scope :future, -> { where('start_date >= ?', Date.today).order('start_date ASC') }
|
scope :future, -> { where('start_date >= ?', Date.today).order('start_date ASC') }
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
class Hall < ActiveRecord::Base
|
class Hall < ActiveRecord::Base
|
||||||
belongs_to :conference
|
belongs_to :conference
|
||||||
|
has_many :slots, dependent: :destroy
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,7 +10,13 @@
|
||||||
= f.input :start_date, as: :date
|
= f.input :start_date, as: :date
|
||||||
= f.input :end_date, as: :date
|
= f.input :end_date, as: :date
|
||||||
= f.input :description
|
= f.input :description
|
||||||
|
hr
|
||||||
|
.row
|
||||||
|
.col-lg-12
|
||||||
|
h2 = Hall.model_name.human(count: 2).mb_chars.capitalize
|
||||||
|
.row
|
||||||
|
= render partial: 'form_halls', locals: {form: f}
|
||||||
|
hr
|
||||||
.row
|
.row
|
||||||
.col-lg-12
|
.col-lg-12
|
||||||
h2 = Track.model_name.human(count: 2).mb_chars.capitalize
|
h2 = Track.model_name.human(count: 2).mb_chars.capitalize
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
div#halls
|
||||||
|
= form.simple_fields_for :halls do |ff|
|
||||||
|
.col-md-3
|
||||||
|
.panel.panel-default
|
||||||
|
.panel-heading
|
||||||
|
.panel-title
|
||||||
|
= Hall.model_name.human.mb_chars.capitalize
|
||||||
|
= ff.link_to_remove fa_icon(:remove), class: ['btn', 'btn-danger', 'btn-xs', 'pull-right']
|
||||||
|
span.clearfix
|
||||||
|
.panel-body
|
||||||
|
= ff.input :name
|
||||||
|
.col-md-3
|
||||||
|
.panel.panel-default
|
||||||
|
.panel-heading
|
||||||
|
.panel-title
|
||||||
|
= t 'actions.new.title_f', model: Hall.model_name.human
|
||||||
|
.panel-body
|
||||||
|
.form-group.text-center
|
||||||
|
= form.link_to_add t('actions.create.button', model: Hall.model_name.human), :halls, data: {target: '#halls'}, class: 'btn btn-success'
|
|
@ -2,13 +2,19 @@ div#tracks
|
||||||
= form.simple_fields_for :tracks do |ff|
|
= form.simple_fields_for :tracks do |ff|
|
||||||
.col-lg-6
|
.col-lg-6
|
||||||
.panel.panel-default
|
.panel.panel-default
|
||||||
|
.panel-heading
|
||||||
|
.panel-title
|
||||||
|
= Track.model_name.human.mb_chars.capitalize
|
||||||
|
= ff.link_to_remove fa_icon(:remove), class: ['btn', 'btn-danger', 'btn-xs', 'pull-right', ff.object.events.any? ? 'disabled' : nil]
|
||||||
|
|
||||||
.panel-body
|
.panel-body
|
||||||
= ff.input :name
|
= ff.input :name
|
||||||
= ff.input :color, as: :color
|
= ff.input :color, as: :color
|
||||||
= ff.input :description
|
= ff.input :description
|
||||||
.panel-footer.text-right
|
|
||||||
= ff.link_to_remove t('actions.destroy.button', model: Track.model_name.human), class: ['btn', 'btn-danger', ff.object.events.any? ? 'disabled' : nil]
|
|
||||||
.col-lg-6
|
.col-lg-6
|
||||||
.panel.panel-default
|
.panel.panel-default
|
||||||
.panel-body.text-right
|
.panel-heading
|
||||||
|
.panel-title
|
||||||
|
= t 'actions.new.title_m', model: Track.model_name.human
|
||||||
|
.panel-body.text-center
|
||||||
= form.link_to_add t('actions.create.button', model: Track.model_name.human), :tracks, data: {target: '#tracks'}, class: 'btn btn-success'
|
= form.link_to_add t('actions.create.button', model: Track.model_name.human), :tracks, data: {target: '#tracks'}, class: 'btn btn-success'
|
||||||
|
|
|
@ -33,13 +33,17 @@ bg:
|
||||||
button: Прегледай %{model}
|
button: Прегледай %{model}
|
||||||
title: Преглед на %{model}
|
title: Преглед на %{model}
|
||||||
are_you_sure: Сигурен ли си?
|
are_you_sure: Сигурен ли си?
|
||||||
|
new:
|
||||||
create_new: Създаване на %{model_name}
|
title_f: Нова %{model}
|
||||||
|
title_m: Нов %{model}
|
||||||
event_mailer:
|
event_mailer:
|
||||||
acceptance_notification:
|
acceptance_notification:
|
||||||
subject: 'Предложението ви за %{conference} за %{submission_type} „%{title}“ е одобрено'
|
subject: 'Предложението ви за %{conference} за %{submission_type} „%{title}“ е одобрено'
|
||||||
activerecord:
|
activerecord:
|
||||||
models:
|
models:
|
||||||
|
hall:
|
||||||
|
one: зала
|
||||||
|
other: зали
|
||||||
user:
|
user:
|
||||||
one: Потребител
|
one: Потребител
|
||||||
other: Потребители
|
other: Потребители
|
||||||
|
@ -59,6 +63,12 @@ bg:
|
||||||
one: конференция
|
one: конференция
|
||||||
other: конференции
|
other: конференции
|
||||||
attributes:
|
attributes:
|
||||||
|
hall:
|
||||||
|
name: Име
|
||||||
|
track:
|
||||||
|
name: Име
|
||||||
|
color: Цвят
|
||||||
|
description: Описание
|
||||||
conference:
|
conference:
|
||||||
email: E-mail
|
email: E-mail
|
||||||
title: Заглавие
|
title: Заглавие
|
||||||
|
|
Loading…
Reference in New Issue