Browse Source

using type of units

pull/704/head
JG 3 years ago
parent
commit
7bd54370cf
  1. 11
      app/models/location.rb
  2. 17
      app/views/locations/new.html.erb
  3. 12
      db/seeds.rb

11
app/models/location.rb

@ -8,6 +8,17 @@ class Location < ApplicationRecord
enum wheelchair_adaptation: WHEELCHAIR_ADAPTATIONS 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 def display_attributes
[ [
{ name: "Location code ", value: location_code, suffix: false }, { name: "Location code ", value: location_code, suffix: false },

17
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" }, 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 %> autofocus: true %>
<%= f.govuk_collection_radio_buttons :scheme_type, <% type_of_units_selection = Location.type_of_units.keys.map { |key, _| OpenStruct.new(id: key, name: key.to_s.humanize) } %>
scheme_types_selection,
<%= f.govuk_collection_radio_buttons :type_of_unit,
type_of_units_selection,
:id, :id,
:name, :name,
legend: { text: "What is this type of scheme?", size: "m" } %> 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" %> <%= f.govuk_submit "Save and continue" %>
</div> </div>
</div> </div>

12
db/seeds.rb

@ -114,7 +114,9 @@ unless Rails.env.test?
location_code: "S254-CU193AA", location_code: "S254-CU193AA",
postcode: "CU19 3AA", postcode: "CU19 3AA",
name: "Rectory Road", 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", type_of_building: "Purpose-built",
county: "Mid Sussex", county: "Mid Sussex",
wheelchair_adaptation: 0, wheelchair_adaptation: 0,
@ -125,7 +127,9 @@ unless Rails.env.test?
location_code: "S254-DM250DC", location_code: "S254-DM250DC",
postcode: "DM25 0DC", postcode: "DM25 0DC",
name: "Smithy Lane", 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", type_of_building: "Converted from previous residential or non-residential property",
county: "Fife", county: "Fife",
wheelchair_adaptation: 1, wheelchair_adaptation: 1,
@ -136,7 +140,9 @@ unless Rails.env.test?
location_code: "S254-YX130WP", location_code: "S254-YX130WP",
postcode: "YX13 0WP", postcode: "YX13 0WP",
name: "Smithy Lane", 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", type_of_building: "Converted from previous residential or non-residential property",
county: "Rochford", county: "Rochford",
wheelchair_adaptation: 1, wheelchair_adaptation: 1,

Loading…
Cancel
Save