diff --git a/app/assets/javascripts/frontend/custom_questions/support_letters.js.coffee b/app/assets/javascripts/frontend/custom_questions/support_letters.js.coffee index 2dbca938b..efc8f0a45 100644 --- a/app/assets/javascripts/frontend/custom_questions/support_letters.js.coffee +++ b/app/assets/javascripts/frontend/custom_questions/support_letters.js.coffee @@ -32,7 +32,7 @@ window.SupportLetters = textContainer = parent.find('.support-letter-attachment-container') textContainer.removeClass('govuk-!-display-none') - textContainer.find('.flex').prepend('
' + filename + '
') + textContainer.find('.flex').html('' + filename + '
') hiddenInput = $("") parent.append(hiddenInput) SupportLetters.autosave() diff --git a/app/assets/javascripts/frontend/form-validation.js.coffee b/app/assets/javascripts/frontend/form-validation.js.coffee index fd40f0a05..63fa8d8e0 100644 --- a/app/assets/javascripts/frontend/form-validation.js.coffee +++ b/app/assets/javascripts/frontend/form-validation.js.coffee @@ -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() @@ -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) diff --git a/app/controllers/form/support_letters_controller.rb b/app/controllers/form/support_letters_controller.rb index fa581277a..0e422180a 100644 --- a/app/controllers/form/support_letters_controller.rb +++ b/app/controllers/form/support_letters_controller.rb @@ -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 diff --git a/app/views/form/support_letters/_form.html.slim b/app/views/form/support_letters/_form.html.slim index f04e1db4f..34605d172 100644 --- a/app/views/form/support_letters/_form.html.slim +++ b/app/views/form/support_letters/_form.html.slim @@ -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? diff --git a/app/views/qae_form/_supporter_fields.html.slim b/app/views/qae_form/_supporter_fields.html.slim index b0580301c..fd6fc0756 100644 --- a/app/views/qae_form/_supporter_fields.html.slim +++ b/app/views/qae_form/_supporter_fields.html.slim @@ -18,12 +18,12 @@ 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 @@ -31,7 +31,7 @@ li.borderless[class=class_names("js-add-example", "js-support-letter-received" = 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 @@ -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