From bd80041e41911758225c049619f40c408e251afd Mon Sep 17 00:00:00 2001 From: Kat Date: Thu, 17 Nov 2022 14:40:50 +0000 Subject: [PATCH] Render correct reactivate question content --- app/views/locations/toggle_active.html.erb | 23 ++++++++++++---------- config/locales/en.yml | 8 +++++--- config/routes.rb | 1 + spec/features/schemes_spec.rb | 3 +++ 4 files changed, 22 insertions(+), 13 deletions(-) diff --git a/app/views/locations/toggle_active.html.erb b/app/views/locations/toggle_active.html.erb index 6d2f4a9ba..321ee8665 100644 --- a/app/views/locations/toggle_active.html.erb +++ b/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 :before_content do %> @@ -7,26 +7,29 @@ href: scheme_location_path(@location.scheme, @location), ) %> <% 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| %>
<% 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_radio_buttons_fieldset :deactivation_date_type, - legend: { text: I18n.t("questions.location.deactivation.apply_from") }, - caption: { text: "Deactivate #{@location.postcode}" }, - hint: { text: I18n.t("hints.location.deactivation", date: collection_start_date.to_formatted_s(:govuk_date)) } do %> - <%= govuk_warning_text text: I18n.t("warnings.location.deactivation.existing_logs") %> - <%= f.govuk_radio_button :deactivation_date_type, + <%= f.govuk_radio_buttons_fieldset date_type_question, + legend: { text: I18n.t("questions.location.deactivate.apply_from") }, + caption: { text: title }, + 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.#{action}.existing_logs") %> + <%= f.govuk_radio_button date_type_question, "default", 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", label: { text: "For tenancies starting after a certain date" }, **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" }, hint: { text: "For example, 27 3 2022" }, width: 20 %> diff --git a/config/locales/en.yml b/config/locales/en.yml index a1c18330a..6d335d4dd 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -374,7 +374,7 @@ en: 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?" mobility_type: "What are the mobility standards for the majority of units in this location?" - deactivation: + deactivate: apply_from: "When should this change apply?" scheme: deactivation: @@ -391,15 +391,17 @@ en: postcode: "For example, SW1P 4DF." 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." - 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: deactivation: "If the date is before %{date}, select ‘From the start of the current collection period’ because the previous period has now closed." warnings: 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." 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: 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." diff --git a/config/routes.rb b/config/routes.rb index 97c7c56bf..bc2e26ad9 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -64,6 +64,7 @@ Rails.application.routes.draw do get "new-reactivation", to: "locations#new_reactivation" patch "new-deactivation", to: "locations#new_deactivation" patch "deactivate", to: "locations#deactivate" + patch "new-reactivation", to: "locations#new_reactivation" end end diff --git a/spec/features/schemes_spec.rb b/spec/features/schemes_spec.rb index 59f7b8008..17da1849d 100644 --- a/spec/features/schemes_spec.rb +++ b/spec/features/schemes_spec.rb @@ -777,6 +777,9 @@ RSpec.describe "Schemes scheme Features" do it "allows to reactivate a location" do click_link("Reactivate this location") 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 context "when I press the back button" do