Use helpers for repeated event dropdown links
This commit is contained in:
parent
25df48f351
commit
48579882a5
6 changed files with 151 additions and 145 deletions
|
|
@ -50,4 +50,135 @@ module EventsHelper
|
||||||
def rating_tooltip(event, max_rating)
|
def rating_tooltip(event, max_rating)
|
||||||
"#{event.average_rating}/#{max_rating}, #{pluralize(event.voters.length, 'vote')}"
|
"#{event.average_rating}/#{max_rating}, #{pluralize(event.voters.length, 'vote')}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def event_type_dropdown(event, event_types, conference_id)
|
||||||
|
selection = event.event_type.try(:title) || 'Event Type'
|
||||||
|
options = event_types.collect do |event_type|
|
||||||
|
[
|
||||||
|
event_type.title,
|
||||||
|
admin_conference_program_event_path(
|
||||||
|
conference_id,
|
||||||
|
event,
|
||||||
|
event: { event_type_id: event_type.id }
|
||||||
|
)
|
||||||
|
]
|
||||||
|
end
|
||||||
|
active_dropdown(selection, options)
|
||||||
|
end
|
||||||
|
|
||||||
|
def track_dropdown(event, tracks, conference_id)
|
||||||
|
selection = event.track.try(:name) || 'Track'
|
||||||
|
options = tracks.collect do |track|
|
||||||
|
[
|
||||||
|
track.name,
|
||||||
|
admin_conference_program_event_path(
|
||||||
|
conference_id,
|
||||||
|
event,
|
||||||
|
event: { track_id: track.id }
|
||||||
|
)
|
||||||
|
]
|
||||||
|
end
|
||||||
|
active_dropdown(selection, options)
|
||||||
|
end
|
||||||
|
|
||||||
|
def difficulty_dropdown(event, difficulties, conference_id)
|
||||||
|
selection = event.difficulty_level.try(:title) || 'Difficulty'
|
||||||
|
options = difficulties.collect do |difficulty|
|
||||||
|
[
|
||||||
|
difficulty.title,
|
||||||
|
admin_conference_program_event_path(
|
||||||
|
conference_id,
|
||||||
|
event,
|
||||||
|
event: { difficulty_level_id: difficulty.id }
|
||||||
|
)
|
||||||
|
]
|
||||||
|
end
|
||||||
|
active_dropdown(selection, options)
|
||||||
|
end
|
||||||
|
|
||||||
|
def state_dropdown(event, conference_id, email_settings)
|
||||||
|
selection = event.state.humanize
|
||||||
|
options = []
|
||||||
|
if event.transition_possible? :accept
|
||||||
|
options << [
|
||||||
|
'Accept',
|
||||||
|
accept_admin_conference_program_event_path(conference_id, event)
|
||||||
|
]
|
||||||
|
if email_settings.send_on_accepted?
|
||||||
|
options << [
|
||||||
|
'Accept (without email)',
|
||||||
|
accept_admin_conference_program_event_path(
|
||||||
|
conference_id,
|
||||||
|
event,
|
||||||
|
send_mail: false
|
||||||
|
)
|
||||||
|
]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if event.transition_possible? :reject
|
||||||
|
options << [
|
||||||
|
'Reject',
|
||||||
|
reject_admin_conference_program_event_path(conference_id, event)
|
||||||
|
]
|
||||||
|
if email_settings.send_on_rejected?
|
||||||
|
options << [
|
||||||
|
'Reject (without email)',
|
||||||
|
reject_admin_conference_program_event_path(
|
||||||
|
conference_id,
|
||||||
|
event,
|
||||||
|
send_mail: false
|
||||||
|
)
|
||||||
|
]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if event.transition_possible? :restart
|
||||||
|
options << [
|
||||||
|
'Start review',
|
||||||
|
restart_admin_conference_program_event_path(conference_id, event)
|
||||||
|
]
|
||||||
|
end
|
||||||
|
if event.transition_possible? :confirm
|
||||||
|
options << [
|
||||||
|
'Confirm',
|
||||||
|
confirm_admin_conference_program_event_path(conference_id, event)
|
||||||
|
]
|
||||||
|
end
|
||||||
|
if event.transition_possible? :cancel
|
||||||
|
options << [
|
||||||
|
'Cancel',
|
||||||
|
cancel_admin_conference_program_event_path(conference_id, event)
|
||||||
|
]
|
||||||
|
end
|
||||||
|
active_dropdown(selection, options)
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def active_dropdown(selection, options)
|
||||||
|
# Consistent rendering of dropdown lists that submit patched changes
|
||||||
|
#
|
||||||
|
# Selection is the string to show by default, which is clicked to expose the
|
||||||
|
# dropdown options.
|
||||||
|
# Options is a list of 2-item lists; for each entry:
|
||||||
|
# * [0] is the text of the option,
|
||||||
|
# * [1] is the link url for the options
|
||||||
|
content_tag('div', class: 'dropdown') do
|
||||||
|
content_tag(
|
||||||
|
'a',
|
||||||
|
class: 'dropdown-toggle',
|
||||||
|
href: '#',
|
||||||
|
data: {
|
||||||
|
toggle: 'dropdown'
|
||||||
|
}
|
||||||
|
) do
|
||||||
|
content_tag('span', selection) +
|
||||||
|
content_tag('span', '', class: 'caret')
|
||||||
|
end +
|
||||||
|
content_tag('ul', class: 'dropdown-menu') do
|
||||||
|
options.collect do |option|
|
||||||
|
content_tag('li', link_to(option[0], option[1], method: :patch))
|
||||||
|
end.join.html_safe
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -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.'
|
|
||||||
|
|
@ -16,20 +16,7 @@
|
||||||
%td.col-md-2
|
%td.col-md-2
|
||||||
%b Type
|
%b Type
|
||||||
%td
|
%td
|
||||||
.dropdown
|
= event_type_dropdown(@event, @event_types, @conference.short_title)
|
||||||
= 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
|
|
||||||
%tr
|
%tr
|
||||||
%td
|
%td
|
||||||
%b Highlight
|
%b Highlight
|
||||||
|
|
@ -45,47 +32,17 @@
|
||||||
%td
|
%td
|
||||||
%b State
|
%b State
|
||||||
%td
|
%td
|
||||||
.dropdown
|
= state_dropdown(@event, @conference.short_title, @conference.email_settings)
|
||||||
= 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
|
|
||||||
%tr
|
%tr
|
||||||
%td
|
%td
|
||||||
%b Track
|
%b Track
|
||||||
%td
|
%td
|
||||||
.dropdown
|
= track_dropdown(@event, @tracks, @conference.short_title)
|
||||||
= 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
|
|
||||||
%tr
|
%tr
|
||||||
%td
|
%td
|
||||||
%b Difficulty
|
%b Difficulty
|
||||||
%td
|
%td
|
||||||
.dropdown
|
= difficulty_dropdown(@event, @difficulty_levels, @conference.short_title)
|
||||||
= 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
|
|
||||||
%tr
|
%tr
|
||||||
%td
|
%td
|
||||||
%b Requires Registration
|
%b Requires Registration
|
||||||
|
|
|
||||||
|
|
@ -152,57 +152,12 @@
|
||||||
off_text: 'No' }
|
off_text: 'No' }
|
||||||
|
|
||||||
%td
|
%td
|
||||||
.btn-group
|
= event_type_dropdown(event, @event_types, @conference.short_title)
|
||||||
%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
|
|
||||||
%td
|
%td
|
||||||
.btn-group
|
= track_dropdown(event, @tracks, @conference.short_title)
|
||||||
%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
|
|
||||||
%td
|
%td
|
||||||
.btn-group
|
= difficulty_dropdown(event, @difficulty_levels, @conference.short_title)
|
||||||
%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
|
|
||||||
|
|
||||||
%td
|
%td
|
||||||
.btn-group
|
= state_dropdown(event, @conference.short_title, @conference.email_settings)
|
||||||
%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
|
|
||||||
%td.text-center
|
%td.text-center
|
||||||
= link_to "#{event.comments_count}", admin_conference_program_event_path(@conference.short_title, event), anchor: 'comments-div'
|
= link_to "#{event.comments_count}", admin_conference_program_event_path(@conference.short_title, event), anchor: 'comments-div'
|
||||||
|
|
|
||||||
|
|
@ -30,8 +30,8 @@ feature Event do
|
||||||
visit admin_conference_program_events_path(conference.short_title)
|
visit admin_conference_program_events_path(conference.short_title)
|
||||||
expect(page).to have_content 'Example Proposal'
|
expect(page).to have_content 'Example Proposal'
|
||||||
|
|
||||||
click_button 'New'
|
click_on 'New'
|
||||||
click_link "reject_event_#{@event.id}"
|
click_link 'Reject'
|
||||||
expect(page).to have_content 'Event rejected!'
|
expect(page).to have_content 'Event rejected!'
|
||||||
@event.reload
|
@event.reload
|
||||||
expect(@event.state).to eq('rejected')
|
expect(@event.state).to eq('rejected')
|
||||||
|
|
@ -41,8 +41,8 @@ feature Event do
|
||||||
visit admin_conference_program_events_path(conference.short_title)
|
visit admin_conference_program_events_path(conference.short_title)
|
||||||
expect(page).to have_content 'Example Proposal'
|
expect(page).to have_content 'Example Proposal'
|
||||||
|
|
||||||
click_button 'New'
|
click_on 'New'
|
||||||
click_link "accept_event_#{@event.id}"
|
click_link 'Accept'
|
||||||
expect(page).to have_content 'Event accepted!'
|
expect(page).to have_content 'Event accepted!'
|
||||||
expect(page).to have_content 'Unconfirmed'
|
expect(page).to have_content 'Unconfirmed'
|
||||||
@event.reload
|
@event.reload
|
||||||
|
|
@ -54,8 +54,8 @@ feature Event do
|
||||||
visit admin_conference_program_events_path(conference.short_title)
|
visit admin_conference_program_events_path(conference.short_title)
|
||||||
expect(page).to have_content 'Example Proposal'
|
expect(page).to have_content 'Example Proposal'
|
||||||
|
|
||||||
click_button 'Rejected'
|
click_on 'Rejected'
|
||||||
click_link "restart_event_#{@event.id}"
|
click_link 'Start review'
|
||||||
expect(page).to have_content 'Review started!'
|
expect(page).to have_content 'Review started!'
|
||||||
@event.reload
|
@event.reload
|
||||||
expect(@event.state).to eq('new')
|
expect(@event.state).to eq('new')
|
||||||
|
|
|
||||||
|
|
@ -189,8 +189,8 @@ feature 'Version' do
|
||||||
click_button 'Update Proposal'
|
click_button 'Update Proposal'
|
||||||
|
|
||||||
visit admin_conference_program_events_path(conference.short_title)
|
visit admin_conference_program_events_path(conference.short_title)
|
||||||
click_button 'New'
|
click_on 'New'
|
||||||
click_link 'Reject event'
|
click_link 'Reject'
|
||||||
|
|
||||||
visit conference_program_proposals_path(conference_id: conference.short_title)
|
visit conference_program_proposals_path(conference_id: conference.short_title)
|
||||||
within('#events') do
|
within('#events') do
|
||||||
|
|
@ -198,15 +198,15 @@ feature 'Version' do
|
||||||
end
|
end
|
||||||
|
|
||||||
visit admin_conference_program_events_path(conference.short_title)
|
visit admin_conference_program_events_path(conference.short_title)
|
||||||
click_button 'New'
|
click_on 'New'
|
||||||
click_link 'Accept event'
|
click_link 'Accept'
|
||||||
|
|
||||||
visit conference_program_proposals_path(conference_id: conference.short_title)
|
visit conference_program_proposals_path(conference_id: conference.short_title)
|
||||||
click_link 'Confirm'
|
click_link 'Confirm'
|
||||||
|
|
||||||
visit admin_conference_program_events_path(conference.short_title)
|
visit admin_conference_program_events_path(conference.short_title)
|
||||||
click_button 'Confirmed'
|
click_on 'Confirmed'
|
||||||
click_link 'Cancel event'
|
click_link 'Cancel'
|
||||||
|
|
||||||
visit admin_revision_history_path
|
visit admin_revision_history_path
|
||||||
expect(page).to have_text("#{organizer.name} submitted new event ABC in conference #{conference.short_title}")
|
expect(page).to have_text("#{organizer.name} submitted new event ABC in conference #{conference.short_title}")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue