Browse Source

Add household needs section & fix form navigation for multi question pages

pull/23/head
baarkerlounger 3 years ago
parent
commit
c46441bd5d
  1. 2
      app/views/form/_numeric_question.html.erb
  2. 4
      app/views/form/_radio_question.html.erb
  3. 5
      app/views/form/_select_question.html.erb
  4. 2
      app/views/form/_text_question.html.erb
  5. 10
      app/views/form/page.html.erb
  6. 123
      config/forms/2021_2022.json
  7. 15
      db/migrate/20210924103433_add_additional_field_to_case_log.rb
  8. 11
      db/schema.rb

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

@ -3,5 +3,5 @@
label: { text: question["header"], size: "l"},
min: question["min"], max: question["max"], step: question["step"], width: 20
%>
<%= f.hidden_field :previous_page, value: question_key %>
<%= f.hidden_field :previous_page, value: page_key %>
<%= f.hidden_field :case_log_id, value: case_log_id %>

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

@ -1,5 +1,5 @@
<% answer_options = question["answer_options"].map { |k, v| OpenStruct.new(id: k.to_i, value: v) } %>
<%= f.govuk_collection_radio_buttons question_key, answer_options, :id, :value, legend: { text: question["header"], size: "l" } %>
<%= f.hidden_field :previous_page, value: question_key %>
<%= f.govuk_collection_radio_buttons question_key, answer_options, :id, :value, legend: { text: question["header"], size: "l" }, hint: { text: question["hint_text"] } %>
<%= f.hidden_field :previous_page, value: page_key %>
<%= f.hidden_field :case_log_id, value: case_log_id %>

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

@ -0,0 +1,5 @@
<% answer_options = question["answer_options"].map { |k, v| OpenStruct.new(id: k.to_i, value: v) } %>
<%= f.govuk_collection_check_boxes question_key, answer_options, :id, :value, legend: { text: question["header"], size: "l" }, hint: { text: question["hint_text"] } %>
<%= f.hidden_field :previous_page, value: page_key %>
<%= f.hidden_field :case_log_id, value: case_log_id %>

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

@ -3,5 +3,5 @@
label: { text: question["header"], size: "l"},
width: 20
%>
<%= f.hidden_field :previous_page, value: question_key %>
<%= f.hidden_field :previous_page, value: page_key %>
<%= f.hidden_field :case_log_id, value: case_log_id %>

10
app/views/form/page.html.erb

@ -6,12 +6,14 @@
<% end %>
<%= turbo_frame_tag "case_log_form", target: "_top" do %>
<h1 class="govuk-heading-xl">
<%= page_info["header"] %>
</h1>
<% if page_info["header"].present? %>
<h1 class="govuk-heading-xl">
<%= page_info["header"] %>
</h1>
<% end %>
<%= form_with action: '/case_logs', method: "next_page", builder: GOVUKDesignSystemFormBuilder::FormBuilder do |f| %>
<% page_info["questions"].map do |question_key, question| %>
<%= render partial: "form/#{question["type"]}_question", locals: { case_log_id: case_log_id, question_key: question_key, question: question, f: f } %>
<%= render partial: "form/#{question["type"]}_question", locals: { case_log_id: case_log_id, page_key: page_key, question_key: question_key, question: question, f: f } %>
<% end %>
<%= f.govuk_submit "Save and continue" %>
<% end %>

123
config/forms/2021_2022.json

