Use helpers for repeated event dropdown links

This commit is contained in:
James Mason 2018-02-13 16:33:11 -08:00
parent 4c58104a65
commit ad19a6d753
7 changed files with 370 additions and 146 deletions

View file

@ -1,37 +0,0 @@
- if event.transition_possible? :accept
%li= link_to 'Accept event',
accept_admin_conference_program_event_path(@conference.short_title, event),
method: :patch, id: "accept_event_#{event.id}"
- if @conference.email_settings.send_on_accepted?
%li= link_to 'Accept event (without email)',
accept_admin_conference_program_event_path(@conference.short_title, event, send_mail: false),
method: :patch, hint: 'Accept this event without sending an automated email.',
id: "accept_event_without_mail_#{event.id}"
- if event.transition_possible? :reject
%li= link_to 'Reject event',
reject_admin_conference_program_event_path(@conference.short_title, event),
method: :patch, confirm: 'Are you sure?', id: "reject_event_#{event.id}"
- if @conference.email_settings.send_on_rejected?
%li= link_to 'Reject event (without email)',
reject_admin_conference_program_event_path(@conference.short_title, event, send_mail: false),
method: :patch, confirm: 'Are you sure?', id: "reject_event_without_mail_#{event.id}"
- if event.transition_possible? :restart
%li= link_to 'Start review',
restart_admin_conference_program_event_path(@conference.short_title, event),
method: :patch, id: "restart_event_#{event.id}"
- if event.transition_possible? :confirm
%li= link_to 'Confirm event',
confirm_admin_conference_program_event_path(@conference.short_title, event),
method: :patch, id: "confirm_event_#{event.id}",
hint: 'Confirm that the speaker(s) will be present and that the event will actually take place.'
- if event.transition_possible? :cancel
%li= link_to 'Cancel event',
cancel_admin_conference_program_event_path(@conference.short_title, event),
method: :patch, id: "cancel_event_#{event.id}",
hint: 'Mark this event as cancelled. Usually this means that the speakers had to cancel their appearance.'

View file

@ -16,20 +16,7 @@
%td.col-md-2
%b Type
%td
.dropdown
= link_to '#', class: 'dropdown-toggle', id: 'type-dropdown', 'data-toggle' => 'dropdown' do
- if @event.event_type.nil?
Event Type
- else
= @event.event_type.title
<b class='caret'></b>
%ul.dropdown-menu
- @event_types.each do |type|
%li= link_to type.title,
admin_conference_program_event_path(@conference.short_title,
@event,
event: { event_type_id: type.id }),
method: :patch
= event_type_dropdown(@event, @event_types, @conference.short_title)
%tr
%td
%b Highlight
@ -45,47 +32,17 @@
%td
%b State
%td
.dropdown
= link_to '#', class: 'dropdown-toggle', 'data-toggle' => 'dropdown' do
= @event.state.humanize
<b class='caret'></b>
%ul.dropdown-menu
= render 'change_state_dropdown', event: @event
= state_dropdown(@event, @conference.short_title, @conference.email_settings)
%tr
%td
%b Track
%td
.dropdown
= link_to '#', class: 'dropdown-toggle', id: 'track-dropdown', 'data-toggle' => 'dropdown' do
- if @event.track.nil?
Track
- else
= @event.track.name
<b class="caret"></b>
%ul.dropdown-menu
- @tracks.each do |track|
%li= link_to track.name,
admin_conference_program_event_path(@conference.short_title,
@event,
event: { track_id: track.id }),
method: :patch
= track_dropdown(@event, @tracks, @conference.short_title)
%tr
%td
%b Difficulty
%td
.dropdown
= link_to '#', class: 'dropdown-toggle', id: 'difficulty-dropdown', 'data-toggle' => 'dropdown' do
- if @event.difficulty_level.nil?
Difficulty Level
- else
= @event.difficulty_level.title
<b class="caret"></b>
%ul.dropdown-menu
- @difficulty_levels.each do |difficulty|
%li= link_to difficulty.title, admin_conference_program_event_path(@conference.short_title,
@event,
event: { difficulty_level_id: difficulty.id }),
method: :patch
= difficulty_dropdown(@event, @difficulty_levels, @conference.short_title)
%tr
%td
%b Requires Registration

View file

@ -152,57 +152,12 @@
off_text: 'No' }
%td
.btn-group
%button{ type: 'button', class: 'btn btn-link dropdown-toggle', 'data-toggle' => 'dropdown' }
- if event.event_type.nil?
Event Type
- else
= event.event_type.title
%span.caret
%ul.dropdown-menu
- @event_types.each do |type|
%li= link_to type.title,
admin_conference_program_event_path(@conference.short_title,
event,
event: { event_type_id: type.id }),
method: :patch
= event_type_dropdown(event, @event_types, @conference.short_title)
%td
.btn-group
%button{ type: 'button', class: 'btn btn-link dropdown-toggle', 'data-toggle' => 'dropdown' }
- if event.track.nil?
Track
- else
= event.track.name
%span.caret
%ul.dropdown-menu
- @tracks.each do |track|
%li= link_to track.name,
admin_conference_program_event_path(@conference.short_title,
event,
event: { track_id: track.id }),
method: :patch
= track_dropdown(event, @tracks, @conference.short_title)
%td
.btn-group
%button{ type: 'button', class: 'btn btn-link dropdown-toggle', 'data-toggle' => 'dropdown' }
- if event.difficulty_level.nil?
Difficulty
- else
= event.difficulty_level.title
%span.caret
%ul.dropdown-menu
- @difficulty_levels.each do |difficulty_level|
%li= link_to difficulty_level.title,
admin_conference_program_event_path(@conference.short_title,
event,
event: { difficulty_level_id: difficulty_level.id }),
method: :patch
= difficulty_dropdown(event, @difficulty_levels, @conference.short_title)
%td
.btn-group
%button{ type: 'button', class: 'btn btn-link dropdown-toggle', 'data-toggle' => 'dropdown' }
= event.state.humanize
%span.caret
%ul.dropdown-menu{ role: 'menu' }
= render 'change_state_dropdown', event: event
= state_dropdown(event, @conference.short_title, @conference.email_settings)
%td.text-center
= link_to "#{event.comments_count}", admin_conference_program_event_path(@conference.short_title, event), anchor: 'comments-div'