mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-10-02 09:54:37 +08:00
Merge pull request #279 from mlorb/ml_sci_638_vol2
Fix validation problems for rich text fields [SCI-638]
This commit is contained in:
commit
b0b2484fdf
6 changed files with 17 additions and 3 deletions
|
@ -27,6 +27,9 @@ function textValidator(ev, textInput, textLimitMin, textLimitMax, clearErr) {
|
|||
|
||||
var text = $(textInput).val().trim();
|
||||
$(textInput).val(text);
|
||||
var text_from_html = $("<div/>").html(text).text();
|
||||
if (text_from_html.length < text.length) text = text_from_html;
|
||||
|
||||
var nameTooShort = text.length < textLimitMin;
|
||||
var nameTooLong = text.length > textLimitMax;
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -26,7 +26,9 @@
|
|||
<div class="tab-content">
|
||||
<div class="tab-pane active" role="tabpanel" id="new-step-main">
|
||||
<%= 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 } %>
|
||||
<div class="form-group">
|
||||
<%= quill_editor nil, { id: 'step_description', name: 'step[description]', value: @step.description } %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-pane" role="tabpanel" id="new-step-checklists">
|
||||
<%= f.nested_fields_for :checklists do |ff| %>
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue