Browse Source

feat: wip add new flow

pull/1034/head
natdeanlewissoftwire 4 years ago
parent
commit
533e214b89
  1. 16
      app/controllers/locations_controller.rb
  2. 4
      app/models/location.rb
  3. 30
      app/views/locations/mobility_standards.html.erb
  4. 27
      app/views/locations/name.html.erb
  5. 6
      app/views/locations/postcode.html.erb
  6. 28
      app/views/locations/startdate.html.erb
  7. 29
      app/views/locations/type_of_unit.html.erb
  8. 29
      app/views/locations/units.html.erb
  9. 10
      config/locales/en.yml
  10. 13
      config/routes.rb

16
app/controllers/locations_controller.rb

@ -15,9 +15,23 @@ class LocationsController < ApplicationController
end end
def new def new
@location = Location.new @location = Location.new(scheme_id: @scheme.id)
@location.save!
redirect_to scheme_location_postcode_path(@scheme, @location)
end end
def postcode; end
def name; end
def type_of_unit; end
def mobility_standards; end
def startdate; end
def check_answers; end
def show; end def show; end
def new_deactivation def new_deactivation

4
app/models/location.rb

@ -1,6 +1,6 @@
class Location < ApplicationRecord class Location < ApplicationRecord
validate :validate_postcode # validate :validate_postcode
validates :units, :type_of_unit, :mobility_type, presence: true # validates :units, :type_of_unit, :mobility_type, presence: true
belongs_to :scheme belongs_to :scheme
has_many :lettings_logs, class_name: "LettingsLog" has_many :lettings_logs, class_name: "LettingsLog"
has_many :location_deactivation_periods, class_name: "LocationDeactivationPeriod" has_many :location_deactivation_periods, class_name: "LocationDeactivationPeriod"

30
app/views/locations/mobility_standards.html.erb

@ -0,0 +1,30 @@
<% content_for :title, "Add a location to this scheme" %>
<% content_for :before_content do %>
<%= govuk_back_link(
text: "Back",
href: "/schemes/#{@scheme.id}/support",
) %>
<% end %>
<%= form_for(@location, method: :patch, url: scheme_location_startdate_path(@scheme, @location)) do |f| %>
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<%= f.govuk_error_summary %>
<%= render partial: "organisations/headings", locals: { main: I18n.t("questions.location.mobility_type"), sub: "Add a location to #{@scheme.service_name}" } %>
<%= f.govuk_collection_radio_buttons :mobility_type,
mobility_type_selection,
:id,
:name,
:description,
legend: nil %>
<div class="govuk-button-group">
<%= f.govuk_submit "Continue" %>
<%= govuk_link_to "Cancel", new_scheme_location_path(@scheme) %>
</div>
</div>
</div>
<% end %>

27
app/views/locations/name.html.erb

@ -0,0 +1,27 @@
<% content_for :title, "Add a location to this scheme" %>
<% content_for :before_content do %>
<%= govuk_back_link(
text: "Back",
href: "/schemes/#{@scheme.id}/support",
) %>
<% end %>
<%= form_for(@location, method: :patch, url: scheme_location_units_path(@scheme, @location)) do |f| %>
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<%= f.govuk_error_summary %>
<%= render partial: "organisations/headings", locals: { main: I18n.t("questions.location.name"), sub: "Add a location to #{@scheme.service_name}" } %>
<%= f.govuk_text_field :name,
label: nil,
hint: { text: I18n.t("hints.location.name") } %>
<div class="govuk-button-group">
<%= f.govuk_submit "Continue" %>
<%= govuk_link_to "Cancel", new_scheme_location_path(@scheme) %>
</div>
</div>
</div>
<% end %>

6
app/views/locations/postcode.html.erb

@ -7,12 +7,12 @@
) %> ) %>
<% end %> <% end %>
<%= form_for(@location, method: :post, url: scheme_locations_path) do |f| %> <%= form_for(@location, method: :patch, url: scheme_location_name_path(@scheme, @location)) do |f| %>
<div class="govuk-grid-row"> <div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds"> <div class="govuk-grid-column-two-thirds">
<%= f.govuk_error_summary %> <%= f.govuk_error_summary %>
<%= render partial: "organisations/headings", locals: { main: "What is the postcode?", sub: "Add a location to #{@scheme.service_name}" } %> <%= render partial: "organisations/headings", locals: { main: I18n.t("questions.location.postcode"), sub: "Add a location to #{@scheme.service_name}" } %>
<%= f.govuk_text_field :postcode, <%= f.govuk_text_field :postcode,
label: { size: "m" }, label: { size: "m" },
@ -21,7 +21,7 @@
<div class="govuk-button-group"> <div class="govuk-button-group">
<%= f.govuk_submit "Continue" %> <%= f.govuk_submit "Continue" %>
<%= govuk_link_to "Cancel", scheme_locations_path(@scheme) %> <%= govuk_link_to "Cancel", new_scheme_location_path(@scheme) %>
</div> </div>
</div> </div>
</div> </div>

28
app/views/locations/startdate.html.erb

