From efb6a32c9dcc11674f855a29baf785beff6bf1b0 Mon Sep 17 00:00:00 2001 From: JG Date: Thu, 30 Jun 2022 13:06:55 +0100 Subject: [PATCH] changed type of unit type in db --- app/controllers/locations_controller.rb | 2 +- app/views/locations/new.html.erb | 11 +++++++++++ .../20220630120251_change_location_type_of_unit.rb | 6 ++++++ db/schema.rb | 2 +- 4 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20220630120251_change_location_type_of_unit.rb diff --git a/app/controllers/locations_controller.rb b/app/controllers/locations_controller.rb index 507c4c68a..6a8a8b499 100644 --- a/app/controllers/locations_controller.rb +++ b/app/controllers/locations_controller.rb @@ -3,7 +3,7 @@ class LocationsController < ApplicationController before_action :authenticate_scope! def new - @scheme = Scheme.find(12) + @scheme = Scheme.find(params[:id]) @location = Location.new end diff --git a/app/views/locations/new.html.erb b/app/views/locations/new.html.erb index fd7385f0c..27740ab98 100644 --- a/app/views/locations/new.html.erb +++ b/app/views/locations/new.html.erb @@ -23,6 +23,17 @@ label: { text: "Name (optional)", size: "m" }, hint: { text: "This is how you refer to this location within your organisation" } %> + <%= f.govuk_number_field :total_units, + label: { text: "Total number of units at this location", size: "m" }, + width: 2, + 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, + :id, + :name, + legend: { text: "What is this type of scheme?", size: "m" } %> <%= f.govuk_submit "Save and continue" %> diff --git a/db/migrate/20220630120251_change_location_type_of_unit.rb b/db/migrate/20220630120251_change_location_type_of_unit.rb new file mode 100644 index 000000000..644b3871a --- /dev/null +++ b/db/migrate/20220630120251_change_location_type_of_unit.rb @@ -0,0 +1,6 @@ +class ChangeLocationTypeOfUnit < ActiveRecord::Migration[7.0] + def change + remove_column :locations, :type_of_unit + add_column :locations, :type_of_unit, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index 048b77ba7..018085d90 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -239,7 +239,6 @@ ActiveRecord::Schema[7.0].define(version: 2022_07_04_135746) do create_table "locations", force: :cascade do |t| t.string "location_code" t.string "postcode" - t.string "type_of_unit" t.string "type_of_building" t.integer "wheelchair_adaptation" t.bigint "scheme_id", null: false @@ -249,6 +248,7 @@ ActiveRecord::Schema[7.0].define(version: 2022_07_04_135746) do t.datetime "updated_at", null: false t.string "name" t.integer "total_units" + t.integer "type_of_unit" t.index ["scheme_id"], name: "index_locations_on_scheme_id" end