diff --git a/app/controllers/case_logs_controller.rb b/app/controllers/case_logs_controller.rb index 3b564cb05..9eb4ec4c7 100644 --- a/app/controllers/case_logs_controller.rb +++ b/app/controllers/case_logs_controller.rb @@ -7,4 +7,21 @@ class CaseLogsController < ApplicationController def show @case_log = CaseLog.find(params[:id]) end + + def edit + @case_log = CaseLog.find(params[:id]) + render 'case_logs/household/tenant_code' + end + + def update + @case_log = CaseLog.find(params[:id]) + @case_log.update(tenant_code: params[:case_log][:tenant_code]) if params[:case_log] + render_next_question(@case_log) + end + + private + + def render_next_question(case_log) + render 'case_logs/household/tenant_age' + end end diff --git a/app/views/case_logs/edit.html.erb b/app/views/case_logs/edit.html.erb index e19709917..0d27a877b 100644 --- a/app/views/case_logs/edit.html.erb +++ b/app/views/case_logs/edit.html.erb @@ -1,8 +1,16 @@ -<%= form_with model: @case_log, builder: GOVUKDesignSystemFormBuilder::FormBuilder do |f| %> - <%= f.govuk_number_field :age, - hint: { text: "More detail" }, - label: { text: "What is the tenant's age?", size: "l"}, - min: 0, max: 150, step: 1, width: 20 - %> - <%= f.govuk_submit %> -<% end %> +
+
+

Tasklist for log + <%= @case_log.id %>

+ +

This submission is + <%= @case_log.status %>

+

You've completed 0 of 9 sections.

+

+ Skip to next incomplete section +

+ + <%= render "tasklist" %> + +
+
diff --git a/app/views/case_logs/household/tenant_age.html.erb b/app/views/case_logs/household/tenant_age.html.erb new file mode 100644 index 000000000..a21603edb --- /dev/null +++ b/app/views/case_logs/household/tenant_age.html.erb @@ -0,0 +1,8 @@ + <%= form_with model: @case_log, method: "patch", builder: GOVUKDesignSystemFormBuilder::FormBuilder do |f| %> + <%= f.govuk_number_field :tenant_age, + hint: { text: "More detail" }, + label: { text: "What is the tenant's age?", size: "l"}, + min: 0, max: 150, step: 1, width: 20 + %> + <%= f.govuk_submit "Save and continue" %> +<% end %> \ No newline at end of file diff --git a/app/views/case_logs/household/tenant_code.html.erb b/app/views/case_logs/household/tenant_code.html.erb new file mode 100644 index 000000000..56e50a01e --- /dev/null +++ b/app/views/case_logs/household/tenant_code.html.erb @@ -0,0 +1,8 @@ +<%= form_with model: @case_log, method: "patch", builder: GOVUKDesignSystemFormBuilder::FormBuilder do |f| %> + <%= f.govuk_text_field :tenant_code, + hint: { text: "More detail" }, + label: { text: "What is the tenant code?", size: "l"}, + width: 20 + %> + <%= f.govuk_submit "Save and continue" %> +<% end %> \ No newline at end of file diff --git a/app/views/case_logs/show.html.erb b/app/views/case_logs/show.html.erb index 0d27a877b..f9f76fa7f 100644 --- a/app/views/case_logs/show.html.erb +++ b/app/views/case_logs/show.html.erb @@ -13,4 +13,4 @@ <%= render "tasklist" %> - + \ No newline at end of file diff --git a/db/migrate/20210914101759_add_question_fields_to_case_logs.rb b/db/migrate/20210914101759_add_question_fields_to_case_logs.rb new file mode 100644 index 000000000..c855c2392 --- /dev/null +++ b/db/migrate/20210914101759_add_question_fields_to_case_logs.rb @@ -0,0 +1,12 @@ +class AddQuestionFieldsToCaseLogs < ActiveRecord::Migration[6.1] + def change + add_column :case_logs, :tenant_code, :string + add_column :case_logs, :tenant_age, :integer + add_column :case_logs, :tenant_gender, :string + add_column :case_logs, :tenant_ethnic_group, :string + add_column :case_logs, :tenant_nationality, :string + add_column :case_logs, :previous_housing_situation, :string + add_column :case_logs, :prior_homelessness, :integer + add_column :case_logs, :armed_forces, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 936791fa2..393bcbc9d 100644 --- a/db/schema.rb +++ b/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_08_122819) do +ActiveRecord::Schema.define(version: 2021_09_14_101759) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -19,6 +19,14 @@ ActiveRecord::Schema.define(version: 2021_09_08_122819) do t.integer "status", default: 0 t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false + t.string "tenant_code" + t.integer "tenant_age" + t.string "tenant_gender" + t.string "tenant_ethnic_group" + t.string "tenant_nationality" + t.string "previous_housing_situation" + t.integer "prior_homelessness" + t.string "armed_forces" end end diff --git a/spec/features/case_log_spec.rb b/spec/features/case_log_spec.rb index 644ce48c3..b2a4f6d6b 100644 --- a/spec/features/case_log_spec.rb +++ b/spec/features/case_log_spec.rb @@ -15,4 +15,12 @@ RSpec.describe "Test Features" do expect(page).to have_field("age") expect(page).to have_button("Continue") end + + it "displays the household questions when you click into that section" do + visit("/case_logs/#{id}") + click_link("Household characteristics") + expect(page).to have_field("case-log-tenant-code-field") + click_button("Save and continue") + expect(page).to have_field("case-log-tenant-age-field") + end end