Browse Source

feat: add question page and subsection

CLDC-1533-is-resale
natdeanlewissoftwire 2 years ago
parent
commit
3f2b8f8ef8
  1. 15
      app/models/form/sales/pages/buyers_organisations.rb
  2. 19
      app/models/form/sales/questions/buyers_organisations.rb
  3. 1
      app/models/form/sales/sections/household.rb
  4. 15
      app/models/form/sales/subsections/household_situation.rb
  5. 10
      db/migrate/20221222153059_add_buyers_organisations_to_sales_log.rb
  6. 6
      db/schema.rb

15
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

19
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

1
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

15
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

10
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

6
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"

Loading…
Cancel
Save