Browse Source

feat: add question and page

pull/1124/head
natdeanlewissoftwire 4 years ago
parent
commit
999af26bef
  1. 15
      app/models/form/sales/pages/armed_forces.rb
  2. 19
      app/models/form/sales/questions/armed_forces.rb
  3. 1
      app/models/form/sales/subsections/household_needs.rb
  4. 7
      db/migrate/20221223134818_add_armed_forces_to_sales_log.rb
  5. 3
      db/schema.rb

15
app/models/form/sales/pages/armed_forces.rb

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

19
app/models/form/sales/questions/armed_forces.rb

@ -0,0 +1,19 @@
class Form::Sales::Questions::ArmedForces < ::Form::Question
def initialize(id, hsh, page)
super
@id = "hhregres"
@check_answer_label = "Have any of the buyers ever served as a regular in the UK armed forces?"
@header = "Have any of the buyers ever served as a regular in the UK armed forces?"
@type = "radio"
@hint_text = "A regular is somebody who has served in the Royal Navy, the Royal Marines, the Royal Airforce or Army full time and does not include reserve forces"
@answer_options = ANSWER_OPTIONS
@page = page
end
ANSWER_OPTIONS = {
"1" => { "value" => "Yes" },
"7" => { "value" => "No" },
"3" => { "value" => "Buyer prefers not to say" },
"8" => { "value" => "Don't know" },
}.freeze
end

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

@ -9,6 +9,7 @@ class Form::Sales::Subsections::HouseholdNeeds < ::Form::Subsection
def pages def pages
@pages ||= [ @pages ||= [
Form::Sales::Pages::ArmedForces.new(nil, nil, self),
Form::Sales::Pages::HouseholdWheelchair.new(nil, nil, self), Form::Sales::Pages::HouseholdWheelchair.new(nil, nil, self),
Form::Sales::Pages::HouseholdDisability.new(nil, nil, self), Form::Sales::Pages::HouseholdDisability.new(nil, nil, self),
] ]

7
db/migrate/20221223134818_add_armed_forces_to_sales_log.rb

@ -0,0 +1,7 @@
class AddArmedForcesToSalesLog < ActiveRecord::Migration[7.0]
def change
change_table :sales_logs, bulk: true do |t|
t.column :hhregres, :integer
end
end
end

3
db/schema.rb

@ -10,7 +10,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[7.0].define(version: 2022_12_21_172821) do ActiveRecord::Schema[7.0].define(version: 2022_12_23_134818) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"
@ -416,6 +416,7 @@ ActiveRecord::Schema[7.0].define(version: 2022_12_21_172821) do
t.integer "ecstat5" t.integer "ecstat5"
t.integer "ecstat6" t.integer "ecstat6"
t.integer "disabled" t.integer "disabled"
t.integer "hhregres"
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