diff --git a/app/assets/javascripts/sitewide/form_validators.js.erb b/app/assets/javascripts/sitewide/form_validators.js.erb index e6c8da54e..8f6098fe6 100644 --- a/app/assets/javascripts/sitewide/form_validators.js.erb +++ b/app/assets/javascripts/sitewide/form_validators.js.erb @@ -27,6 +27,9 @@ function textValidator(ev, textInput, textLimitMin, textLimitMax, clearErr) { var text = $(textInput).val().trim(); $(textInput).val(text); + var text_from_html = $("
").html(text).text(); + if (text_from_html.length < text.length) text = text_from_html; + var nameTooShort = text.length < textLimitMin; var nameTooLong = text.length > textLimitMax; diff --git a/app/assets/stylesheets/themes/scinote.scss b/app/assets/stylesheets/themes/scinote.scss index 3f3208551..cdd626d29 100644 --- a/app/assets/stylesheets/themes/scinote.scss +++ b/app/assets/stylesheets/themes/scinote.scss @@ -428,6 +428,13 @@ a[data-toggle="tooltip"] { } } +.has-error { + .ql-container.ql-snow, + .ql-toolbar.ql-snow { + border: 1px solid $color-apple-blossom; + } +} + .nav-tabs-less { margin-bottom: 0; } diff --git a/app/models/result_text.rb b/app/models/result_text.rb index 39975f893..f1cabaadb 100644 --- a/app/models/result_text.rb +++ b/app/models/result_text.rb @@ -2,7 +2,7 @@ class ResultText < ActiveRecord::Base auto_strip_attributes :text, nullify: false validates :text, presence: true, - length: { maximum: Constants::TEXT_MAX_LENGTH } + length: { maximum: Constants::RICH_TEXT_MAX_LENGTH } validates :result, presence: true belongs_to :result, inverse_of: :result_text diff --git a/app/models/step.rb b/app/models/step.rb index e572dff2a..3d329096d 100644 --- a/app/models/step.rb +++ b/app/models/step.rb @@ -5,7 +5,7 @@ class Step < ActiveRecord::Base validates :name, presence: true, length: { maximum: Constants::NAME_MAX_LENGTH } - validates :description, length: { maximum: Constants::TEXT_MAX_LENGTH } + validates :description, length: { maximum: Constants::RICH_TEXT_MAX_LENGTH } validates :position, presence: true validates :completed, inclusion: { in: [true, false] } validates :user, :protocol, presence: true diff --git a/app/views/steps/_empty_step.html.erb b/app/views/steps/_empty_step.html.erb index 19581bb45..f23f48a9b 100644 --- a/app/views/steps/_empty_step.html.erb +++ b/app/views/steps/_empty_step.html.erb @@ -26,7 +26,9 @@
<%= f.text_field :name, label: t("protocols.steps.new.name"), placeholder: t("protocols.steps.new.name_placeholder") %> - <%= quill_editor nil, { name: 'step[description]', value: @step.description } %> +
+ <%= quill_editor nil, { id: 'step_description', name: 'step[description]', value: @step.description } %> +
<%= f.nested_fields_for :checklists do |ff| %> diff --git a/config/initializers/constants.rb b/config/initializers/constants.rb index becd940ec..0ed5223ef 100644 --- a/config/initializers/constants.rb +++ b/config/initializers/constants.rb @@ -11,6 +11,8 @@ class Constants NAME_TRUNCATION_LENGTH = 25 # Max characters for long text fields TEXT_MAX_LENGTH = 10000 + # Max characters for rich text fields (in html format) + RICH_TEXT_MAX_LENGTH = 50000 # Max characters for color field (given in HEX format) COLOR_MAX_LENGTH = 7 # Max characters for text in dropdown list element