Merge pull request #28 from CactusPuppy/177216921/sub-text-fill
Make submission text be auto-filled into text instead of placeholder
This commit is contained in:
commit
6cadf13a2a
4 changed files with 46 additions and 4 deletions
|
|
@ -147,6 +147,15 @@ function word_count(text, divId, maxcount) {
|
|||
});
|
||||
};
|
||||
|
||||
function fill_if_empty(text_area, filler) {
|
||||
let area = $('#' + text_area);
|
||||
|
||||
if (!area.val()) {
|
||||
area.val(filler);
|
||||
area.trigger('change');
|
||||
}
|
||||
}
|
||||
|
||||
/* Wait for the DOM to be ready before attaching events to the elements */
|
||||
$( document ).ready(function() {
|
||||
/* Set the minimum and maximum proposal abstract and submission text word length */
|
||||
|
|
@ -155,15 +164,15 @@ $( document ).ready(function() {
|
|||
var max = $selected.data("max-words");
|
||||
var min = $selected.data("min-words");
|
||||
|
||||
// Set the filler text for the submission text
|
||||
fill_if_empty('event_submission_text', $selected.data("help"));
|
||||
|
||||
$("#abstract-maximum-word-count").text(max);
|
||||
$("#submission-maximum-word-count").text(max);
|
||||
$("#abstract-minimum-word-count").text(min);
|
||||
$("#submission-minimum-word-count").text(min);
|
||||
word_count($('#event_abstract').get(0), 'abstract-count', max);
|
||||
word_count($('#event_submission_text').get(0), 'submission-count', max);
|
||||
|
||||
// Set the placeholder text for the abstract
|
||||
$('#event_submission_text').attr("placeholder", $selected.data("help"));
|
||||
})
|
||||
.trigger('change');
|
||||
|
||||
|
|
@ -180,6 +189,18 @@ $( document ).ready(function() {
|
|||
var max = $selected.data("max-words");
|
||||
word_count(this, 'submission-count', max);
|
||||
});
|
||||
|
||||
/* Listen for reset template button, wait for confirm, and reset. */
|
||||
$('#sub_text_reset').click((e) => {
|
||||
let $selected = $("#event_event_type_id option:selected");
|
||||
let $this = $(e.target);
|
||||
let affirm = confirm($this.data('confirm'));
|
||||
if (affirm) {
|
||||
let sub_text = $('#event_submission_text');
|
||||
sub_text.val($selected.data('help'));
|
||||
sub_text.trigger('change');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
/* Commodity function for modal windows */
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@
|
|||
|
||||
= 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
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@
|
|||
= f.input :title, as: :string, required: true, input_html: { required: true }
|
||||
= 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 }]},
|
||||
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' }
|
||||
|
||||
- @program.event_types.each do |event_type|
|
||||
|
|
@ -63,6 +63,7 @@
|
|||
|
||||
= f.input :submission_text, input_html: { rows: 5, data: { provide: 'markdown' } },
|
||||
hint: markdown_hint
|
||||
%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
|
||||
|
|
|
|||
|
|
@ -177,5 +177,24 @@ feature Event do
|
|||
@event.reload
|
||||
expect(@event.state).to eq('withdrawn')
|
||||
end
|
||||
|
||||
scenario 'can reset to text template', feature: true, js: true do
|
||||
event_type = conference.program.event_types[-1]
|
||||
event_type.description = 'Example event description'
|
||||
event_type.save!
|
||||
|
||||
sign_in participant
|
||||
visit new_conference_program_proposal_path(conference.short_title)
|
||||
|
||||
fill_in 'event_title', with: 'Example Proposal'
|
||||
select(event_type.title, from: 'event[event_type_id]')
|
||||
fill_in 'event_submission_text', with: 'Lorem ipsum example submission text'
|
||||
|
||||
accept_confirm do
|
||||
click_button 'Reset to Template'
|
||||
end
|
||||
|
||||
expect(page.find('#event_submission_text').value).to eq(event_type.description)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue