Browse Source

Add the bottom guidance partial (#788)

pull/794/head
Stéphane Meny 2 years ago committed by GitHub
parent
commit
e97bffb54f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      app/models/form/question.rb
  2. 2
      app/models/form/setup/questions/scheme_id.rb
  3. 4
      app/views/form/_checkbox_question.html.erb
  4. 4
      app/views/form/_date_question.html.erb
  5. 4
      app/views/form/_numeric_output_question.html.erb
  6. 4
      app/views/form/_numeric_question.html.erb
  7. 4
      app/views/form/_radio_question.html.erb
  8. 4
      app/views/form/_select_question.html.erb
  9. 4
      app/views/form/_text_question.html.erb
  10. 4
      app/views/form/_textarea_question.html.erb
  11. 5
      app/views/form/guidance/_scheme_selection.html.erb

14
app/models/form/question.rb

@ -5,6 +5,11 @@ class Form::Question
:inferred_answers, :hidden_in_check_answers, :inferred_check_answers_value,
:guidance_partial, :prefix, :suffix, :requires_js, :fields_added, :derived
module GuidancePosition
TOP = 1
BOTTOM = 2
end
def initialize(id, hsh, page)
@id = id
@page = page
@ -12,6 +17,7 @@ class Form::Question
@check_answer_label = hsh["check_answer_label"]
@header = hsh["header"]
@guidance_partial = hsh["guidance_partial"]
@guidance_position = GuidancePosition::TOP
@hint_text = hsh["hint_text"]
@type = hsh["type"]
@min = hsh["min"]
@ -238,6 +244,14 @@ class Form::Question
case_log[id].to_s == answer.id.to_s
end
def top_guidance?
@guidance_partial && @guidance_position == GuidancePosition::TOP
end
def bottom_guidance?
@guidance_partial && @guidance_position == GuidancePosition::BOTTOM
end
private
def selected_answer_option_is_derived?(case_log)

2
app/models/form/setup/questions/scheme_id.rb

@ -7,6 +7,8 @@ class Form::Setup::Questions::SchemeId < ::Form::Question
@type = "select"
@answer_options = answer_options
@derived = true unless FeatureToggle.supported_housing_schemes_enabled?
@guidance_position = GuidancePosition::BOTTOM
@guidance_partial = "scheme_selection"
end
def answer_options

4
app/views/form/_checkbox_question.html.erb

@ -1,4 +1,4 @@
<%= render partial: "form/guidance/#{question.guidance_partial}" if question.guidance_partial %>
<%= render partial: "form/guidance/#{question.guidance_partial}" if question.top_guidance? %>
<%= f.govuk_check_boxes_fieldset question.id.to_sym,
caption: caption(caption_text, page_header, conditional),
@ -20,3 +20,5 @@
<% end %>
<% end %>
<% end %>
<%= render partial: "form/guidance/#{question.guidance_partial}" if question.bottom_guidance? %>

4
app/views/form/_date_question.html.erb

@ -1,4 +1,4 @@
<%= render partial: "form/guidance/#{question.guidance_partial}" if question.guidance_partial %>
<%= render partial: "form/guidance/#{question.guidance_partial}" if question.top_guidance? %>
<%= f.govuk_date_field question.id.to_sym,
caption: caption(caption_text, page_header, conditional),
@ -6,3 +6,5 @@
hint: { text: question.hint_text&.html_safe || "For example, 1 9 2022." },
width: 20,
**stimulus_html_attributes(question) %>
<%= render partial: "form/guidance/#{question.guidance_partial}" if question.bottom_guidance? %>

4
app/views/form/_numeric_output_question.html.erb

@ -1,4 +1,4 @@
<%= render partial: "form/guidance/#{question.guidance_partial}" if question.guidance_partial %>
<%= render partial: "form/guidance/#{question.guidance_partial}" if question.top_guidance? %>
<div class="govuk-form-group">
<label class="govuk-label govuk-label--<%= label_size(page_header, conditional) %>" for="case-log-<%= question.id %>-field">
@ -20,3 +20,5 @@
<span class="govuk-input__suffix"><%= question.suffix_label(case_log) %></span>
</div>
</div>
<%= render partial: "form/guidance/#{question.guidance_partial}" if question.bottom_guidance? %>

4
app/views/form/_numeric_question.html.erb

@ -1,4 +1,4 @@
<%= render partial: "form/guidance/#{question.guidance_partial}" if question.guidance_partial %>
<%= render partial: "form/guidance/#{question.guidance_partial}" if question.top_guidance? %>
<%= f.govuk_number_field question.id.to_sym,
caption: caption(caption_text, page_header, conditional),
@ -10,3 +10,5 @@
prefix_text: question.prefix.to_s,
suffix_text: question.suffix_label(@case_log),
**stimulus_html_attributes(question) %>
<%= render partial: "form/guidance/#{question.guidance_partial}" if question.bottom_guidance? %>

4
app/views/form/_radio_question.html.erb

@ -1,4 +1,4 @@
<%= render partial: "form/guidance/#{question.guidance_partial}" if question.guidance_partial %>
<%= render partial: "form/guidance/#{question.guidance_partial}" if question.top_guidance? %>
<%= f.govuk_radio_buttons_fieldset question.id.to_sym,
caption: caption(caption_text, page_header, conditional),
@ -34,3 +34,5 @@
<% end %>
<% end %>
<% end %>
<%= render partial: "form/guidance/#{question.guidance_partial}" if question.bottom_guidance? %>

4
app/views/form/_select_question.html.erb

@ -1,4 +1,4 @@
<%= render partial: "form/guidance/#{question.guidance_partial}" if question.guidance_partial %>
<%= render partial: "form/guidance/#{question.guidance_partial}" if question.top_guidance? %>
<% selected = @case_log.public_send(question.id) || "" %>
<% answers = question.displayed_answer_options(@case_log).map { |key, value| OpenStruct.new(id: key, name: value.respond_to?(:service_name) ? value.service_name : nil, resource: value) } %>
@ -16,3 +16,5 @@
<%= answer.id == "" ? "disabled" : "" %>><%= answer.name || answer.resource %></option>
<% end %>
<% end %>
<%= render partial: "form/guidance/#{question.guidance_partial}" if question.bottom_guidance? %>

4
app/views/form/_text_question.html.erb

@ -1,4 +1,4 @@
<%= render partial: "form/guidance/#{question.guidance_partial}" if question.guidance_partial %>
<%= render partial: "form/guidance/#{question.guidance_partial}" if question.top_guidance? %>
<%= f.govuk_text_field question.id.to_sym,
caption: caption(caption_text, page_header, conditional),
@ -6,3 +6,5 @@
hint: { text: question.hint_text&.html_safe },
width: question.width || nil,
**stimulus_html_attributes(question) %>
<%= render partial: "form/guidance/#{question.guidance_partial}" if question.bottom_guidance? %>

4
app/views/form/_textarea_question.html.erb

@ -1,4 +1,4 @@
<%= render partial: "form/guidance/#{question.guidance_partial}" if question.guidance_partial %>
<%= render partial: "form/guidance/#{question.guidance_partial}" if question.top_guidance? %>
<%= f.govuk_text_area question.id.to_sym,
caption: caption(caption_text, page_header, conditional),
@ -6,3 +6,5 @@
hint: { text: question.hint_text&.html_safe },
width: question.width || nil,
**stimulus_html_attributes(question) %>
<%= render partial: "form/guidance/#{question.guidance_partial}" if question.bottom_guidance? %>

5
app/views/form/guidance/_scheme_selection.html.erb

@ -0,0 +1,5 @@
<% if current_user.data_provider? %>
<p class="govuk-body">If you can’t find the supported housing service you’re looking for or not sure which to choose, contact a data coordinator at <%= current_user.organisation.name %>.</p>
<% elsif current_user.data_coordinator? %>
<p class="govuk-body">or <%= govuk_link_to "create a new supported housing service", new_scheme_path %></p>
<% end %>
Loading…
Cancel
Save