@ -0,0 +1,28 @@
<% content_for :title, "Add a location to this scheme" %>
<% content_for :before_content do %>
<%= govuk_back_link(
text: "Back",
href: "/schemes/#{@scheme.id}/support",
) %>
<% end %>
<%= form_for(@location, method: :patch, url: scheme_location_check_answers_path(@scheme, @location)) do |f| %>
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<%= f.govuk_error_summary %>
<%= render partial: "organisations/headings", locals: { main: I18n.t("questions.location.startdate"), sub: "Add a location to #{@scheme.service_name}" } %>
<%= f.govuk_date_field :startdate,
hint: { text: I18n.t("hints.location.startdate") },
legend: nil,
width: 20 %>
<div class="govuk-button-group">
<%= f.govuk_submit "Continue" %>
<%= govuk_link_to "Cancel", new_scheme_location_path(@scheme) %>
</div>
</div>
</div>
<% end %>

29
app/views/locations/type_of_unit.html.erb

@ -0,0 +1,29 @@
<% content_for :title, "Add a location to this scheme" %>
<% content_for :before_content do %>
<%= govuk_back_link(
text: "Back",
href: "/schemes/#{@scheme.id}/support",
) %>
<% end %>
<%= form_for(@location, method: :patch, url: scheme_location_mobility_standards_path(@scheme, @location)) do |f| %>
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<%= f.govuk_error_summary %>
<%= render partial: "organisations/headings", locals: { main: I18n.t("questions.location.type_of_unit"), sub: "Add a location to #{@scheme.service_name}" } %>
<%= f.govuk_collection_radio_buttons :type_of_unit,
type_of_units_selection,
:id,
:name,
legend: nil %>
<div class="govuk-button-group">
<%= f.govuk_submit "Continue" %>
<%= govuk_link_to "Cancel", new_scheme_location_path(@scheme) %>
</div>
</div>
</div>
<% end %>

29
app/views/locations/units.html.erb

@ -0,0 +1,29 @@
<% content_for :title, "Add a location to this scheme" %>
<% content_for :before_content do %>
<%= govuk_back_link(
text: "Back",
href: "/schemes/#{@scheme.id}/support",
) %>
<% end %>
<%= form_for(@location, method: :patch, url: scheme_location_type_of_unit_path(@scheme, @location)) do |f| %>
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<%= f.govuk_error_summary %>
<%= render partial: "organisations/headings", locals: { main: I18n.t("questions.location.units"), sub: "Add a location to #{@scheme.service_name}" } %>
<%= f.govuk_number_field :units,
label: nil,
width: 2,
hint: { text: I18n.t("hints.location.units") },
autofocus: true %>
<div class="govuk-button-group">
<%= f.govuk_submit "Continue" %>
<%= govuk_link_to "Cancel", new_scheme_location_path(@scheme) %>
</div>
</div>
</div>
<% end %>

10
config/locales/en.yml

@ -372,10 +372,11 @@ en:
questions: questions:
location: location:
name: "Location name (optional)" postcode: "What is the postcode?"
units: "Total number of units at this location" name: "What is the name of this location?"
units: "How many units are at this location?"
type_of_unit: "What is the most common type of unit at this location?" type_of_unit: "What is the most common type of unit at this location?"
startdate: "When did the first property in this location become available under this scheme? (optional)" startdate: "When did the first property in this location become available under this scheme?"
add_another_location: "Do you want to add another location?" add_another_location: "Do you want to add another location?"
mobility_type: "What are the mobility standards for the majority of units in this location?" mobility_type: "What are the mobility standards for the majority of units in this location?"
toggle_active: toggle_active:
@ -394,8 +395,9 @@ en:
location: location:
postcode: "For example, SW1P 4DF." postcode: "For example, SW1P 4DF."
name: "This is how you refer to this location within your organisation" name: "This is how you refer to this location within your organisation"
units: "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." units: "A unit is the space being let. For example, the property might be a block of flats and the unit would be the specific flat being let. A unit can also be a bedroom in a shared house or flat. Do not include spaces used for staff."
toggle_active: "If the date is before %{date}, select ‘From the start of the current collection period’ because the previous period has now closed." toggle_active: "If the date is before %{date}, select ‘From the start of the current collection period’ because the previous period has now closed."
startdate: "For example, 27 3 2021"
scheme: scheme:
deactivation: "If the date is before %{date}, select ‘From the start of the current collection period’ because the previous period has now closed." deactivation: "If the date is before %{date}, select ‘From the start of the current collection period’ because the previous period has now closed."

13
config/routes.rb

@ -62,6 +62,19 @@ Rails.application.routes.draw do
get "deactivate-confirm", to: "locations#deactivate_confirm" get "deactivate-confirm", to: "locations#deactivate_confirm"
get "reactivate", to: "locations#reactivate" get "reactivate", to: "locations#reactivate"
get "new-reactivation", to: "locations#new_reactivation" get "new-reactivation", to: "locations#new_reactivation"
get "postcode", to: "locations#postcode"
get "name", to: "locations#name"
patch "name", to: "locations#name"
get "units", to: "locations#units"
patch "units", to: "locations#units"
get "type-of-unit", to: "locations#type_of_unit"
patch "type-of-unit", to: "locations#type_of_unit"
get "mobility-standards", to: "locations#mobility_standards"
patch "mobility-standards", to: "locations#mobility_standards"
get "startdate", to: "locations#startdate"
patch "startdate", to: "locations#startdate"
get "check-answers", to: "locations#show"
patch "check-answers", to: "locations#show"
patch "new-deactivation", to: "locations#new_deactivation" patch "new-deactivation", to: "locations#new_deactivation"
patch "deactivate", to: "locations#deactivate" patch "deactivate", to: "locations#deactivate"
patch "reactivate", to: "locations#reactivate" patch "reactivate", to: "locations#reactivate"

Loading…
Cancel
Save