Skip to content

Commit

Permalink
Merge pull request #650 from bitzesty/main
Browse files Browse the repository at this point in the history
Staging release
  • Loading branch information
dreamfall authored Feb 1, 2024
2 parents 8becfbf + 6f57517 commit 55d2363
Show file tree
Hide file tree
Showing 21 changed files with 1,090 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ window.SupportLetters =
enable_item_fields_and_controls: (parent) ->
parent.find(".js-save-collection").removeClass("govuk-!-display-none")
parent.find(".visible-read-only").hide()
parent.find(".remove-link").removeClass("govuk-!-display-none")
fields = parent.find("input")
fields.removeClass("read-only")
parent.find(".govuk-error-message").html("")
Expand Down Expand Up @@ -124,6 +123,7 @@ window.SupportLetters =
SupportLetters.disable_item_fields_and_controls(parent)
window.FormValidation.validateStep()
SupportLetters.autosave()
SupportLetters.showRemoveLink(parent, data, response)

return
error: (response) ->
Expand Down Expand Up @@ -154,3 +154,9 @@ window.SupportLetters =
type: 'POST'
dataType: 'json'
})

showRemoveLink: (parent, data, response) ->
removeLink = $(".remove-supporter", parent)
removeLink.data("url", "/users/form_answers/#{response['form_answer_id']}/support_letters/#{response['id']}")
removeLink.attr("aria-label", "Delete support letter from #{data['support_letter']['first_name']} #{data['support_letter']['last_name']}")
removeLink.removeClass("govuk-!-display-none")
4 changes: 2 additions & 2 deletions app/assets/javascripts/frontend/form-validation.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -355,8 +355,8 @@ window.FormValidation =
validateSupportLetters: (question) ->
lettersReceived = $(".js-support-letter-received").length
if lettersReceived < 2
@logThis(question, "validateSupportLetters", "Upload at least two letters of support")
@appendMessage(question, "Upload at least two letters of support")
@logThis(question, "validateSupportLetters", "Upload two letters of support")
@appendMessage(question, "Upload two letters of support")
@addErrorClass(question)

validateSelectionLimit: (question) ->
Expand Down
3 changes: 3 additions & 0 deletions app/controllers/form/support_letters_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ def new
end

def destroy
# safeguard for the case when not a user tries to delete a letter
return if current_assessor || current_leutenant

if @support_letter.destroy
remove_support_letter_from_document!
@form_answer.save
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/users/support_letters_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def create
attachment.support_letter = support_letter
attachment.save!

render json: support_letter.id,
render json: { id: support_letter.id, form_answer_id: form_answer.id },
status: :created
else
render json: support_letter.errors.messages.to_json,
Expand Down
2 changes: 1 addition & 1 deletion app/models/award_year.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class AwardYear < ApplicationRecord

after_create :create_settings

AVAILABLE_YEARS = [2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024]
AVAILABLE_YEARS = [2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025]

DEFAULT_FINANCIAL_DEADLINE_DAY = 17
DEFAULT_FINANCIAL_DEADLINE_MONTH = 9
Expand Down
3 changes: 2 additions & 1 deletion app/models/form_answer.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require_relative '../../forms/award_years/v2022/qae_forms'
require_relative '../../forms/award_years/v2023/qae_forms'
require_relative '../../forms/award_years/v2024/qae_forms'
require_relative '../../forms/award_years/v2025/qae_forms'

