Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions app/assets/javascripts/add-all-chapters.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// "Add to all" option at the top of the chapters dropdown on the admin event
// form. Selects every chapter so organisers don't have to pick each one.
// Chosen only renders <option>s, so the row is injected into its dropdown.

/* global $ */

$(() => {
const $chapters = $("#event_chapter_ids");

$chapters.on("chosen:ready", () => {
const $addAll = $('<div class="add-all-chapters">Add to all</div>');
$chapters.next(".chosen-container").find(".chosen-drop").prepend($addAll);

// mousedown fires before Chosen's blur handling closes the dropdown;
// stopPropagation keeps Chosen's container handler from reopening it
$addAll.on("mousedown", (event) => {
event.preventDefault();
event.stopPropagation();
$chapters.find("option").prop("selected", true);
$chapters.trigger("change").trigger("chosen:updated").trigger("chosen:close");
});
});
});
1 change: 1 addition & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
//= require pickadate/picker.date
//= require pickadate/picker.time
//= require subscriptions-toggle
//= require add-all-chapters
//= require invitations
//= require dietary-restrictions
//= require cocoon
Expand Down
10 changes: 10 additions & 0 deletions app/assets/stylesheets/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ form .hint {
margin-bottom: 1.14286rem;
}

.add-all-chapters {
cursor: pointer;
font-weight: bold;
padding: 8px 6px 4px;
}

.add-all-chapters:hover {
color: #1e90ff;
}

.small-image {
max-height: 100px;
}
Expand Down
34 changes: 24 additions & 10 deletions spec/features/admin/manage_event_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,24 @@
scenario 'accessing an event' do
visit admin_event_path(event)

expect(page).to have_content(event.name)
expect(page).to have_text(event.name)

expect(page).to have_content 'Venue'
expect(page).to have_content event.venue.name
expect(page).to have_text 'Venue'
expect(page).to have_text event.venue.name
end

scenario 'adding all chapters to an event with one click', :js do
Fabricate.times(2, :chapter)
visit edit_admin_event_path(event)

find('#event_chapter_ids_chosen').click
find('.add-all-chapters', text: 'Add to all').click
expect(page).to have_no_css('#event_chapter_ids_chosen.chosen-with-drop')

click_on 'Save'

expect(page).to have_text('You have just updated the event')
expect(event.reload.chapter_ids).to match_array(Chapter.ids)
end

scenario 'verifying an attendance' do
Expand All @@ -23,7 +37,7 @@

click_on 'Verify'

expect(page).to have_content "You have verified #{invitation.member.full_name}'s spot at the event!"
expect(page).to have_text "You have verified #{invitation.member.full_name}'s spot at the event!"
expect(invitation.reload.verified_by).to eq(member)
end

Expand All @@ -33,8 +47,8 @@

click_on 'Cancel'

expect(page).to have_content "You have cancelled #{invitation.member.full_name}'s attendance."
expect(invitation.reload.attending).to eq(false)
expect(page).to have_text "You have cancelled #{invitation.member.full_name}'s attendance."
expect(invitation.reload.attending).to be(false)
end

scenario 'accessing a list of attendee emails' do
Expand All @@ -44,9 +58,9 @@

click_on 'Emails'

expect(page).to have_content('COACHES')
expect(page).to have_content(coach_invitation.member.email)
expect(page).to have_content('STUDENTS')
expect(page).to have_content(student_invitation.member.email)
expect(page).to have_text('COACHES')
expect(page).to have_text(coach_invitation.member.email)
expect(page).to have_text('STUDENTS')
expect(page).to have_text(student_invitation.member.email)
end
end