magicmilo
3 years ago
34 changed files with 374 additions and 342 deletions
@ -0,0 +1,21 @@
|
||||
module DateValidations |
||||
def validate_property_major_repairs(record) |
||||
date_valid?("mrcdate", record) |
||||
end |
||||
|
||||
def validate_startdate(record) |
||||
date_valid?("startdate", record) |
||||
end |
||||
|
||||
def validate_sale_completion_date(record) |
||||
date_valid?("sale_completion_date", record) |
||||
end |
||||
|
||||
private |
||||
|
||||
def date_valid?(question, record) |
||||
if record[question].is_a?(ActiveSupport::TimeWithZone) && record[question].year.zero? |
||||
record.errors.add question, "Please enter a valid date" |
||||
end |
||||
end |
||||
end |
@ -1,13 +1,11 @@
|
||||
<dl class="govuk-summary-list govuk-!-margin-bottom-9"> |
||||
<div class="govuk-summary-list__row"> |
||||
<dt class="govuk-summary-list__key"> |
||||
<%= question_info["check_answer_label"].to_s.present? ? question_info["check_answer_label"].to_s : question_info["header"].to_s%> |
||||
<dt> |
||||
<dd class="govuk-summary-list__value"> |
||||
<%= form.get_answer_label(@case_log, question_title) %> |
||||
</dd> |
||||
<dd class="govuk-summary-list__actions"> |
||||
<%= create_update_answer_link(@case_log[question_title], @case_log.id, page)%> |
||||
</dd> |
||||
</div> |
||||
</dl> |
||||
<div class="govuk-summary-list__row"> |
||||
<dt class="govuk-summary-list__key"> |
||||
<%= question_info["check_answer_label"].to_s.present? ? question_info["check_answer_label"].to_s : question_info["header"].to_s%> |
||||
<dt> |
||||
<dd class="govuk-summary-list__value"> |
||||
<%= form.get_answer_label(@case_log, question_title) %> |
||||
</dd> |
||||
<dd class="govuk-summary-list__actions"> |
||||
<%= create_update_answer_link(question_title, question_info, @case_log, form) %> |
||||
</dd> |
||||
</div> |
||||
|
@ -0,0 +1,12 @@
|
||||
### ADR - 009: Form Routing Logic |
||||
|
||||
There are 2 ways you can think about form (page) routing logic: |
||||
|
||||
1. Based on the answer you give to a page you are navigated to some point in the form, i.e. a "Jump to" |
||||
2. Each question is considered sequentially and independently and we evaluate whether it should be shown or not |
||||
|
||||
Our Form Definition DSL takes the second approach. This has a couple of advantages: |
||||
|
||||
- It makes the check answers pattern easier to code as you can ask each page directly: "Have the conditions for you to be shown been met?", with approach 1, you would effectively have to traverse the full route branch to see if a particular page was shown for each page/question which adds complexity. |
||||
|
||||
- It makes it easier to look at the JSON and see at a glance what conditions will show or hide a page, which is closer to how the business logic is discussed and is easier to reason about. |
Loading…
Reference in new issue