Refactor the new/edit submission forms

This commit is contained in:
Michael Ball 2021-03-23 22:43:11 -07:00
parent c55eff4eec
commit ed20ff3b51
5 changed files with 101 additions and 115 deletions

View file

@ -199,7 +199,7 @@ $( document ).ready(function() {
let affirm = confirm($this.data('confirm'));
if (affirm) {
let sub_text = $('#event_submission_text');
sub_text.val($selected.data('help'));
sub_text.val($selected.data('instructions'));
sub_text.trigger('change');
}
});

View file

@ -60,6 +60,19 @@ module EventsHelper
"#{event.average_rating}/#{max_rating}, #{pluralize(event.voters.length, 'vote')}"
end
def event_type_options(event_types)
event_types.map do |type|
[
"#{type.title} - #{show_time(type.length)}",
type.id,
data: {
min_words: type.minimum_abstract_length,
max_words: type.maximum_abstract_length,
help: type.submission_instructions
}
]
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|

View file

@ -11,85 +11,43 @@
= track_selector_input f
= f.input :event_type_id, as: :select,
collection: @conference.program.event_types.map {|type| ["#{type.title} - #{show_time(type.length)}", type.id,
data: { min_words: type.minimum_abstract_length, max_words: type.maximum_abstract_length, help: type.description }]},
include_blank: false, label: 'Type', input_html: { class: 'select-help-toggle' }
- if @program.languages.present?
= f.input :language, as: :select,
collection: @languages,
include_blank: false, label: 'Language', input_html: { class: 'select-help-toggle' }
- @conference.program.event_types.each do |event_type|
%span{ class: 'help-block select-help-text event_event_type_id collapse', id: "#{event_type.id}-help" }
= event_type.description
= f.input :difficulty_level, as: :select, collection: @conference.program.difficulty_levels, input_html: { class: 'select-help-toggle' },
- if @program.difficulty_levels.present?
= f.input :difficulty_level, as: :select, collection: @program.difficulty_levels,
input_html: { class: 'select-help-toggle' },
include_blank: '(Please select)' if @conference.program.difficulty_levels.any?
- @conference.program.difficulty_levels.each do |difficulty_level|
- @program.difficulty_levels.each do |difficulty_level|
%span{ class: 'help-block select-help-text collapse event_difficulty_level_id', id: "#{difficulty_level.id}-help" }
= difficulty_level.description
= f.input :abstract, required: true, input_html: { rows: 5, data: { provide: 'markdown' } },
hint: markdown_hint('[Tips to improve your presentations.](http://blog.hubspot.com/blog/tabid/6307/bid/5975/10-Rules-to-Instantly-Improve-Your-Presentations.aspx)')
= render 'submission_type_content_form', f: f, program: @program
%p
You have used
%span#abstract-count #{@event.abstract_word_count}
words. Abstracts must be between
%span#abstract-minimum-word-count
0
and
%span#abstract-maximum-word-count
250
words.
%br
- @conference.program.event_types.each do |event_type|
%span{ class: 'help-block select-help-text event_event_type_id collapse', id: "#{event_type.id}-help" }
%h3
= event_type.name
Instructions
= markdown(event_type.submission_instructions)
= f.input :submission_text, input_html: { rows: 5, data: { provide: 'markdown' }, placeholder: '' },
hint: markdown_hint('Only conference organizers will read this.')
%button.btn.btn-primary.primary-button{ type: 'button', id: 'sub_text_reset', data: { confirm: 'Do you really want to reset your submission text to the provided template?' } } Reset to Template
%p
You have used
%span#submission-count #{@event.submission_word_count}
words. Submission descriptions must be between
%span#submission-minimum-word-count
0
and
%span#submission-maximum-word-count
250
words.
- if current_user.is_admin? or @program.cfp&.enable_registrations?
- if @program.cfp&.enable_registrations?
= f.inputs 'Enable pre-registration' do
= f.input :require_registration, label: 'Require participants to register to your event'
- message = @event.room ? "Value must be between 1 and #{@event.room.size}" : 'Check room capacity after scheduling.'
= f.input :max_attendees, hint: 'The maximum number of participants. ' + message
- if current_user.has_any_role? :admin, { name: :organizer, resource: @conference }, { name: :cfp, resource: @conference }
= f.input :is_highlight
%p.text-right
= link_to '#description', 'data-toggle' => 'collapse' do
Do you require something special?
#description{ class: "collapse #{ 'in' if @event.description.present? }" }
= f.input :description, input_html: { rows: 5 }, label: 'Requirements', placeholder: 'Eg. Whiteboard, printer, or something like that.'
- if current_user.has_any_role? :admin, { name: :organizer, resource: @conference }, { name: :cfp, resource: @conference }
%p (Admin Only)
= f.input :is_highlight
%p.text-right
- if @event.new_record?
= f.submit 'Submit Proposal', class: 'btn btn-success'
- else
= f.submit 'Update Proposal', class: 'btn btn-success'
= f.submit 'Update Proposal', class: 'btn btn-primary'
:javascript
$(document).ready(function() {

View file

@ -0,0 +1,66 @@
-# PARTIAL FOR EVENT/PROPOSAL FORM
-# `f` a current from helper.
= f.input :event_type_id, as: :select, include_blank: false, label: 'Type',
input_html: { class: 'select-help-toggle' },
collection: event_type_options(program.event_types)
- program.event_types.each do |event_type|
.help-block.event_event_type_id.collapse{ id: "#{event_type.id}-help" }
%strong Description
%div
= markdown(event_type.description)
%h3 Submission Abstract
%p
The abstract is reviewed by the committee and included in the conference program.
You are encouraged to include links or other references as appropriate.
= f.label :abstract, class: 'sr-only'
= f.input :abstract, required: true, label: false,
input_html: { rows: 5, data: { provide: 'markdown' } },
hint: markdown_hint
%p
You have used
%span#abstract-count #{@event.abstract_word_count}
words. Abstracts must be between
%span#abstract-minimum-word-count 0
and
%span#abstract-maximum-word-count 250
words.
%hr
%h3 Submission Details
%p
This part of the submission is intended only for the conference committee.
- program.event_types.each do |event_type|
.help-block.select-help-text.event_event_type_id.collapse{ id: "#{event_type.id}-instructions" }
- if event_type.submission_instructions.blank?
%p
Use this space to include any additional inforrmation that is helpful in reviewing your
submission. If you have any co-presenters, please include them
below. After submission, you will have the opportunity to add them to the
speakers list. (However, they must have an active #{ENV['OSEM_NAME']} account.)
- else
%p
Please use the following as the template for your submission. This will help the conference committee review your submission with all the details they need. If you have any co-presenters, please include them below. After
submission, you will have the opportunity to add them to the speakers
list. (However, they must have an active #{ENV['OSEM_NAME']} account.)
.panel.panel-primary
.panel-heading
= event_type.name
Template
.panel-body
= markdown(event_type.submission_instructions)
.panel-footer
%button.btn.btn-warning.btn-xs{ type: 'button', id: 'sub_text_reset', data: { confirm: 'Do you really want to reset your submission text to the provided template?' } }
Reset Submission to Template
%span.small You may want to use this if you have changed the submission type.
= f.label :submission_text, class: 'sr-only'
= f.input :submission_text, label: false,
input_html: { rows: 10, data: { provide: 'markdown' } },
hint: markdown_hint

View file

@ -38,67 +38,16 @@
collection: @languages,
include_blank: false, label: 'Language', input_html: { class: 'select-help-toggle' }
= f.input :event_type_id, as: :select,
collection: @program.event_types.map {|type| ["#{type.title} - #{show_time(type.length)}", type.id,
data: { min_words: type.minimum_abstract_length, max_words: type.maximum_abstract_length, instructions: type.submission_instructions }]},
include_blank: false, label: 'Type', input_html: { class: 'select-help-toggle' }
- if @program.difficulty_levels.present?
= f.input :difficulty_level, as: :select, collection: @program.difficulty_levels,
input_html: { class: 'select-help-toggle' },
include_blank: '(Please select)' if @conference.program.difficulty_levels.any?
- @program.event_types.each do |event_type|
.help-block.event_event_type_id.collapse{ id: "#{event_type.id}-help" }
%strong Description
%div
= markdown(event_type.description)
- @program.difficulty_levels.each do |difficulty_level|
%span.help-block.select-help-text.collapse.event_difficulty_level_id{ id: "#{difficulty_level.id}-help" }
= difficulty_level.description
%h3 Submission Abstract
%p
The abstract is reviewed by the committee and included in the conference program.
You are encouraged to include links or other references as appropriate.
= f.label :abstract, class: 'sr-only'
= f.input :abstract, required: true, label: false,
input_html: { rows: 5, data: { provide: 'markdown' } },
hint: markdown_hint
%p
You have used
%span#abstract-count #{@event.abstract_word_count}
words. Abstracts must be between
%span#abstract-minimum-word-count 0
and
%span#abstract-maximum-word-count 250
words.
%hr
%h3
Submission Details
%p
This part of the submission is intended only for the conference committee.
- @conference.program.event_types.each do |event_type|
.help-block.select-help-text.event_event_type_id.collapse{ id: "#{event_type.id}-instructions" }
- if event_type.submission_instructions.blank?
Use this space to include any additional inforrmation that is helpful in reviewing your submission. If you have any co-presenters, please include them
below. After submission, you will have the opportunity to add them to the
speakers list. (However, they must have an active #{ENV['OSEM_NAME']} account.)
- else
%p
Please use the following as the template for your submission. This will help the conference committee review your submission with all the details they need. If you have any co-presenters, please include them below. After
submission, you will have the opportunity to add them to the speakers
list. (However, they must have an active #{ENV['OSEM_NAME']} account.)
.panel.panel-primary
.panel-heading
= event_type.name
Template
.panel-body
= markdown(event_type.submission_instructions)
.panel-footer
%button.btn.btn-warning.btn-xs{ type: 'button', id: 'sub_text_reset', data: { confirm: 'Do you really want to reset your submission text to the provided template?' } } Reset Submission to Template
%span.small
You may want to use this if you have changed the submission type.
= f.label :submission_text, class: 'sr-only'
= f.input :submission_text, label: false,
input_html: { rows: 10, data: { provide: 'markdown' } },
hint: markdown_hint
= render 'submission_type_content_form', f: f, program: @program
- if @program.cfp.enable_registrations?
= f.input :require_registration, label: 'Require participants to register to your event'