Browse Source

Render correct reactivate question content

pull/1007/head
Kat 4 years ago
parent
commit
bd80041e41
  1. 23
      app/views/locations/toggle_active.html.erb
  2. 8
      config/locales/en.yml
  3. 1
      config/routes.rb
  4. 3
      spec/features/schemes_spec.rb

23
app/views/locations/toggle_active.html.erb

@ -1,4 +1,4 @@
<% title = "#{action.humanize} #{@location.postcode}" %> <% title = "#{action.humanize} #{@location.name}" %>
<% content_for :title, title %> <% content_for :title, title %>
<% content_for :before_content do %> <% content_for :before_content do %>
@ -7,26 +7,29 @@
href: scheme_location_path(@location.scheme, @location), href: scheme_location_path(@location.scheme, @location),
) %> ) %>
<% end %> <% end %>
<% form_path = action == "deactivate" ? scheme_location_new_deactivation_path(scheme_id: @location.scheme.id, location_id: @location.id) : scheme_location_new_reactivation_path(scheme_id: @location.scheme.id, location_id: @location.id) %>
<%= form_with model: @location, url: scheme_location_new_deactivation_path(scheme_id: @location.scheme.id, location_id: @location.id), method: "patch", local: true do |f| %> <%= form_with model: @location, url: form_path, method: "patch", local: true 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">
<% collection_start_date = FormHandler.instance.current_collection_start_date %> <% collection_start_date = FormHandler.instance.current_collection_start_date %>
<% date_question = action == "deactivate" ? :deactivation_date : :reactivation_date %>
<% date_type_question = action == "deactivate" ? :deactivation_date_type : :reactivation_date_type %>
<%= f.govuk_error_summary %> <%= f.govuk_error_summary %>
<%= f.govuk_radio_buttons_fieldset :deactivation_date_type, <%= f.govuk_radio_buttons_fieldset date_type_question,
legend: { text: I18n.t("questions.location.deactivation.apply_from") }, legend: { text: I18n.t("questions.location.deactivate.apply_from") },
caption: { text: "Deactivate #{@location.postcode}" }, caption: { text: title },
hint: { text: I18n.t("hints.location.deactivation", date: collection_start_date.to_formatted_s(:govuk_date)) } do %> hint: { text: I18n.t("hints.location.deactivate", date: collection_start_date.to_formatted_s(:govuk_date)) } do %>
<%= govuk_warning_text text: I18n.t("warnings.location.deactivation.existing_logs") %> <%= govuk_warning_text text: I18n.t("warnings.location.#{action}.existing_logs") %>
<%= f.govuk_radio_button :deactivation_date_type, <%= f.govuk_radio_button date_type_question,
"default", "default",
label: { text: "From the start of the current collection period (#{collection_start_date.to_formatted_s(:govuk_date)})" } %> label: { text: "From the start of the current collection period (#{collection_start_date.to_formatted_s(:govuk_date)})" } %>
<%= f.govuk_radio_button :deactivation_date_type, <%= f.govuk_radio_button date_type_question,
"other", "other",
label: { text: "For tenancies starting after a certain date" }, label: { text: "For tenancies starting after a certain date" },
**basic_conditional_html_attributes({ "deactivation_date" => %w[other] }, "location") do %> **basic_conditional_html_attributes({ "deactivation_date" => %w[other] }, "location") do %>
<%= f.govuk_date_field :deactivation_date, <%= f.govuk_date_field date_question,
legend: { text: "Date", size: "m" }, legend: { text: "Date", size: "m" },
hint: { text: "For example, 27 3 2022" }, hint: { text: "For example, 27 3 2022" },
width: 20 %> width: 20 %>

8
config/locales/en.yml

@ -374,7 +374,7 @@ en:
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? (optional)"
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?"
deactivation: deactivate:
apply_from: "When should this change apply?" apply_from: "When should this change apply?"
scheme: scheme:
deactivation: deactivation:
@ -391,15 +391,17 @@ en:
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 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."
deactivation: "If the date is before %{date}, select ‘From the start of the current collection period’ because the previous period has now closed." deactivate: "If the date is before %{date}, select ‘From the start of the current collection period’ because the previous period has now closed."
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."
warnings: warnings:
location: location:
deactivation: deactivate:
existing_logs: "It will not be possible to add logs with this location if their tenancy start date is on or after the date you enter. Any existing logs may be affected." existing_logs: "It will not be possible to add logs with this location if their tenancy start date is on or after the date you enter. Any existing logs may be affected."
review_logs: "Your data providers will need to review these logs and answer a few questions again. We’ll email each log creator with a list of logs that need updating." review_logs: "Your data providers will need to review these logs and answer a few questions again. We’ll email each log creator with a list of logs that need updating."
reactivate:
existing_logs: "You’ll be able to add logs with this location if their tenancy start date is on or after the date you enter."
scheme: scheme:
deactivation: deactivation:
existing_logs: "It will not be possible to add logs with this scheme if their tenancy start date is on or after the date you enter. Any existing logs may be affected." existing_logs: "It will not be possible to add logs with this scheme if their tenancy start date is on or after the date you enter. Any existing logs may be affected."

1
config/routes.rb

@ -64,6 +64,7 @@ Rails.application.routes.draw do
get "new-reactivation", to: "locations#new_reactivation" get "new-reactivation", to: "locations#new_reactivation"
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 "new-reactivation", to: "locations#new_reactivation"
end end
end end

3
spec/features/schemes_spec.rb

@ -777,6 +777,9 @@ RSpec.describe "Schemes scheme Features" do
it "allows to reactivate a location" do it "allows to reactivate a location" do
click_link("Reactivate this location") click_link("Reactivate this location")
expect(page).to have_current_path("/schemes/#{scheme.id}/locations/#{deactivated_location.id}/new-reactivation") expect(page).to have_current_path("/schemes/#{scheme.id}/locations/#{deactivated_location.id}/new-reactivation")
expect(page).to have_content("Reactivate #{deactivated_location.name}")
expect(page).to have_content("You’ll be able to add logs with this location if their tenancy start date is on or after the date you enter.")
expect(page).to have_content("If the date is before 1 April 2022, select ‘From the start of the current collection period’ because the previous period has now closed.")
end end
context "when I press the back button" do context "when I press the back button" do

Loading…
Cancel
Save