Skip to content

Commit

Permalink
Merge pull request #715 from bitzesty/letters-of-support
Browse files Browse the repository at this point in the history
Fix missing value validation on Letters of Support subquestions
  • Loading branch information
DaniBitZesty authored Aug 28, 2024
2 parents fab91b2 + 90270c9 commit ea2df1c
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ window.SupportLetters =

textContainer = parent.find('.support-letter-attachment-container')
textContainer.removeClass('govuk-!-display-none')
textContainer.find('.flex').prepend('<p class="govuk-body">' + filename + '</p>')
textContainer.find('.flex').html('<p class="govuk-body">' + filename + '</p>')
hiddenInput = $("<input class='js-support-letter-attachment-id' type='hidden' name='#{$el.attr("name")}' value='#{data.result['id']}' />")
parent.append(hiddenInput)
SupportLetters.autosave()
Expand Down
3 changes: 1 addition & 2 deletions app/assets/javascripts/frontend/form-validation.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ window.FormValidation =
clearErrors: (container) ->
if container.closest(".question-financial").length > 0
container.closest("label").find(".govuk-error-message").empty()
else if container.closest('.question-block').data('answer').indexOf('address') > -1
else if container.closest('.question-block').data('answer') && container.closest('.question-block').data('answer').indexOf('address') > -1
container.closest(".govuk-form-group").find(".govuk-error-message").empty()
else
container.closest(".question-block").find(".govuk-error-message").empty()
Expand Down Expand Up @@ -489,7 +489,6 @@ window.FormValidation =
stepContainer.find(".govuk-form-group--error").removeClass("govuk-form-group--error")
stepContainer.find(".govuk-error-message").empty()
$(".steps-progress-bar .js-step-link[data-step='" + currentStep + "']").removeClass("step-errors")

for question in stepContainer.find(".question-block")
question = $(question)
@validateIndividualQuestion(question)
2 changes: 1 addition & 1 deletion app/controllers/form/support_letters_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def add_support_letters_to_document!
h[:first_name] = support_letter.first_name
h[:last_name] = support_letter.last_name
h[:relationship_to_nominee] = support_letter.relationship_to_nominee
h[:letter_of_support] = support_letter.support_letter_attachment.id
h[:letter_of_support] = support_letter.support_letter_attachment&.id
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/views/form/support_letters/_form.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
' If you upload the wrong file, click the 'Remove' link next to the file name to delete it. The file upload button will reappear, allowing you to select the correct file.

= ff.simple_fields_for :support_letter_attachment, (ff.object.support_letter_attachment || ff.object.build_support_letter_attachment) do |fff|
- if fff.object.attachment.present?
- if ff.object.support_letter_attachment.present?
p.govuk-body.support-letter-attachment-container class="govuk-!-font-size-19"
= render "shared/attachment_with_virus_check_status", item: fff.object, mount_name: :attachment
- if ff.object.support_letter_attachment.id.present?
Expand Down
8 changes: 4 additions & 4 deletions app/views/qae_form/_supporter_fields.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@ li.borderless[class=class_names("js-add-example", "js-support-letter-received" =
= render "qae_form/question_ref", question: question, ref: "C #{idx}.1"
span class="govuk-body govuk-!-font-size-24 govuk-!-font-weight-bold govuk-!-display-block"
' Name of the person who wrote the #{first_or_second} letter of support
.govuk-form-group
.govuk-form-group.question-block.question-required
label.govuk-label for="form[#{question.key}][#{index}][first_name]"
' First Name:
span.govuk-error-message
input.js-support-letter-field.js-support-letter-first-name.js-trigger-autosave.govuk-input autocomplete="off" class="js-trigger-autosave medium" name="form[#{question.key}][#{index}][first_name]" id="form[#{question.key}][#{index}][first_name]" type="text" value=supporter["first_name"] *possible_read_only_ops(question.step.opts[:id])
.govuk-form-group
.govuk-form-group.question-block.question-required
label.govuk-label for="form[#{question.key}][#{index}][last_name]"
' Surname:
span.govuk-error-message
input.js-support-letter-field.js-support-letter-last-name.js-trigger-autosave.govuk-input autocomplete="off" class="js-trigger-autosave medium" name="form[#{question.key}][#{index}][last_name]" id="form[#{question.key}][#{index}][last_name]" type="text" value=supporter["last_name"] *possible_read_only_ops(question.step.opts[:id])

legend.govuk-label aria-label="C #{idx}.2: Relationship to Group"
= render "qae_form/question_ref", question: question, ref: "C #{idx}.2"
.govuk-form-group
.govuk-form-group.question-block.question-required
label class="govuk-body govuk-!-font-size-24 govuk-!-font-weight-bold govuk-!-display-block" for="form[#{question.key}][#{index}][relationship_to_nominee]"
' Relationship to group
span.question-context.question-debug.govuk-hint
Expand All @@ -41,7 +41,7 @@ li.borderless[class=class_names("js-add-example", "js-support-letter-received" =

legend.govuk-label aria-label="C #{idx}.3: Relationship to Group"
= render "qae_form/question_ref", question: question, ref: "C #{idx}.3"
.govuk-form-group
.govuk-form-group.question-block.question-required
label class="govuk-body govuk-!-font-size-24 govuk-!-font-weight-bold govuk-!-display-block" for="form[#{question.key}][#{index}][letter_of_support]"
' Upload the #{first_or_second} letter of support
span.question-context.question-debug.govuk-hint
Expand Down

0 comments on commit ea2df1c

Please sign in to comment.