baarkerlounger
3 years ago
12 changed files with 77 additions and 65 deletions
@ -0,0 +1,24 @@ |
|||||||
|
class FormController < ApplicationController |
||||||
|
|
||||||
|
FIRST_QUESTION_FOR_SUBSECTION = { |
||||||
|
"Household characteristics" => "case_logs/household/tenant_code", |
||||||
|
} |
||||||
|
|
||||||
|
NEXT_QUESTION = { |
||||||
|
"tenant_code" => "case_logs/household/tenant_age", |
||||||
|
"tenant_age" => "case_logs/household/tenant_gender", |
||||||
|
"tenant_gender" => "case_logs/household/tenant_ethnic_group", |
||||||
|
"tenant_ethnic_group" => "case_logs/household/tenant_nationality" |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
def next_question |
||||||
|
subsection = params[:subsection] |
||||||
|
result = if subsection |
||||||
|
FIRST_QUESTION_FOR_SUBSECTION[subsection] |
||||||
|
else |
||||||
|
NEXT_QUESTION[params[:previous_question]] |
||||||
|
end |
||||||
|
render result |
||||||
|
end |
||||||
|
end |
@ -1,16 +1,18 @@ |
|||||||
<div class="govuk-grid-row"> |
<%= turbo_frame_tag "case_log_form" do %> |
||||||
<div class="govuk-grid-column-two-thirds"> |
<div class="govuk-grid-row"> |
||||||
<h1 class="govuk-heading-xl">Tasklist for log |
<div class="govuk-grid-column-two-thirds"> |
||||||
<%= @case_log.id %></h1> |
<h1 class="govuk-heading-xl">Tasklist for log |
||||||
|
<%= @case_log.id %></h1> |
||||||
|
|
||||||
<h2 class="govuk-heading-s govuk-!-margin-bottom-2">This submission is |
<h2 class="govuk-heading-s govuk-!-margin-bottom-2">This submission is |
||||||
<%= @case_log.status %></h2> |
<%= @case_log.status %></h2> |
||||||
<p class="govuk-body govuk-!-margin-bottom-7">You've completed 0 of 9 sections.</p> |
<p class="govuk-body govuk-!-margin-bottom-7">You've completed 0 of 9 sections.</p> |
||||||
<p class="govuk-body govuk-!-margin-bottom-7"> |
<p class="govuk-body govuk-!-margin-bottom-7"> |
||||||
<a href="#">Skip to next incomplete section</a> |
<a href="#">Skip to next incomplete section</a> |
||||||
</p> |
</p> |
||||||
|
|
||||||
<%= render "tasklist" %> |
<%= render "tasklist" %> |
||||||
|
|
||||||
|
</div> |
||||||
</div> |
</div> |
||||||
</div> |
<% end %> |
||||||
|
@ -1,8 +1,11 @@ |
|||||||
<%= form_with model: @case_log, method: "patch", builder: GOVUKDesignSystemFormBuilder::FormBuilder do |f| %> |
<%= turbo_frame_tag "case_log_form" do %> |
||||||
|
<%= form_with action: '/form', method: "next_question", builder: GOVUKDesignSystemFormBuilder::FormBuilder do |f| %> |
||||||
<%= f.govuk_number_field :tenant_age, |
<%= f.govuk_number_field :tenant_age, |
||||||
hint: { text: "More detail" }, |
hint: { text: "More detail" }, |
||||||
label: { text: "What is the tenant's age?", size: "l"}, |
label: { text: "What is the tenant's age?", size: "l"}, |
||||||
min: 0, max: 150, step: 1, width: 20 |
min: 0, max: 150, step: 1, width: 20 |
||||||
%> |
%> |
||||||
|
<%= f.hidden_field :previous_question, value: :tenant_age %> |
||||||
<%= f.govuk_submit "Save and continue" %> |
<%= f.govuk_submit "Save and continue" %> |
||||||
<% end %> |
<% end %> |
||||||
|
<% end %> |
||||||
|
@ -1,8 +1,11 @@ |
|||||||
<%= form_with model: @case_log, method: "patch", builder: GOVUKDesignSystemFormBuilder::FormBuilder do |f| %> |
<%= turbo_frame_tag "case_log_form" do %> |
||||||
<%= f.govuk_text_field :tenant_code, |
<%= form_with action: '/form', method: "next_question", builder: GOVUKDesignSystemFormBuilder::FormBuilder do |f| %> |
||||||
hint: { text: "More detail" }, |
<%= f.govuk_text_field :tenant_code, |
||||||
label: { text: "What is the tenant code?", size: "l"}, |
hint: { text: "More detail" }, |
||||||
width: 20 |
label: { text: "What is the tenant code?", size: "l"}, |
||||||
%> |
width: 20 |
||||||
<%= f.govuk_submit "Save and continue" %> |
%> |
||||||
<% end %> |
<%= f.hidden_field :previous_question, value: :tenant_code %> |
||||||
|
<%= f.govuk_submit "Save and continue" %> |
||||||
|
<% end %> |
||||||
|
<% end %> |
||||||
|
@ -1,16 +0,0 @@ |
|||||||
<div class="govuk-grid-row"> |
|
||||||
<div class="govuk-grid-column-two-thirds"> |
|
||||||
<h1 class="govuk-heading-xl">Tasklist for log |
|
||||||
<%= @case_log.id %></h1> |
|
||||||
|
|
||||||
<h2 class="govuk-heading-s govuk-!-margin-bottom-2">This submission is |
|
||||||
<%= @case_log.status %></h2> |
|
||||||
<p class="govuk-body govuk-!-margin-bottom-7">You've completed 0 of 9 sections.</p> |
|
||||||
<p class="govuk-body govuk-!-margin-bottom-7"> |
|
||||||
<a href="#">Skip to next incomplete section</a> |
|
||||||
</p> |
|
||||||
|
|
||||||
<%= render "tasklist" %> |
|
||||||
|
|
||||||
</div> |
|
||||||
</div> |
|
Loading…
Reference in new issue