Update help text and add dynamic example text
- Display help text and example text according to
remote census configuration:
Examples with expecte results:
* With remote census without :date_of_birth and :postal_code:
-> "To verify a user, your application needs: Document number"
-> "Required fields for each user must be separated by commas and
each user must be separated by semicolons."
-> "Example: 12345678Z; 87654321Y"
* With remote census with :date_of_birth required:
-> "To verify a user, your application needs: Document number,
Day of birth (dd/mm/yyyy)"
-> "Required fields for each user must be separated by commas and
each user must be separated by semicolons."
-> "Example: 12345678Z, 01/01/1980; 87654321Y, 01/02/1990"
* With remote census with :date_of_birth and :postal_code required:
-> "To verify a user, your application needs: Document number,
Day of birth (dd/mm/yyyy) and Postal Code"
-> "Required fields for each user must be separated by commas and
each user must be separated by semicolons."
-> "Example: 12345678Z, 01/01/1980, 28001; 87654321Y, 01/02/1990, 28002"
This commit is contained in:
@@ -5,4 +5,48 @@ module SignatureSheetsHelper
|
||||
[t("activerecord.models.budget/investment", count: 1), Budget::Investment]]
|
||||
end
|
||||
|
||||
end
|
||||
def required_fields_to_verify_text_help
|
||||
if Setting["feature.remote_census"].present?
|
||||
date_of_birth_and_postal_code_text_help
|
||||
else
|
||||
t("admin.signature_sheets.new.document_numbers_note")
|
||||
end
|
||||
end
|
||||
|
||||
def date_of_birth_and_postal_code_text_help
|
||||
text_help = t("admin.signature_sheets.new.text_help.required_fields_note")
|
||||
|
||||
if Setting.force_presence_date_of_birth?
|
||||
text_help += t("admin.signature_sheets.new.text_help.date_of_birth_note")
|
||||
end
|
||||
|
||||
if Setting.force_presence_postal_code?
|
||||
text_help += t("admin.signature_sheets.new.text_help.postal_code_note")
|
||||
end
|
||||
|
||||
text_help += "<br/>"
|
||||
text_help += t("admin.signature_sheets.new.text_help.required_fields_structure_note")
|
||||
|
||||
return text_help.html_safe
|
||||
end
|
||||
|
||||
def example_text_help
|
||||
text_example = t("admin.signature_sheets.new.text_help.example_text")
|
||||
example_1 = "12345678Z"
|
||||
example_2 = "87654321Y"
|
||||
|
||||
if Setting.force_presence_date_of_birth?
|
||||
example_1 += ", 01/01/1980"
|
||||
example_2 += ", 01/02/1990"
|
||||
end
|
||||
|
||||
if Setting.force_presence_postal_code?
|
||||
example_1 += ", 28001"
|
||||
example_2 += ", 28002"
|
||||
end
|
||||
|
||||
text_example += "#{example_1}; #{example_2}"
|
||||
return text_example
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
</div>
|
||||
|
||||
<%= f.label :required_fields_to_verify %>
|
||||
<p class="help-text" id="required-fields-to-verify-help-text"><%= t("admin.signature_sheets.new.document_numbers_note") %></p>
|
||||
<p class="help-text" id="required-fields-to-verify-help-text"><%= required_fields_to_verify_text_help %></p>
|
||||
<p class="help-text"> <%= example_text_help %></p>
|
||||
<%= f.text_area :required_fields_to_verify, rows: "6", label: false, aria: {describedby: "required-fields-to-verify-help-text"} %>
|
||||
|
||||
<%= f.submit(class: "button", value: t("admin.signature_sheets.new.submit")) %>
|
||||
|
||||
Reference in New Issue
Block a user