Browse Source

switch test form

pull/78/head
magicmilo 3 years ago
parent
commit
ca367d612d
  1. 18
      app/helpers/check_answers_helper.rb
  2. 24
      config/forms/2021_2022.json
  3. 0
      db/migrate/20211102100820_add_about_this_log_readable_columns.rb
  4. 13
      db/schema.rb
  5. 21
      spec/fixtures/forms/test_aboutthislog.json

18
app/helpers/check_answers_helper.rb

@ -28,12 +28,25 @@ module CheckAnswersHelper
def filter_conditional_questions(questions, case_log)
applicable_questions = questions
# puts applicable_questions.count
questions.each do |k, question|
# if k == "default_next_page"
# applicable_questions = applicable_questions.reject { |z| z == "default_next_page" }
# else
# question.fetch("conditional_for", []).each do |conditional_question_key, condition|
# if condition_not_met(case_log, k, question, condition)
# applicable_questions = applicable_questions.reject { |z| z == conditional_question_key }
# end
# end
# end
question.fetch("conditional_for", []).each do |conditional_question_key, condition|
if condition_not_met(case_log, k, question, condition)
applicable_questions = applicable_questions.reject { |z| z == conditional_question_key }
end
end
end
applicable_questions
end
@ -56,13 +69,14 @@ module CheckAnswersHelper
operator = condition[/[<>=]+/].to_sym
operand = condition[/\d+/].to_i
case_log[question_key].blank? || !case_log[question_key].send(operator, operand)
when "text"
case_log[question_key].blank? || !condition.include?(case_log[question_key])
when "radio"
case_log[question_key].blank? || !condition.include?(case_log[question_key])
when "select"
case_log[question_key].blank? || !condition.include?(case_log[question_key])
else
raise "Not implemented yet"
end
raise "Not implemented yet" end
end
def create_update_answer_link(case_log_answer, case_log_id, page)

24
config/forms/2021_2022.json

@ -33,6 +33,9 @@
"header": "You cannot use this service",
"hint_text": "",
"description": "We cannot accept data about a tenant or buyer unless they’ve seen the DLUHC privacy notice.",
"questions": {
},
"default_next_page" : "check_answers"
},
"organisation_details": {
@ -74,13 +77,12 @@
"0": "Sale",
"1": "Letting"
}
},
"conditional_route_to": {
"sale_completion_date": { "sale_or_letting": "Sale" },
"tenant_same_property_renewal": { "sale_or_letting": "Letting" }
},
"default_next_page" : ["check_answers"]
}
}
},
"conditional_route_to": {
"tenant_same_property_renewal": { "sale_or_letting": "Letting" }
},
"default_next_page" : "check_answers"
},
"tenant_same_property_renewal": {
"header": "About this log",
@ -126,15 +128,15 @@
"3": "Rent To Buy",
"4": "London Living Rent",
"5": "Other Intermediate Rent Product"
},
"conditional_for": {
"intermediate_rent_product_name": ["Other Intermediate Rent Product"]
}
},
"intermediate_rent_product_name": {
"check_answer_label": "Enter the product name",
"header": "What is intermediate rent product name?",
"type": "text",
"conditional_for": {
"rent_type": ["Other Intermediate Rent Product"]
}
"type": "text"
},
"needs_type": {
"check_answer_label": "What is the needs type?",

0
db/migrate/20211102100820_add_about_this_log_readable_columns → db/migrate/20211102100820_add_about_this_log_readable_columns.rb

13
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_10_27_123535) do
ActiveRecord::Schema.define(version: 2021_11_02_100820) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -133,6 +133,17 @@ ActiveRecord::Schema.define(version: 2021_10_27_123535) do
t.boolean "reasonable_preference_reason_do_not_know"
t.datetime "discarded_at"
t.string "other_tenancy_type"
t.string "gdpr_acceptance"
t.string "gdpr_declined"
t.string "property_owner_organisation"
t.string "property_manager_organisation"
t.string "sale_or_letting"
t.string "tenant_same_property_renewal"
t.string "rent_type"
t.string "intermediate_rent_product_name"
t.string "needs_type"
t.string "sale_completion_date"
t.string "purchaser_code"
t.index ["discarded_at"], name: "index_case_logs_on_discarded_at"
end

21
spec/fixtures/forms/test_aboutthislog.json vendored

@ -75,13 +75,12 @@
"0": "Sale",
"1": "Letting"
}
},
"conditional_route_to": {
"sale_completion_date": { "sale_or_letting": "Sale" },
"tenant_same_property_renewal": { "sale_or_letting": "Letting" }
},
"default_next_page" : ["check_answers"]
}
}
},
"conditional_route_to": {
"tenant_same_property_renewal": { "sale_or_letting": "Letting" }
},
"default_next_page" : "check_answers"
},
"tenant_same_property_renewal": {
"header": "About this log",
@ -127,15 +126,15 @@
"3": "Rent To Buy",
"4": "London Living Rent",
"5": "Other Intermediate Rent Product"
},
"conditional_for": {
"intermediate_rent_product_name": ["Other Intermediate Rent Product"]
}
},
"intermediate_rent_product_name": {
"check_answer_label": "Enter the product name",
"header": "What is intermediate rent product name?",
"type": "text",
"conditional_for": {
"rent_type": ["Other Intermediate Rent Product"]
}
"type": "text"
},
"needs_type": {
"check_answer_label": "What is the needs type?",

Loading…
Cancel
Save