@ -272,14 +272,129 @@
"household_needs": {
"label": "Household needs",
"pages": {
"tenant_code_0":{
"armed_forces":{
"header": "Experience of the UK Armed Forces",
"description": "",
"questions":{
"armed_forces": {
"header": "Has the tenant ever served in the UK armed forces?",
"hint_text": "",
"type": "radio",
"answer_options": {
"0": "Yes - a regular",
"1": "Yes - a reserve",
"2": "No",
"3": "Prefer not to say"
}
},
"armed_forces_active": {
"header": "Are they still serving?",
"hint_text": "",
"type": "radio",
"answer_options": {
"0": "Yes",
"1": "No - they left up to 5 years ago",
"2": "No - they left more than 5 years ago",
"3": "Prefer not to say"
}
},
"armed_forces_injured": {
"header": "Were they seriously injured or ill as a result of their service?",
"hint_text": "",
"type": "radio",
"answer_options": {
"0": "Yes",
"1": "No",
"2": "Prefer not to say"
}
},
"armed_forces_partner": {
"header": "Was the tenant the spouse or civil partner of someone who served in the UK armed forces?",
"hint_text": "",
"type": "radio",
"answer_options": {
"0": "Yes - was the spouse or civil partner of a UK Armed Forces member and have separated within the last 2 years",
"1": "Yes - was the spouse or civil partner of a UK Armed Forces member who died within the last 2 years",
"2": "No",
"3": "Prefer not to say"
}
}
}
},
"medical_conditions": {
"header": "",
"description": "",
"questions":{
"tenant_code_0": {
"header": "What is the tenant code?",
"medical_conditions": {
"header": "Does anyone in the household have a physical condition, mental health condition, or other illness that they expect to last for 12 months or more?",
"hint_text": "",
"type": "text"
"type": "radio",
"answer_options": {
"0": "Yes",
"1": "No",
"2": "Do not know",
"3": "Prefer not to say"
}
}
}
},
"pregnancy": {
"header": "",
"description": "",
"questions":{
"pregnancy": {
"header": "Is anyone in the household pregnant?",
"hint_text": "",
"type": "radio",
"answer_options": {
"0": "Yes",
"1": "No",
"2": "Prefer not to say"
}
}
}
},
"accessibility_requirements": {
"header": "",
"description": "",
"questions":{
"accessibility_requirements": {
"header": "Are any of these affected by their condition or illness?",
"hint_text": "Select all that apply",
"type": "select",
"answer_options": {
"0": "Fully wheelchair accessible housing",
"1": "Wheelchair access to essential rooms",
"2": "Level access housing",
"3": "Other disability requirements",
"4": "No disability requirements",
"5": "Do not know",
"6": "Prefer not to say"
}
}
}
},
"condition_effects": {
"header": "",
"description": "",
"questions":{
"condition_effects": {
"header": "Are any of these affected by their condition or illness?",
"hint_text": "Select all that apply",
"type": "select",
"answer_options": {
"0": "Vision - such as blindness or partial sight ",
"1": "Hearing - such as deafness or partial hearing ",
"2": "Mobility - such as walking short distances or climbing stairs ",
"3": "Dexterity - such as lifting and carrying objects or using a keyboard ",
"4": "Stamina or breathing or fatigue",
"5": "Learning or understanding or concentrating",
"6": "Memory",
"7": "Mental health - such as depression, anxiety, schizophrenia or bipolar",
"8": "Socially or behaviourally - such as those associated with autism spectral disorder (ASD) including Aspergers’ or attention deficit hyperactivity disorder (ADHD))",
"9": "Other",
"10": "Prefer not to say"
}
}
}
}

15
db/migrate/20210924103433_add_additional_field_to_case_log.rb

@ -0,0 +1,15 @@
class AddAdditionalFieldToCaseLog < ActiveRecord::Migration[6.1]
def change
change_table :case_logs, bulk: true do |t|
t.column :last_settled_home, :string
t.column :benefit_cap_spare_room_subsidy, :string
t.column :armed_forces_active, :string
t.column :armed_forces_injured, :string
t.column :armed_forces_partner, :string
t.column :medical_conditions, :string
t.column :pregnancy, :string
t.column :accessibility_requirements, :string
t.column :condition_effects, :string
end
end
end

11
db/schema.rb

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2021_09_24_085939) do
ActiveRecord::Schema.define(version: 2021_09_24_103433) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -59,6 +59,15 @@ ActiveRecord::Schema.define(version: 2021_09_24_085939) do
t.string "person_8_gender"
t.string "person_8_economic"
t.string "homelessness"
t.string "last_settled_home"
t.string "benefit_cap_spare_room_subsidy"
t.string "armed_forces_active"
t.string "armed_forces_injured"
t.string "armed_forces_partner"
t.string "medical_conditions"
t.string "pregnancy"
t.string "accessibility_requirements"
t.string "condition_effects"
end
end

Loading…
Cancel
Save