Skip to content

Commit c9c53f5

Browse files
fix: Questionnaire agreement read and accept error placement (#525)
Co-authored-by: Chris Baudouin, Jr <[email protected]>
1 parent 894135d commit c9c53f5

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

app/assets/javascripts/validate.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ document.addEventListener('turbolinks:load', function() {
1818
switch (types[i]) {
1919
case 'presence':
2020
if (!value || $.trim(value).length < 1) {
21-
if ($(this).parents('.agreement_input')) {
22-
notify('.agreement_input', 'Please read & accept');
21+
if ($(this).hasClass("agreement_input")) {
22+
notify($(this).parent(), 'Please read & accept');
2323
} else {
2424
notify(this, 'Missing Information');
2525
}
@@ -74,7 +74,9 @@ document.addEventListener('turbolinks:load', function() {
7474
.fadeOut(200, function() {
7575
$(this).remove();
7676
});
77-
$(".agreement_input")
77+
// this removes the notification for agreements
78+
$(this)
79+
.parent()
7880
.parent()
7981
.removeClass('field_with_errors')
8082
.find('.error')

app/assets/stylesheets/forms/_forms.sass

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ hr
7373
@include css4
7474
color: var(--grey)
7575
.error
76+
display: inline-block
77+
width: 100%
7678
@include css4
7779
background: var(--input--error--background)
7880
color: var(--input--error--text)

app/views/questionnaires/_form.html.haml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@
5252
%strong Agreements
5353
%p Please review the agreements and click the corresponding checkbox next to each agreement to agree.
5454
.form-inputs
55-
.agreement_input
56-
= f.association :agreements, as: :check_boxes, label_method: :formatted_agreement, value_method: :id, label: "", wrapper_html: { style: 'display: block' }, input_html: { "data-validate" => "presence" }
55+
= f.association :agreements, as: :check_boxes, label_method: :formatted_agreement, value_method: :id, label: "", wrapper_html: { style: 'display: block' }, input_html: { "data-validate" => "presence", class: "agreement_input"}
5756

5857
.right
5958
%button.button{ type: "button", "data-wizard" => "previous" } Previous

0 commit comments

Comments
 (0)