Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Corrections to proposal help text #3243

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
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
6 changes: 2 additions & 4 deletions app/assets/javascripts/osem.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,17 +145,15 @@ function word_count(text, divId, maxcount) {
/* Wait for the DOM to be ready before attaching events to the elements */
$( document ).ready(function() {
/* Set the minimum and maximum proposal abstract word length */
function updateEventTypeRequirements() {
$("#event_event_type_id").change(function () {
var $selected = $("#event_event_type_id option:selected")
var max = $selected.data("max-words");
var min = $selected.data("min-words");

$("#abstract-maximum-word-count").text(max);
$("#abstract-minimum-word-count").text(min);
word_count($('#event_abstract').get(0), 'abstract-count', max);
}
$("#event_event_type_id").change(updateEventTypeRequirements);
updateEventTypeRequirements();
});

/* Count the proposal abstract length */
$("#event_abstract").on('input', function() {
Expand Down
9 changes: 8 additions & 1 deletion app/helpers/event_types_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ module EventTypesHelper
# ====Returns
# * +String+ -> number of registrations / max allowed registrations
def event_type_select_options(event_types = {})
event_types.map { |type| ["#{type.title} - #{show_time(type.length)}", type.id] }
event_types.map do |type|
content = "#{type.title} - #{show_time(type.length)}"
value = type.id
attributes = { data: { min_words: type.minimum_abstract_length,
max_words: type.maximum_abstract_length } }

[content, value, attributes]
end
end
end
10 changes: 5 additions & 5 deletions app/views/proposals/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
display_details = user_is_admin || action_is_edit
display_registration = user_is_admin || @program.cfp&.enable_registrations?

event_type = @event.event_type || @conference.program.event_types.first

%h4
Proposal Information
%hr
Expand Down Expand Up @@ -48,13 +50,11 @@
= markdown_hint('[Tips to improve your presentations.](http://blog.hubspot.com/blog/tabid/6307/bid/5975/10-Rules-to-Instantly-Improve-Your-Presentations.aspx)')
%p
You have used
%span#abstract-count = @event.abstract_word_count
%span#abstract-count= @event.abstract_word_count
words. Abstracts must be between
%span#abstract-minimum-word-count
0
%span#abstract-minimum-word-count= event_type.minimum_abstract_length
and
%span#abstract-maximum-word-count
250
%span#abstract-maximum-word-count= event_type.maximum_abstract_length
words.
- if display_registration && display_details
%h4
Expand Down
2 changes: 1 addition & 1 deletion spec/factories/event_types.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
length { 30 }
description { 'This event type is an example.' }
minimum_abstract_length { 0 }
maximum_abstract_length { 500 }
maximum_abstract_length { 123 }
color { '#ffffff' }
program
end
Expand Down
25 changes: 24 additions & 1 deletion spec/features/proposals_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,16 @@
fill_in 'user_password_confirmation', with: 'testuserpassword'
end
fill_in 'event_title', with: 'Example Proposal'

expect(page).to have_selector '.in', text: 'Presentation in lecture format'
expect(page).to have_text 'Abstracts must be between 0 and 500 words.'
select('Example Event Type', from: 'event[event_type_id]')
expect(page).to have_selector '.in', text: 'This event type is an example.'
expect(page).to have_text 'Abstracts must be between 0 and 123 words.'

expect(page).to have_text('You have used 0 words')
fill_in 'event_abstract', with: 'Lorem ipsum abstract'
expect(page).to have_text('You have used 3 words')

click_button 'Create Proposal'
page.find('#flash')
Expand All @@ -115,22 +121,39 @@

scenario 'update a proposal', js: true do
conference = create(:conference)
create :event_type, program: conference.program,
title: 'Five to Ten Words',
description: 'This has a nonzero minimum.',
minimum_abstract_length: 5,
maximum_abstract_length: 10
create :track, program: conference.program,
name: 'Example Track',
description: 'This track is an *example*.'
create(:cfp, program: conference.program)
proposal = create(:event, program: conference.program)
proposal = create(:event, program: conference.program, abstract: 'Three word abstract')

sign_in proposal.submitter

visit edit_conference_program_proposal_path(proposal.program.conference.short_title, proposal)

fill_in 'event_subtitle', with: 'My event subtitle'

select 'Example Track', from: 'Track'
expect(page).to have_selector '.in', text: 'This track is an example.'

select('Easy', from: 'event[difficulty_level_id]')
expect(page).to have_selector '.in', text: 'Events are understandable for everyone without knowledge of the topic.'

expect(page).to have_selector '.in', text: 'This event type is an example.'
expect(page).to have_text 'Abstracts must be between 0 and 123 words.'
select 'Five to Ten Words', from: 'Type'
expect(page).to have_selector '.in', text: 'This has a nonzero minimum.'
expect(page).to have_text 'Abstracts must be between 5 and 10 words.'

expect(page).to have_text('You have used 3 words')
fill_in 'event_abstract', with: 'This abstract has five words.'
expect(page).to have_text('You have used 5 words')

click_button 'Update Proposal'
page.find('#flash')
expect(page).to have_content 'Proposal was successfully updated.'
Expand Down