diff --git a/app/helpers/events_helper.rb b/app/helpers/events_helper.rb index 3d6e70c4..1140898b 100644 --- a/app/helpers/events_helper.rb +++ b/app/helpers/events_helper.rb @@ -156,6 +156,27 @@ module EventsHelper active_dropdown(selection, options) end + def event_switch_checkbox(event, attribute, conference_id) + check_box_tag( + conference_id, + event.id, + event.send(attribute), + url: admin_conference_program_event_path( + conference_id, + event, + event: { attribute => nil } + ), + method: :patch, + class: 'switch-checkbox', + data: { + size: 'small', + off_color: 'warning', + on_text: 'Yes', + off_text: 'No' + } + ) + end + private def active_dropdown(selection, options) diff --git a/app/views/admin/events/_proposal.html.haml b/app/views/admin/events/_proposal.html.haml index 78d6ee02..a1d9387a 100644 --- a/app/views/admin/events/_proposal.html.haml +++ b/app/views/admin/events/_proposal.html.haml @@ -21,13 +21,7 @@ %td %b Highlight %td - = check_box_tag @conference.short_title, @event.id, @event.is_highlight, - method: :patch, url: "/admin/conferences/#{@conference.short_title}/program/events/#{@event.id}?event[is_highlight]=", - class: 'switch-checkbox', data: { size: 'small', - off_color: 'warning', - on_text: 'Yes', - off_text: 'No' } - + = event_switch_checkbox(@event, :is_highlight, @conference.short_title) %tr %td %b State @@ -47,12 +41,7 @@ %td %b Requires Registration %td - = check_box_tag @conference.short_title, @event.id, @event.require_registration, - method: :patch, url: "/admin/conferences/#{@conference.short_title}/program/events/#{@event.id}?event[require_registration]=", - class: 'switch-checkbox', data: { size: 'small', - off_color: 'warning', - on_text: 'Yes', - off_text: 'No' } + = event_switch_checkbox(@event, :require_registration, @conference.short_title) - if @event.require_registration = registered_text(@event) diff --git a/app/views/admin/events/index.html.haml b/app/views/admin/events/index.html.haml index ce77a709..d61d8112 100644 --- a/app/views/admin/events/index.html.haml +++ b/app/views/admin/events/index.html.haml @@ -133,24 +133,12 @@ = event.language %td.text-center{ 'data-order' => "#{event.require_registration}" } - = check_box_tag @conference.short_title, event.id, event.require_registration, - method: :patch, url: "/admin/conferences/#{@conference.short_title}/program/events/#{event.id}?event[require_registration]=", - class: 'switch-checkbox', data: { size: 'small', - off_color: 'warning', - on_text: 'Yes', - off_text: 'No' } + = event_switch_checkbox(event, :require_registration, @conference.short_title) - if event.require_registration - %br = link_to registered_text(event), registrations_admin_conference_program_event_path(@conference.short_title, event), class: 'btn btn-xs btn-default' %td.text-center{ 'data-order' => "#{event.is_highlight}" } - = check_box_tag @conference.short_title, event.id, event.is_highlight, - method: :patch, url: "/admin/conferences/#{@conference.short_title}/program/events/#{event.id}?event[is_highlight]=", - class: 'switch-checkbox', data: { size: 'small', - off_color: 'warning', - on_text: 'Yes', - off_text: 'No' } - + = event_switch_checkbox(event, :is_highlight, @conference.short_title) %td = event_type_dropdown(event, @event_types, @conference.short_title) %td