Browse Source

CLDC-1577 Added page asking for local authority in sales log

pull/953/head
David May-Miller 4 years ago
parent
commit
da927e2a21
  1. 16
      app/models/form/sales/pages/property_local_authority.rb
  2. 17
      app/models/form/sales/questions/property_local_authority.rb
  3. 24
      app/models/form/sales/questions/property_local_authority_known.rb
  4. 1
      app/models/form/sales/subsections/property_information.rb
  5. 8
      db/migrate/20221007133155_add_la_to_sales_log.rb
  6. 2
      db/schema.rb

16
app/models/form/sales/pages/property_local_authority.rb

@ -0,0 +1,16 @@
class Form::Sales::Pages::PropertyLocalAuthority < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "property_local_authority"
@header = ""
@description = ""
@subsection = subsection
end
def questions
@questions ||= [
Form::Sales::Questions::PropertyLocalAuthorityKnown.new(nil, nil, self),
Form::Sales::Questions::PropertyLocalAuthority.new(nil, nil, self),
]
end
end

17
app/models/form/sales/questions/property_local_authority.rb

@ -0,0 +1,17 @@
class Form::Sales::Questions::PropertyLocalAuthority < ::Form::Question
def initialize(id, hsh, page)
super
@id = "la"
@check_answer_label = "Local authority"
@header = "What is the local authority of the property?"
@type = "select"
@answer_options = ANSWER_OPTIONS
@page = page
end
ANSWER_OPTIONS = {
"test" => "Location",
"test2" => "Other location",
"foo" => "bar",
}.freeze
end

24
app/models/form/sales/questions/property_local_authority_known.rb

@ -0,0 +1,24 @@
class Form::Sales::Questions::PropertyLocalAuthorityKnown < ::Form::Question
def initialize(id, hsh, page)
super
@id = "la_known"
@check_answer_label = "Local authority known"
@header = "Do you know the local authority of the property?"
@type = "radio"
@answer_options = ANSWER_OPTIONS
@conditional_for = { "la" => [1] }
@hidden_in_check_answers = {
"depends_on" => [
{
"la_known" => 1,
},
],
}
@page = page
end
ANSWER_OPTIONS = {
"1" => { "value" => "Yes" },
"0" => { "value" => "No" },
}.freeze
end

1
app/models/form/sales/subsections/property_information.rb

@ -12,6 +12,7 @@ class Form::Sales::Subsections::PropertyInformation < ::Form::Subsection
Form::Sales::Pages::PropertyNumberOfBedrooms.new(nil, nil, self), Form::Sales::Pages::PropertyNumberOfBedrooms.new(nil, nil, self),
Form::Sales::Pages::PropertyBuildingType.new(nil, nil, self), Form::Sales::Pages::PropertyBuildingType.new(nil, nil, self),
Form::Sales::Pages::PropertyUnitType.new(nil, nil, self), Form::Sales::Pages::PropertyUnitType.new(nil, nil, self),
Form::Sales::Pages::PropertyLocalAuthority.new(nil, nil, self),
] ]
end end
end end

8
db/migrate/20221007133155_add_la_to_sales_log.rb

@ -0,0 +1,8 @@
class AddLaToSalesLog < ActiveRecord::Migration[7.0]
def change
change_table :sales_logs do |t|
t.column :la, :string
t.column :la_known, :integer
end
end
end

2
db/schema.rb

@ -367,6 +367,8 @@ ActiveRecord::Schema[7.0].define(version: 2022_10_19_082625) do
t.integer "age5_known" t.integer "age5_known"
t.integer "age6" t.integer "age6"
t.integer "age6_known" t.integer "age6_known"
t.string "la"
t.integer "la_known"
t.index ["created_by_id"], name: "index_sales_logs_on_created_by_id" 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 ["managing_organisation_id"], name: "index_sales_logs_on_managing_organisation_id"
t.index ["owning_organisation_id"], name: "index_sales_logs_on_owning_organisation_id" t.index ["owning_organisation_id"], name: "index_sales_logs_on_owning_organisation_id"

Loading…
Cancel
Save