Schedule update moved to program update
Schedule update updated a program attribute
This commit is contained in:
parent
310c521790
commit
81108290e5
4 changed files with 41 additions and 22 deletions
|
|
@ -11,4 +11,27 @@ $(function () {
|
||||||
dataType: 'script'
|
dataType: 'script'
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$("[class='switch-checkbox-schedule']").bootstrapSwitch();
|
||||||
|
|
||||||
|
$('input[class="switch-checkbox-schedule"]').on('switchChange.bootstrapSwitch', function(event, state) {
|
||||||
|
var url = $(this).attr('url');
|
||||||
|
var method = $(this).attr('method');
|
||||||
|
|
||||||
|
if(state){
|
||||||
|
url += $(this).attr('value');
|
||||||
|
}
|
||||||
|
|
||||||
|
var callback = function(data) {
|
||||||
|
if(data.status != 'ok'){
|
||||||
|
alert("The schedule couldn't been updated");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$.ajax({
|
||||||
|
url: url,
|
||||||
|
type: method,
|
||||||
|
success: callback,
|
||||||
|
dataType: 'json'
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -13,20 +13,28 @@ module Admin
|
||||||
@program.assign_attributes(program_params)
|
@program.assign_attributes(program_params)
|
||||||
send_mail_on_schedule_public = @program.notify_on_schedule_public?
|
send_mail_on_schedule_public = @program.notify_on_schedule_public?
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
if @program.update_attributes(program_params)
|
if @program.update_attributes(program_params)
|
||||||
ConferenceScheduleUpdateMailJob.perform_later(@conference) if send_mail_on_schedule_public
|
ConferenceScheduleUpdateMailJob.perform_later(@conference) if send_mail_on_schedule_public
|
||||||
|
format.html do
|
||||||
redirect_to admin_conference_program_path(@conference.short_title),
|
redirect_to admin_conference_program_path(@conference.short_title),
|
||||||
notice: 'The program was successfully updated.'
|
notice: 'The program was successfully updated.'
|
||||||
|
end
|
||||||
|
format.js { render json: { 'status' => 'ok' } }
|
||||||
else
|
else
|
||||||
|
format.html do
|
||||||
flash[:error] = "Updating program failed. #{@program.errors.to_a.join('. ')}."
|
flash[:error] = "Updating program failed. #{@program.errors.to_a.join('. ')}."
|
||||||
render :new
|
render :new
|
||||||
end
|
end
|
||||||
|
format.js { render json: { 'status' => 'error' } }
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def program_params
|
def program_params
|
||||||
params.require(:program).permit(:rating, :schedule_public, :schedule_fluid, :languages, :blind_voting, :voting_start_date, :voting_end_date)
|
params.require(:program).permit(:rating, :schedule_public, :schedule_fluid, :languages, :blind_voting, :voting_start_date, :voting_end_date, :selected_schedule_id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,6 @@ module Admin
|
||||||
load_resource :selected_schedule, through: :program, singleton: true
|
load_resource :selected_schedule, through: :program, singleton: true
|
||||||
load_resource :venue, through: :conference, singleton: true
|
load_resource :venue, through: :conference, singleton: true
|
||||||
|
|
||||||
skip_before_action :verify_authenticity_token, only: [:update]
|
|
||||||
|
|
||||||
def index; end
|
def index; end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
|
|
@ -29,16 +27,6 @@ module Admin
|
||||||
@rooms = (@venue && @venue.rooms.any?) ? @venue.rooms : [Room.new(name: 'No Rooms!', size: 0)]
|
@rooms = (@venue && @venue.rooms.any?) ? @venue.rooms : [Room.new(name: 'No Rooms!', size: 0)]
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
|
||||||
if params[:selected_schedule] == 'true'
|
|
||||||
@program.selected_schedule_id = params[:id].to_i
|
|
||||||
elsif params[:selected_schedule] == 'false' && (@selected_schedule.id == params[:id].to_i)
|
|
||||||
@program.selected_schedule_id = nil
|
|
||||||
end
|
|
||||||
@program.save
|
|
||||||
render json: { 'status' => 'ok' }
|
|
||||||
end
|
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
if @schedule.destroy
|
if @schedule.destroy
|
||||||
redirect_to admin_conference_schedules_path(conference_id: @conference.short_title),
|
redirect_to admin_conference_schedules_path(conference_id: @conference.short_title),
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,8 @@
|
||||||
.col-md-2
|
.col-md-2
|
||||||
Selected schedule
|
Selected schedule
|
||||||
= check_box_tag @conference.short_title, @schedule.id, (@schedule.id == @selected_schedule.try(:id)),
|
= check_box_tag @conference.short_title, @schedule.id, (@schedule.id == @selected_schedule.try(:id)),
|
||||||
method: :put, url: (admin_conference_schedule_path(@conference.short_title, @schedule) + '?selected_schedule='),
|
method: :patch, url: (admin_conference_program_path(@conference.short_title) + '?[program][selected_schedule_id]='),
|
||||||
class: 'switch-checkbox', data: { size: 'small',
|
class: 'switch-checkbox-schedule', data: { size: 'small',
|
||||||
off_color: 'warning',
|
off_color: 'warning',
|
||||||
on_text: 'Yes',
|
on_text: 'Yes',
|
||||||
off_text: 'No' }
|
off_text: 'No' }
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue