-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #713 from bitzesty/letters-of-support
New letters of support question styling
- Loading branch information
Showing
15 changed files
with
205 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
app/controllers/form/support_letter_attachments_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
class Form::SupportLetterAttachmentsController < Form::BaseController | ||
include FormAnswerSubmissionMixin | ||
before_action :set_support_letter | ||
|
||
def show; end | ||
|
||
def destroy | ||
attachment = SupportLetterAttachment.find(params[:id]) | ||
form_answer = attachment.form_answer | ||
|
||
if attachment.destroy | ||
updated_list = form_answer.document['supporter_letters_list'].reject { |letter| letter['letter_of_support'] == attachment.id } | ||
form_answer.update(document: form_answer.document.merge(supporter_letters_list: updated_list)) | ||
|
||
flash[:notice] = 'Attachment successfully deleted.' | ||
else | ||
flash[:alert] = 'Failed to delete attachment.' | ||
end | ||
|
||
redirect_to form_form_answer_supporters_path(form_answer) | ||
end | ||
|
||
private | ||
|
||
def set_support_letter | ||
@support_letter = SupportLetter.find(params[:support_letter_id]) | ||
@form_answer = @support_letter.form_answer | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
- content_for :page_title, "Support Letter Attachment" | ||
|
||
.govuk-grid-row | ||
.govuk-grid-column-two-thirds | ||
h1.govuk-heading-xl Support Letter Attachment | ||
|
||
- if @support_letter.support_letter_attachment.present? | ||
.govuk-summary-list | ||
.govuk-summary-list__row | ||
dt.govuk-summary-list__key | ||
| File Name | ||
dd.govuk-summary-list__value | ||
= @support_letter.support_letter_attachment.original_filename | ||
|
||
= button_to "Delete Attachment", | ||
form_form_answer_support_letter_support_letter_attachment_path(@form_answer, @support_letter, @support_letter.support_letter_attachment), | ||
method: :delete, | ||
class: "govuk-button govuk-button--warning" | ||
- else | ||
p.govuk-body No attachment found for this support letter. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,50 @@ | ||
= f.simple_fields_for :support_letters do |ff| | ||
- idx = ff.options[:child_index] + 1 | ||
li | ||
.govuk-grid-row | ||
.govuk-grid-column-one-half | ||
label[class="govuk-label"] | ||
span[class="govuk-body govuk-!-font-size-20 govuk-!-font-weight-bold govuk-!-display-block"] | ||
= "Letter of Support #{idx}" | ||
= ff.input :first_name, label: "First Name:", input_html: { class: "form-control" } | ||
= ff.input :last_name, label: "Surname:", input_html: { class: "form-control" } | ||
= ff.input :relationship_to_nominee, label: "Relationship to Group:", input_html: { class: "form-control" } | ||
|
||
= ff.input :manual, as: :hidden, input_html: { value: true } | ||
= ff.input :user_id, as: :hidden, input_html: { value: current_user.id } | ||
|
||
= ff.simple_fields_for :support_letter_attachment, (ff.object.support_letter_attachment || ff.object.build_support_letter_attachment) do |fff| | ||
= fff.input :attachment, as: :file, label: "Upload Letter of Support #{idx}", input_html: { class: "form-control" }, wrapper_html: { style: "margin-bottom: -1rem;" } | ||
- if fff.object.attachment.present? | ||
p.govuk-body.support-letter-attachment-filename | ||
= render "shared/attachment_with_virus_check_status", item: fff.object, mount_name: :attachment | ||
- first_or_second = idx == 1 ? "first" : "second" | ||
li.borderless | ||
.question-block | ||
label[class="govuk-label"] | ||
legend.govuk-label | ||
= render "qae_form/question_ref", question: question, ref: "C #{idx}" | ||
span[class="govuk-body govuk-!-font-size-36 govuk-!-font-weight-bold govuk-!-display-block"] | ||
= "The #{first_or_second} letter of support" | ||
|
||
legend.govuk-label aria-label="C #{idx}.1: Name" | ||
= 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" | ||
= ff.input :first_name, label: "First Name:", input_html: { class: "form-control medium" } | ||
= ff.input :last_name, label: "Surname:", input_html: { class: "form-control medium" } | ||
|
||
legend.govuk-label aria-label="C #{idx}.2: Relationship to Group" | ||
= render "qae_form/question_ref", question: question, ref: "C #{idx}.2" | ||
label for="form_answer_support_letters_attributes_#{ff.options[:child_index]}_relationship_to_nominee" class="govuk-body govuk-!-font-size-24 govuk-!-font-weight-bold govuk-!-display-block" | ||
= "Relationship to group" | ||
span.question-context.question-debug.govuk-hint | ||
' For example, a beneficiary of the group, local resident or member of a partner charity. | ||
= ff.input :relationship_to_nominee, label: false, input_html: { class: "form-control medium" } | ||
|
||
= ff.input :manual, as: :hidden, input_html: { value: true } | ||
= ff.input :user_id, as: :hidden, input_html: { value: current_user.id } | ||
|
||
legend.govuk-label aria-label="C #{idx}.3: Upload Letter of Support" | ||
= render "qae_form/question_ref", question: question, ref: "C #{idx}.3" | ||
label for="form_answer_support_letters_attributes_#{ff.options[:child_index]}_support_letter_attachment" class="govuk-body govuk-!-font-size-24 govuk-!-font-weight-bold govuk-!-display-block" | ||
= "Upload the #{first_or_second} letter of support" | ||
span.question-context.question-debug.govuk-hint | ||
' 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? | ||
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? | ||
= link_to 'Remove', form_form_answer_support_letter_support_letter_attachment_path(@form_answer, ff.object, ff.object.support_letter_attachment), method: :delete, class: 'govuk-link non-js-remove-support-letter-attachment govuk-!-font-size-19' | ||
|
||
= fff.input :attachment_cache, as: :hidden | ||
|
||
= fff.input :form_answer_id, as: :hidden, input_html: { value: @form_answer.id } | ||
= fff.input :user_id, as: :hidden, input_html: { value: current_user.id } | ||
|
||
- unless fff.object.id.present? | ||
= fff.input :attachment, as: :file, label: false, input_html: { class: "form-control" }, wrapper_html: { style: "margin-bottom: -1rem;" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
span class="steps step-#{ref.to_s.parameterize} #{'if-js-hide' if question.sub_ref && !question.display_sub_ref_on_js_form}" | ||
span.todo | ||
= ref.to_s |
Oops, something went wrong.