mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Server-side render initial visibility of select help text
Resolves failure to display initial help text of difficulty level.
This commit is contained in:
parent
e5ab9b4db1
commit
6ed1725b01
3 changed files with 18 additions and 9 deletions
|
|
@ -145,7 +145,7 @@ 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 */
|
||||
$("#event_event_type_id").change(function () {
|
||||
function updateEventTypeRequirements() {
|
||||
var $selected = $("#event_event_type_id option:selected")
|
||||
var max = $selected.data("max-words");
|
||||
var min = $selected.data("min-words");
|
||||
|
|
@ -153,8 +153,9 @@ $( document ).ready(function() {
|
|||
$("#abstract-maximum-word-count").text(max);
|
||||
$("#abstract-minimum-word-count").text(min);
|
||||
word_count($('#event_abstract').get(0), 'abstract-count', max);
|
||||
})
|
||||
.trigger('change');
|
||||
}
|
||||
$("#event_event_type_id").change(updateEventTypeRequirements);
|
||||
updateEventTypeRequirements();
|
||||
|
||||
/* Count the proposal abstract length */
|
||||
$("#event_abstract").on('input', function() {
|
||||
|
|
|
|||
|
|
@ -27,16 +27,14 @@
|
|||
.form-group
|
||||
= f.label :language
|
||||
= f.select :language, @languages, { include_blank: false}, { class: 'select-help-toggle form-control' }
|
||||
- @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
|
||||
= render 'shared/select_help_text', f: f, for: :event_type_id, options: @conference.program.event_types do |event_type|
|
||||
= event_type.description
|
||||
- if action_is_edit
|
||||
- if @conference.program.difficulty_levels.any?
|
||||
= f.label :difficulty_level
|
||||
= f.select :difficulty_level_id, @conference.program.difficulty_levels.map{|level| [level.title, level.id ] }, {include_blank: false}, { class: 'select-help-toggle form-control' }
|
||||
- @conference.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
|
||||
= render 'shared/select_help_text', f: f, for: :difficulty_level_id, options: @conference.program.difficulty_levels do |difficulty_level|
|
||||
= difficulty_level.description
|
||||
.form-group
|
||||
= f.label :abstract
|
||||
= f.text_area :abstract, required: true, rows: 5, data: { provide: 'markdown' }, class: 'form-control'
|
||||
|
|
|
|||
10
app/views/shared/_select_help_text.html.haml
Normal file
10
app/views/shared/_select_help_text.html.haml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
:ruby
|
||||
include_blank ||= false
|
||||
select_id = field_id(f.object_name, local_assigns[:for])
|
||||
value = f.object.send(local_assigns[:for])
|
||||
|
||||
- options.each_with_index do |option, i|
|
||||
- selected = value.present? ? option.id == value : !include_blank && i == 0
|
||||
|
||||
%span.help-block.select-help-text.collapse{ id: "#{option.id}-help", class: [select_id, ('in' if selected)] }
|
||||
= yield option
|
||||
Loading…
Add table
Add a link
Reference in a new issue