Browse Source

Add custom guidance partials

pull/192/head
baarkerlounger 3 years ago
parent
commit
59f8c73e7f
  1. 4
      app/models/form/question.rb
  2. 2
      app/views/form/_checkbox_question.html.erb
  3. 2
      app/views/form/_date_question.html.erb
  4. 2
      app/views/form/_numeric_question.html.erb
  5. 2
      app/views/form/_radio_question.html.erb
  6. 2
      app/views/form/_select_question.html.erb
  7. 2
      app/views/form/_text_question.html.erb
  8. 2
      app/views/form/_textarea_question.html.erb
  9. 25
      app/views/form/guidance/_what_counts_as_income.html.erb
  10. 13
      config/forms/2021_2022.json

4
app/models/form/question.rb

@ -2,12 +2,14 @@ class Form::Question
attr_accessor :id, :header, :hint_text, :description, :questions,
:type, :min, :max, :step, :width, :fields_to_add, :result_field,
:conditional_for, :readonly, :answer_options, :page, :check_answer_label,
:inferred_answers, :hidden_in_check_answers, :inferred_check_answers_value
:inferred_answers, :hidden_in_check_answers, :inferred_check_answers_value,
:guidance_partial
def initialize(id, hsh, page)
@id = id
@check_answer_label = hsh["check_answer_label"]
@header = hsh["header"]
@guidance_partial = hsh["guidance_partial"]
@hint_text = hsh["hint_text"]
@type = hsh["type"]
@min = hsh["min"]

2
app/views/form/_checkbox_question.html.erb

@ -1,3 +1,5 @@
<%= render partial: "form/guidance/#{question.guidance_partial}" if question.guidance_partial %>
<%= f.govuk_check_boxes_fieldset question.id.to_sym,
caption: caption && !page_header.present? ? { text: caption.html_safe, size: "l" } : nil,
legend: { text: question.header.html_safe, size: !page_header.present? ? "l" : "m", tag: !page_header.present? ? "h1" : "h2" },

2
app/views/form/_date_question.html.erb

@ -1,3 +1,5 @@
<%= render partial: "form/guidance/#{question.guidance_partial}" if question.guidance_partial %>
<%= f.govuk_date_field question.id.to_sym,
caption: caption && !page_header.present? ? { text: caption.html_safe, size: "l" } : nil,
legend: { text: question.header.html_safe, size: !page_header.present? ? "l" : "m", tag: !page_header.present? ? "h1" : "h2" },

2
app/views/form/_numeric_question.html.erb

@ -1,3 +1,5 @@
<%= render partial: "form/guidance/#{question.guidance_partial}" if question.guidance_partial %>
<%= f.govuk_number_field question.id.to_sym,
caption: caption && !page_header.present? ? { text: caption.html_safe, size: "l" } : nil,
label: { text: question.header.html_safe, size: !page_header.present? ? "l" : "m", tag: !page_header.present? ? "h1" : "h2" },

2
app/views/form/_radio_question.html.erb

@ -1,3 +1,5 @@
<%= render partial: "form/guidance/#{question.guidance_partial}" if question.guidance_partial %>
<%= f.govuk_radio_buttons_fieldset question.id.to_sym,
caption: caption && !page_header.present? ? { text: caption.html_safe, size: "l" } : nil,
legend: { text: question.header.html_safe, size: !page_header.present? ? "l" : "m", tag: !page_header.present? ? "h1" : "h2" },

2
app/views/form/_select_question.html.erb

@ -1,3 +1,5 @@
<%= render partial: "form/guidance/#{question.guidance_partial}" if question.guidance_partial %>
<% selected = CaseLog::UK_LA[@case_log.public_send(question.id)] || "" %>
<%= answers = question.answer_options.map { |key, value| OpenStruct.new(id: key, name: value) }
f.govuk_collection_select question.id.to_sym,

2
app/views/form/_text_question.html.erb

@ -1,3 +1,5 @@
<%= render partial: "form/guidance/#{question.guidance_partial}" if question.guidance_partial %>
<%= f.govuk_text_field question.id.to_sym,
caption: caption && !page_header.present? ? { text: caption.html_safe, size: "l" } : nil,
label: { text: question.header.html_safe, size: !page_header.present? ? "l" : "m", tag: !page_header.present? ? "h1" : "h2" },

2
app/views/form/_textarea_question.html.erb

@ -1,3 +1,5 @@
<%= render partial: "form/guidance/#{question.guidance_partial}" if question.guidance_partial %>
<%= f.govuk_text_area question.id.to_sym,
caption: caption && !page_header.present? ? { text: caption.html_safe, size: "l" } : nil,
label: { text: question.header.html_safe, size: !page_header.present? ? "l" : "m", tag: !page_header.present? ? "h1" : "h2" },

25
app/views/form/guidance/_what_counts_as_income.html.erb

@ -0,0 +1,25 @@
<details class="govuk-details" data-module="govuk-details">
<summary class="govuk-details__summary">
<span class="govuk-details__summary-text">
What counts as income?
</span>
</summary>
<div class="govuk-details__text">
<p class="govuk-body">You should include any income from:</p>
<ul class="govuk-list govuk-list--bullet">
<li>employment</li>
<li>pensions</li>
<li>Universal Credit</li>
</ul>
<p class="govuk-body">Don’t include:</p>
<ul class="govuk-list govuk-list--bullet">
<li>National Insurance (NI) contributions and tax</li>
<li>housing benefit</li>
<li>child benefit</li>
<li>council tax support</li>
</ul>
</div>
</details>

13
config/forms/2021_2022.json

@ -1796,18 +1796,21 @@
"depends_on": { "about_this_log": "completed" },
"pages": {
"net_income": {
"header": "",
"header": "Household’s combined income",
"description": "",
"questions": {
"net_income_known": {
"check_answer_label": "Income known",
"header": "Do you know the tenant and their partner’s net income?",
"header": "Do you know the household’s combined income after tax?",
"guidance_partial": "what_counts_as_income",
"hint_text": "",
"type": "radio",
"answer_options": {
"0": "Yes",
"1": "No",
"2": "Tenant prefers not to say"
"0": "Yes – the household has a weekly income",
"1": "Yes – the household has a monthly income",
"2": "Yes – the household has a yearly income",
"divider_a": true,
"3": "Tenant prefers not to say"
},
"conditional_for": {
"earnings": ["Yes"],

Loading…
Cancel
Save