Browse Source
* add deactivation_date to locations * Change conditional question controller to accommodate all models * UI spike * Update toggle-active views and render them correctly * Display 2 errors * Update errors * Extract text to translation file * Add collection start date * Add out of range validation * Update affected logs label * lint * Add status method * update the displayed status tags * Keep deactivation_date_type selected if an error occurs * refactor deactivation_date_type to use default and other as options instead of 1 and 2 * refactor * refactor * update lettings logs * Add reactivate ocation button and path * Fix controller and update deactivate confirm page * Don't actually update the logs data when deactivating a location * lint and typos * update a path * update current_collection_start_date * Remove unused scopepull/986/head
kosiakkatrina
2 years ago
committed by
GitHub
18 changed files with 396 additions and 12 deletions
@ -0,0 +1,39 @@ |
|||||||
|
<% title = "#{action.humanize} #{@location.postcode}" %> |
||||||
|
<% content_for :title, title %> |
||||||
|
|
||||||
|
<% content_for :before_content do %> |
||||||
|
<%= govuk_back_link( |
||||||
|
text: "Back", |
||||||
|
href: scheme_location_path(scheme_id: @location.scheme.id, id: @location.id), |
||||||
|
) %> |
||||||
|
<% end %> |
||||||
|
|
||||||
|
<%= form_with model: @location, url: scheme_location_deactivate_path(scheme_id: @location.scheme.id, location_id: @location.id), method: "patch", local: true do |f| %> |
||||||
|
<div class="govuk-grid-row"> |
||||||
|
<div class="govuk-grid-column-two-thirds"> |
||||||
|
<% collection_start_date = FormHandler.instance.current_collection_start_date %> |
||||||
|
<%= 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, |
||||||
|
"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, |
||||||
|
"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, |
||||||
|
legend: { text: "Date", size: "m" }, |
||||||
|
hint: { text: "For example, 27 3 2008" }, |
||||||
|
width: 20 %> |
||||||
|
<% end %> |
||||||
|
<% end %> |
||||||
|
|
||||||
|
<%= f.govuk_submit "Continue" %> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
<% end %> |
@ -0,0 +1,16 @@ |
|||||||
|
<%= form_with model: @location, url: scheme_location_deactivate_path(@location), method: "patch", local: true do |f| %> |
||||||
|
<% content_for :before_content do %> |
||||||
|
<%= govuk_back_link(href: :back) %> |
||||||
|
<% end %> |
||||||
|
<h1 class="govuk-heading-l"> |
||||||
|
<span class="govuk-caption-l"><%= @location.postcode %></span> |
||||||
|
<%= "This change will affect #{@location.lettings_logs.count} logs" %> |
||||||
|
</h1> |
||||||
|
<%= govuk_warning_text text: I18n.t("warnings.location.deactivation.review_logs") %> |
||||||
|
<%= f.hidden_field :confirm, value: true %> |
||||||
|
<%= f.hidden_field :deactivation_date, value: deactivation_date %> |
||||||
|
<div class="govuk-button-group"> |
||||||
|
<%= f.govuk_submit "Deactivate this location" %> |
||||||
|
<%= govuk_button_link_to "Cancel", scheme_location_path(scheme_id: @scheme, id: @location.id), html: { method: :get }, secondary: true %> |
||||||
|
</div> |
||||||
|
<% end %> |
@ -0,0 +1,5 @@ |
|||||||
|
class AddDeactivationDateToLocations < ActiveRecord::Migration[7.0] |
||||||
|
def change |
||||||
|
add_column :locations, :deactivation_date, :datetime |
||||||
|
end |
||||||
|
end |
Loading…
Reference in new issue