class FormAnswer < ApplicationRecord
include Statesman::Adapters::ActiveRecordQueries[
Expand Down Expand Up @@ -155,7 +156,7 @@ def award_form
elsif self.class.const_defined?(award_form_class_name(year))
self.class.const_get(award_form_class_name(year))
else
AwardYears::V2024::QaeForms # default value
AwardYears::V2025::QaeForms # default value
end
else
raise ArgumentError, "Can not find award form for the nomination in year: #{award_year.year}"
Expand Down
15 changes: 9 additions & 6 deletions app/views/qae_form/_supporter_fields.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,13 @@ li.js-add-example class="#{'read-only js-support-letter-received' if persisted}"
button.govuk-button.js-save-collection class=(persisted ? "visuallyhidden" : "") data-save-collection-url=users_form_answer_support_letters_url(@form_answer)
| Submit letter of support

- if !admin_in_read_only_mode? && persisted
- if supporter["support_letter_id"].present? && @form_answer.support_letters.find_by_id(supporter["support_letter_id"])
- url = users_form_answer_support_letter_path(form_answer_id: @form_answer.id, id: supporter["support_letter_id"])
- if current_form_is_editable? && !current_lieutenant && !current_assessor
- if persisted
- if supporter["support_letter_id"].present? && @form_answer.support_letters.find_by_id(supporter["support_letter_id"])
- url = users_form_answer_support_letter_path(form_answer_id: @form_answer.id, id: supporter["support_letter_id"])
- else
- url = "#"
- if current_user || policy(:support_letter).can_remove?
= link_to "Remove", url, class: "govuk-button govuk-button--warning remove-supporter remove-link js-remove-link", data: { url: url }, 'aria-label' => "Delete support letter from #{supporter["first_name"]} #{supporter["last_name"]}"
- else
- url = "#"
- if current_user || policy(:support_letter).can_remove?
= link_to "Remove", url, class: "govuk-button govuk-button--warning remove-supporter remove-link js-remove-link", data: { url: url }, 'aria-label' => "Delete support letter from #{supporter["first_name"]} #{supporter["last_name"]}"
= link_to "Remove", "#", class: "govuk-button govuk-button--warning remove-supporter remove-link js-remove-link govuk-!-display-none", data: { url: "#" }, 'aria-label' => "#"
7 changes: 5 additions & 2 deletions app/views/qae_form/_supporter_fields_placeholder.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,8 @@ li.js-add-example class="govuk-!-display-none"
span.govuk-error-message
input class="js-trigger-autosave js-support-letter-attachment govuk-input medium" name="form[#{question.key}][{index}][letter_of_support]" id="form[#{question.key}][{index}][letter_of_support]" type='file' disabled=true

button.govuk-button.button-alt.js-save-collection data-save-collection-url=users_form_answer_support_letters_url(@form_answer) disabled='disabled'
| Submit letter of support
p
button.govuk-button.button-alt.js-save-collection data-save-collection-url=users_form_answer_support_letters_url(@form_answer) disabled='disabled'
| Submit letter of support

= link_to "Remove", "#", class: "govuk-button govuk-button--warning remove-supporter remove-link js-remove-link govuk-!-display-none", data: { url: "#" }, 'aria-label' => "#"
5 changes: 3 additions & 2 deletions app/views/qae_form/_supporters_question.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ ul.list-add.supporters-list data-need-to-clear-example=true data-add-limit=quest
- (0...question.default.to_i).each do |index|
= render 'qae_form/supporter_fields', question: question, supporter: {}, index: index

a.govuk-button.govuk-button--secondary.button-add.js-button-add href="#" *possible_read_only_ops(question.step.opts[:id])
| Add another letter of support
- if current_form_is_editable?
a.govuk-button.govuk-button--secondary.button-add.js-button-add href="#" *possible_read_only_ops(question.step.opts[:id])
| Add another letter of support
2 changes: 1 addition & 1 deletion app/views/qae_form/show.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ form.qae-form.award-form data-autosave-url=save_form_url(@form_answer) action=sa
h2.govuk-error-summary__title#letters-of-support-error-title There was a problem submitting the form
.govuk-error-summary__body
p.govuk-body
' Upload at least two letters of support.
' Upload two letters of support.
p.govuk-body
= link_to "Add more letters of support", form_form_answer_supporters_path(@form_answer), class: 'govuk-link'

Expand Down
43 changes: 42 additions & 1 deletion forms/appraisal_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class AppraisalForm
#
# THIS NEED TO BE UPDATED EACH YEAR
#
SUPPORTED_YEARS = [2022, 2023, 2024]
SUPPORTED_YEARS = [2022, 2023, 2024, 2025]

EVALUATION_OPTIONS_2022 = [
["Weak evidence", "weak"],
Expand All @@ -24,6 +24,12 @@ class AppraisalForm
["Strong evidence", "strong"]
]

EVALUATION_OPTIONS_2025 = [
["Weak evidence", "weak"],
["Good evidence", "good"],
["Strong evidence", "strong"]
]

VERDICT_OPTIONS_2022 = [
["Not Recommended", "not_recommended"],
["Recommended", "recommended"],
Expand All @@ -42,6 +48,12 @@ class AppraisalForm
["Undecided", "undecided"]
]

VERDICT_OPTIONS_2025 = [
["Not Recommended", "not_recommended"],
["Recommended", "recommended"],
["Undecided", "undecided"]
]

def self.evaluation_options_for(object, section)
options = const_get("EVALUATION_OPTIONS_#{object.award_year.year}")

Expand Down Expand Up @@ -164,9 +176,38 @@ def self.verdict_options_for(object, section)
}
}.freeze

QAVS_2025 = {
good_impact: {
type: :rag,
label: "Good impact",
position: 0
},
volunteer_led: {
type: :rag,
label: "Volunteer-led",
position: 1
},
good_governance: {
type: :rag,
label: "Good governance",
position: 2
},
exceptional_qualities: {
type: :rag,
label: "Exceptional qualities",
position: 3
},
verdict: {
type: :verdict,
label: "Overall decision",
position: 4
}
}.freeze

ALL_FORMS_2022 = [QAVS_2022]
ALL_FORMS_2023 = [QAVS_2023]
ALL_FORMS_2024 = [QAVS_2024]
ALL_FORMS_2025 = [QAVS_2025]

