From 3f2b8f8ef887341e31ca658d56601ee7775718c1 Mon Sep 17 00:00:00 2001 From: natdeanlewissoftwire Date: Thu, 22 Dec 2022 16:16:08 +0000 Subject: [PATCH] feat: add question page and subsection --- .../form/sales/pages/buyers_organisations.rb | 15 +++++++++++++++ .../sales/questions/buyers_organisations.rb | 19 +++++++++++++++++++ app/models/form/sales/sections/household.rb | 1 + .../sales/subsections/household_situation.rb | 15 +++++++++++++++ ...9_add_buyers_organisations_to_sales_log.rb | 10 ++++++++++ db/schema.rb | 6 +++++- 6 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 app/models/form/sales/pages/buyers_organisations.rb create mode 100644 app/models/form/sales/questions/buyers_organisations.rb create mode 100644 app/models/form/sales/subsections/household_situation.rb create mode 100644 db/migrate/20221222153059_add_buyers_organisations_to_sales_log.rb diff --git a/app/models/form/sales/pages/buyers_organisations.rb b/app/models/form/sales/pages/buyers_organisations.rb new file mode 100644 index 000000000..cc6f82984 --- /dev/null +++ b/app/models/form/sales/pages/buyers_organisations.rb @@ -0,0 +1,15 @@ +class Form::Sales::Pages::BuyersOrganisations < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "buyers_organisations" + @header = "" + @description = "" + @subsection = subsection + end + + def questions + @questions ||= [ + Form::Sales::Questions::BuyersOrganisations.new(nil, nil, self), + ] + end +end diff --git a/app/models/form/sales/questions/buyers_organisations.rb b/app/models/form/sales/questions/buyers_organisations.rb new file mode 100644 index 000000000..1b932f02a --- /dev/null +++ b/app/models/form/sales/questions/buyers_organisations.rb @@ -0,0 +1,19 @@ +class Form::Sales::Questions::BuyersOrganisations < ::Form::Question + def initialize(id, hsh, page) + super + @id="organisations_buyers" + @check_answer_label = "Organisations buyers were registered with" + @header = "What organisations were the buyers registered with?" + @type = "checkbox" + @hint_text = "Select all that apply" + @page = page + @answer_options = ANSWER_OPTIONS + end + + ANSWER_OPTIONS = { + "pregyrha" => { "value" => "Their private registered provider (PRP)- housing association" }, + "pregother" => { "value" => "Other private registered provider (PRP)- housing association" }, + "pregla" => { "value" => "Local Authority" }, + "pregghb" => { "value" => "Help to Buy Agent" }, + }.freeze +end diff --git a/app/models/form/sales/sections/household.rb b/app/models/form/sales/sections/household.rb index e6f71a26d..3c7eae085 100644 --- a/app/models/form/sales/sections/household.rb +++ b/app/models/form/sales/sections/household.rb @@ -7,6 +7,7 @@ class Form::Sales::Sections::Household < ::Form::Section @form = form @subsections = [ Form::Sales::Subsections::HouseholdCharacteristics.new(nil, nil, self), + Form::Sales::Subsections::HouseholdSituation.new(nil, nil, self), Form::Sales::Subsections::HouseholdNeeds.new(nil, nil, self), ] end diff --git a/app/models/form/sales/subsections/household_situation.rb b/app/models/form/sales/subsections/household_situation.rb new file mode 100644 index 000000000..2be48f68c --- /dev/null +++ b/app/models/form/sales/subsections/household_situation.rb @@ -0,0 +1,15 @@ +class Form::Sales::Subsections::HouseholdSituation < ::Form::Subsection + def initialize(id, hsh, section) + super + @id = "household_situation" + @label = "Household situation" + @section = section + @depends_on = [{ "setup_completed?" => true }] + end + + def pages + @pages ||= [ + Form::Sales::Pages::BuyersOrganisations.new(nil, nil, self), + ] + end +end diff --git a/db/migrate/20221222153059_add_buyers_organisations_to_sales_log.rb b/db/migrate/20221222153059_add_buyers_organisations_to_sales_log.rb new file mode 100644 index 000000000..4781fd7b3 --- /dev/null +++ b/db/migrate/20221222153059_add_buyers_organisations_to_sales_log.rb @@ -0,0 +1,10 @@ +class AddBuyersOrganisationsToSalesLog < ActiveRecord::Migration[7.0] + def change + change_table :sales_logs, bulk: true do |t| + t.column :pregyrha, :int + t.column :pregla, :int + t.column :pregghb, :int + t.column :pregother, :integer + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 9b00a3a78..f13947a31 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[7.0].define(version: 2022_12_22_081402) do +ActiveRecord::Schema[7.0].define(version: 2022_12_22_153059) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -428,6 +428,10 @@ ActiveRecord::Schema[7.0].define(version: 2022_12_22_081402) do t.decimal "deposit", precision: 10, scale: 2 t.decimal "cashdis", precision: 10, scale: 2 t.integer "lanomagr" + t.integer "pregyrha" + t.integer "pregla" + t.integer "pregghb" + t.integer "pregother" t.index ["created_by_id"], name: "index_sales_logs_on_created_by_id" t.index ["managing_organisation_id"], name: "index_sales_logs_on_managing_organisation_id" t.index ["owning_organisation_id"], name: "index_sales_logs_on_owning_organisation_id"