DRY up event export menus

This commit is contained in:
James Mason 2018-02-22 21:15:27 -08:00
parent 0848df6948
commit 81bad2eb4d
3 changed files with 26 additions and 24 deletions

View file

@ -25,6 +25,7 @@ module Admin
@scheduled_event_distribution = @conference.scheduled_event_distribution @scheduled_event_distribution = @conference.scheduled_event_distribution
@file_name = "events_for_#{@conference.short_title}" @file_name = "events_for_#{@conference.short_title}"
@event_export_option = params[:event_export_option] @event_export_option = params[:event_export_option]
@export_formats = [:pdf, :csv, :xlsx]
respond_to do |format| respond_to do |format|
format.html format.html

View file

@ -0,0 +1,21 @@
.btn-group
%button.btn.btn-success.dropdown-toggle{ data: { toggle: 'dropdown' } }
Export
= export_format.upcase
%span.caret
%ul.dropdown-menu{ role: 'menu' }
%li
= link_to 'All Events',
admin_conference_program_events_path(conference_id,
format: export_format,
event_export_option: 'all')
%li
= link_to 'Confirmed Events',
admin_conference_program_events_path(conference_id,
format: export_format,
event_export_option: 'confirmed')
%li
= link_to 'All Events with Comments',
admin_conference_program_events_path(conference_id,
format: export_format,
event_export_option: 'all_with_comments')

View file

@ -13,30 +13,10 @@
= link_to 'Add Event', new_admin_conference_program_event_path(@conference.short_title), class: 'button btn btn-default btn-info' = link_to 'Add Event', new_admin_conference_program_event_path(@conference.short_title), class: 'button btn btn-default btn-info'
- if can? :read, Event - if can? :read, Event
.btn-group - @export_formats.each do |export_format|
%button.btn.btn-default.dropdown-toggle{ 'data-toggle' => 'dropdown', type: 'button', class: 'btn btn-success' } = render 'export_menu',
Export PDF export_format: export_format,
%span.caret conference_id: @conference.short_title
%ul.dropdown-menu{ role: 'menu' }
%li= link_to 'All Events', admin_conference_program_events_path(@conference.short_title, format: :pdf, event_export_option: 'all')
%li= link_to 'Confirmed Events', admin_conference_program_events_path(@conference.short_title, format: :pdf, event_export_option: 'confirmed')
%li= link_to 'All Events with Comments', admin_conference_program_events_path(@conference.short_title, format: :pdf, event_export_option: 'all_with_comments')
.btn-group
%button.btn.btn-default.dropdown-toggle{ 'data-toggle' => 'dropdown', type: 'button', class: 'btn btn-success' }
Export CSV
%span.caret
%ul.dropdown-menu{ role: 'menu' }
%li= link_to 'All', admin_conference_program_events_path(@conference.short_title, format: :csv, event_export_option: 'all')
%li= link_to 'Confirmed', admin_conference_program_events_path(@conference.short_title, format: :csv, event_export_option: 'confirmed')
%li= link_to 'All with Comments', admin_conference_program_events_path(@conference.short_title, format: :csv, event_export_option: 'all_with_comments')
.btn-group
%button.btn.btn-default.dropdown-toggle{ 'data-toggle' => 'dropdown', type: 'button', class: 'btn btn-success' }
Export XLS
%span.caret
%ul.dropdown-menu{ role: 'menu' }
%li= link_to 'All', admin_conference_program_events_path(@conference.short_title, format: :xlsx, event_export_option: 'all')
%li= link_to 'Confirmed', admin_conference_program_events_path(@conference.short_title, format: :xlsx, event_export_option: 'confirmed')
%li= link_to 'All with Comments', admin_conference_program_events_path(@conference.short_title, format: :xlsx, event_export_option: 'all_with_comments')
%p.text-muted %p.text-muted
All the submissions of your speakers All the submissions of your speakers