def self.rate(key)
"#{key}_rate"
Expand Down
2 changes: 1 addition & 1 deletion forms/award_years/v2022/qavs/qavs_step4.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def qavs_step4
required
text -> do
%(
I have read and understood the contents of the <a href="https://qavs.dcms.gov.uk/privacy-policy/">Privacy Notice</a>
I have read and understood the contents of the <a href="https://qavs.dcms.gov.uk/privacy-policy/" target="_blank">Privacy Notice</a>
)
end
end
Expand Down
2 changes: 1 addition & 1 deletion forms/award_years/v2023/qavs/qavs_step4.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def qavs_step4
required
text -> do
%(
I have read and understood the contents of the <a href="https://qavs.dcms.gov.uk/privacy-policy/">Privacy Notice</a>
I have read and understood the contents of the <a href="https://qavs.dcms.gov.uk/privacy-policy/" target="_blank">Privacy Notice</a>
)
end
end
Expand Down
2 changes: 1 addition & 1 deletion forms/award_years/v2024/qavs/qavs_step4.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def qavs_step4
required
text -> do
%(
I have read and understood the contents of the <a href="https://kavs.dcms.gov.uk/privacy-policy/">Privacy Notice</a>
I have read and understood the contents of the <a href="https://kavs.dcms.gov.uk/privacy-policy/" target="_blank">Privacy Notice</a>
)
end
end
Expand Down
4 changes: 4 additions & 0 deletions forms/award_years/v2025/qae_forms.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
require_relative 'qavs'

class AwardYears::V2025::QaeForms
end
30 changes: 30 additions & 0 deletions forms/award_years/v2025/qavs.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
require_relative "qavs/qavs_step1"
require_relative "qavs/qavs_step2"
require_relative "qavs/qavs_step3"
require_relative "qavs/qavs_step4"
require_relative "qavs/qavs_step5"

class AwardYears::V2025::QaeForms
class << self
def qavs
@qavs ||= QaeFormBuilder.build "King's Award for Voluntary Service Nomination" do
step "nominee",
&AwardYears::V2025::QaeForms.qavs_step1

step "recommendation",
&AwardYears::V2025::QaeForms.qavs_step2

step "letters_of_support",
{ id: :letters_of_support_step },
&AwardYears::V2025::QaeForms.qavs_step3

step "submit_step",
&AwardYears::V2025::QaeForms.qavs_step4

step "local_assessment_form",
{ id: :local_assessment },
&AwardYears::V2025::QaeForms.qavs_step5
end
end
end
end
116 changes: 116 additions & 0 deletions forms/award_years/v2025/qavs/qavs_step1.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
# coding: utf-8
class AwardYears::V2025::QaeForms
class << self
def qavs_step1
@qavs_step1 ||= proc do
notice %(
<p class=govuk-body>Please note your answers are being saved automatically in the background.</p>
)

header :nominee_details_header, "Group details" do
ref "A 1"
end

text :nominee_name, "Name of group" do
sub_ref "A 1.1"
required
form_hint "It is important that the name is accurate and spelt correctly, as this will appear on the Award certificate if your nomination succeeds. You do not need to add a charity number."
style "large"
end

text :nominee_established_date, "When was the group established?" do
sub_ref "A 1.2"
required
style "small"
end

dropdown :nominee_activity, "Please select the group's main area of activity" do
sub_ref "A 1.3"
required
option "", ""
nominee_activities
end

dropdown :secondary_activity, "Please select the group's secondary area of activity (optional)" do
sub_ref "A 1.4"
option "", ""
nominee_activities
end

address :nominee_address, "Address of group" do
sub_ref "A 1.5"
required
sub_fields([
{ building: "Building" },
{ street: "Street" },
{ city: "Town or city" },
{ county: "County" },
{ postcode: "Postcode" }
])
end

text :nominee_phone, "Telephone number" do
sub_ref "A 1.6"
style "small"
type "tel"
end

text :nominee_website, "Website" do
sub_ref "A 1.7"
style "large"
end

textarea :social_media, "Social media" do
sub_ref "A 1.8"
form_hint "Social media accounts if known"
words_max 100
rows 2
end

header :nominee_leader_header, "About the group leader or main contact in the group" do
ref "A 2"
context %(
<p class='govuk-hint'>This is the person the County Assessment Panel will contact to ask any questions or arrange a visit.</p>
)
end

text :nominee_leader_name, "Name of the group leader or main contact in the group" do
sub_ref "A 2.1"
required
style "small"
end

text :nominee_leader_position, "Position held in the group" do
sub_ref "A 2.2"
required
style "large"
end

address :nominee_leader_address, "Address of main contact" do
sub_ref "A 2.3"
required
sub_fields([
{ building: "Building" },
{ street: "Street" },
{ city: "Town or city" },
{ county: "County" },
{ postcode: "Postcode" }
])
end

text :nominee_leader_email, "Email" do
sub_ref "A 2.4"
required
type "email"
style "large"
end

text :nominee_leader_telephone, "Telephone" do
sub_ref "A 2.5"
style "small"
type "tel"
end
end
end
end
end
Loading

0 comments on commit 55d2363

Please sign in to comment.