From 7bd54370cf552bb9417b3fe2f81c5172312f141a Mon Sep 17 00:00:00 2001 From: JG Date: Thu, 30 Jun 2022 13:36:27 +0100 Subject: [PATCH] using type of units --- app/models/location.rb | 11 +++++++++++ app/views/locations/new.html.erb | 17 +++++++++++++++-- db/seeds.rb | 12 +++++++++--- 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/app/models/location.rb b/app/models/location.rb index d3cc23f82..db4f158e0 100644 --- a/app/models/location.rb +++ b/app/models/location.rb @@ -8,6 +8,17 @@ class Location < ApplicationRecord enum wheelchair_adaptation: WHEELCHAIR_ADAPTATIONS + TYPE_OF_UNIT = { + "Self-contained flat or bedsit": 1, + "Self-contained flat or bedsit with common facilities": 2, + "Shared flat": 3, + "Shared house or hostel": 4, + "Bungalow": 5, + "Self-contained house": 6, + }.freeze + + enum type_of_unit: TYPE_OF_UNIT + def display_attributes [ { name: "Location code ", value: location_code, suffix: false }, diff --git a/app/views/locations/new.html.erb b/app/views/locations/new.html.erb index 27740ab98..54158e875 100644 --- a/app/views/locations/new.html.erb +++ b/app/views/locations/new.html.erb @@ -29,12 +29,25 @@ hint: { text: "A unit can be a bedroom in a shared house or flat, or a house with 4 bedrooms. Do not include bedrooms used for wardens, managers, volunteers or sleep-in staff.s" }, autofocus: true %> - <%= f.govuk_collection_radio_buttons :scheme_type, - scheme_types_selection, + <% type_of_units_selection = Location.type_of_units.keys.map { |key, _| OpenStruct.new(id: key, name: key.to_s.humanize) } %> + + <%= f.govuk_collection_radio_buttons :type_of_unit, + type_of_units_selection, :id, :name, legend: { text: "What is this type of scheme?", size: "m" } %> + <% wheelchair_user_selection = Location.wheelchair_adaptations.keys.map { |key, _| OpenStruct.new(id: key, name: key.to_s.humanize) } %> + + <%= f.govuk_collection_radio_buttons :type_of_unit, + wheelchair_user_selection, + :id, + :name, + hint: { text: "This includes stairlifts, ramps, level-access showers or grab rails" }, + legend: { text: "Are the majority of units in this location built or adapted to wheelchair-user standards?", size: "m" } %> + + <%= govuk_section_break(visible: true, size: "m") %> + <%= f.govuk_submit "Save and continue" %> diff --git a/db/seeds.rb b/db/seeds.rb index 42b26c8c4..968cde114 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -114,7 +114,9 @@ unless Rails.env.test? location_code: "S254-CU193AA", postcode: "CU19 3AA", name: "Rectory Road", - type_of_unit: "Self-contained flat or bedsit", + address_line1: "Rectory Road", + address_line2: "North Chaim", + type_of_unit: 4, type_of_building: "Purpose-built", county: "Mid Sussex", wheelchair_adaptation: 0, @@ -125,7 +127,9 @@ unless Rails.env.test? location_code: "S254-DM250DC", postcode: "DM25 0DC", name: "Smithy Lane", - type_of_unit: "Self-contained flat or bedsit with common facilities", + address_line1: "Smithy Lane", + address_line2: "North Kellieworth", + type_of_unit: 1, type_of_building: "Converted from previous residential or non-residential property", county: "Fife", wheelchair_adaptation: 1, @@ -136,7 +140,9 @@ unless Rails.env.test? location_code: "S254-YX130WP", postcode: "YX13 0WP", name: "Smithy Lane", - type_of_unit: "Shared house or hostel", + address_line1: "Smithy Lane", + address_line2: "East Darwin", + type_of_unit: 2, type_of_building: "Converted from previous residential or non-residential property", county: "Rochford", wheelchair_adaptation: 1,