Browse Source

select options in the view

juris_katrina_test
JG 2 years ago
parent
commit
c01703eb2b
  1. 26
      app/models/scheme.rb
  2. 6
      app/views/schemes/details.html.erb
  3. 6
      app/views/schemes/new.html.erb
  4. 13
      app/views/schemes/support.html.erb

26
app/models/scheme.rb

@ -151,30 +151,4 @@ class Scheme < ApplicationRecord
{ name: "Intended length of stay", value: intended_stay }, { name: "Intended length of stay", value: intended_stay },
] ]
end end
def care_acts_options_with_hints
hints = { "Yes – part registered as a care home": "A proportion of units are registered as being a care home." }
Scheme.registered_under_care_acts.keys.map { |key, _| OpenStruct.new(id: key, name: key.to_s.humanize, description: hints[key.to_sym]) }
end
def support_level_options_with_hints
hints = {
"Low level": "Staff visiting once a week, fortnightly or less.",
"Medium level": "Staff on site daily or making frequent visits with some out-of-hours cover.",
"High level": "Intensive level of staffing provided on a 24-hour basis.",
}
Scheme.support_types.keys.excluding("Missing").map { |key, _| OpenStruct.new(id: key, name: key.to_s.humanize, description: hints[key.to_sym]) }
end
def intended_length_of_stay_options_with_hints
hints = {
"Very short stay": "Up to one month.",
"Short stay": "Up to one year.",
"Medium stay": "More than one year but with an expectation to move on.",
"Permanent": "Provides a home for life with no requirement for the tenant to move.",
}
Scheme.intended_stays.keys.excluding("Missing").map { |key, _| OpenStruct.new(id: key, name: key.to_s.humanize, description: hints[key.to_sym]) }
end
end end

6
app/views/schemes/details.html.erb

@ -40,8 +40,12 @@
:name, :name,
legend: { text: "What is this type of scheme?", size: "m" } %> legend: { text: "What is this type of scheme?", size: "m" } %>
<% care_acts_options_hints = { "Yes – part registered as a care home": "A proportion of units are registered as being a care home." } %>
<% care_acts_options_with_hints = Scheme.registered_under_care_acts.keys.map { |key, _| OpenStruct.new(id: key, name: key.to_s.humanize, description: care_acts_options_hints[key.to_sym]) } %>
<%= f.govuk_collection_radio_buttons :registered_under_care_act, <%= f.govuk_collection_radio_buttons :registered_under_care_act,
@scheme.care_acts_options_with_hints, care_acts_options_with_hints,
:id, :id,
:name, :name,
:description, :description,

6
app/views/schemes/new.html.erb

@ -44,8 +44,12 @@
:name, :name,
legend: { text: "What is this type of scheme?", size: "m" } %> legend: { text: "What is this type of scheme?", size: "m" } %>
<% care_acts_options_hints = { "Yes – part registered as a care home": "A proportion of units are registered as being a care home." } %>
<% care_acts_options_with_hints = Scheme.registered_under_care_acts.keys.map { |key, _| OpenStruct.new(id: key, name: key.to_s.humanize, description: care_acts_options_hints[key.to_sym]) } %>
<%= f.govuk_collection_radio_buttons :registered_under_care_act, <%= f.govuk_collection_radio_buttons :registered_under_care_act,
@scheme.care_acts_options_with_hints, care_acts_options_with_hints,
:id, :id,
:name, :name,
:description, :description,

13
app/views/schemes/support.html.erb

@ -14,17 +14,24 @@
<div class="govuk-grid-column-two-thirds"> <div class="govuk-grid-column-two-thirds">
<%= f.govuk_error_summary %> <%= f.govuk_error_summary %>
<% support_level_options_hints = { "Low level": "Staff visiting once a week, fortnightly or less.", "Medium level": "Staff on site daily or making frequent visits with some out-of-hours cover.", "High level": "Intensive level of staffing provided on a 24-hour basis." } %>
<% support_level_options_with_hints = Scheme.support_types.keys.excluding("Missing").map { |key, _| OpenStruct.new(id: key, name: key.to_s.humanize, description: support_level_options_hints[key.to_sym]) } %>
<%= f.govuk_collection_radio_buttons :support_type, <%= f.govuk_collection_radio_buttons :support_type,
@scheme.support_level_options_with_hints, support_level_options_with_hints,
:id, :id,
:name, :name,
:description, :description,
legend: { text: "Level of support given", size: "m" }, legend: { text: "Level of support given", size: "m" },
bold_labels: false %> bold_labels: false %>
<% intended_stay_selection = Scheme.intended_stays.keys.excluding("Missing").map { |key, _| OpenStruct.new(id: key, name: key.to_s.humanize) } %> <% intended_length_of_stay_options_hints = { "Very short stay": "Up to one month.", "Short stay": "Up to one year.", "Medium stay": "More than one year but with an expectation to move on.", "Permanent": "Provides a home for life with no requirement for the tenant to move." } %>
<% intended_length_of_stay_options_with_hints = Scheme.intended_stays.keys.excluding("Missing").map { |key, _| OpenStruct.new(id: key, name: key.to_s.humanize, description: intended_length_of_stay_options_hints[key.to_sym]) } %>
<%= f.govuk_collection_radio_buttons :intended_stay, <%= f.govuk_collection_radio_buttons :intended_stay,
@scheme.intended_length_of_stay_options_with_hints, intended_length_of_stay_options_with_hints,
:id, :id,
:name, :name,
:description, :description,

Loading…
Cancel
Save