Browse Source

feat: wip set deactivation_date to a datetime (to be more specific times later_

pull/980/head
natdeanlewissoftwire 2 years ago
parent
commit
a5df699583
  1. 13
      app/controllers/schemes_controller.rb
  2. 2
      app/views/schemes/toggle_active.html.erb
  3. 16
      app/views/schemes/toggle_active_confirm.html.erb

13
app/controllers/schemes_controller.rb

@ -22,6 +22,16 @@ class SchemesController < ApplicationController
end end
def deactivate def deactivate
if params[:confirm] && params[:deactivation_date].present?
if @scheme.update!(deactivation_date: params[:deactivation_date])
# update the logs
end
redirect_to scheme_details_path(@scheme)
return
elsif params[:deactivation_date].present?
render "toggle_active_confirm", locals: { action: "deactivate", deactivation_date: params[:deactivation_date] }
return
end
render "toggle_active", locals: { action: "deactivate" } render "toggle_active", locals: { action: "deactivate" }
end end
@ -210,7 +220,8 @@ private
:support_type, :support_type,
:arrangement_type, :arrangement_type,
:intended_stay, :intended_stay,
:confirmed) :confirmed,
:deactivation_date)
if arrangement_type_changed_to_different_org?(required_params) if arrangement_type_changed_to_different_org?(required_params)
required_params[:managing_organisation_id] = nil required_params[:managing_organisation_id] = nil

2
app/views/schemes/toggle_active.html.erb

@ -1,4 +1,4 @@
<%= form_with url: scheme_details_path(@scheme), method: "get", local: true do |f| %> <%= form_with url: scheme_deactivate_path(@scheme), method: "get", local: true do |f| %>
<% content_for :before_content do %> <% content_for :before_content do %>
<%= govuk_back_link(href: :back) %> <%= govuk_back_link(href: :back) %>
<% end %> <% end %>

16
app/views/schemes/toggle_active_confirm.html.erb

@ -0,0 +1,16 @@
<%= form_with url: scheme_deactivate_path(@scheme), method: "get", 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"><%= @scheme.service_name %></span>
<%= "This change will affect SOME logs" %>
</h1>
<%= govuk_warning_text text: "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." %>
<%= f.hidden_field :confirm %>
<%= f.hidden_field :deactivation_date, :value => params[:deactivation_date] %>
<div class="govuk-button-group">
<%= f.govuk_submit "Deactivate this scheme" %>
<%= govuk_button_link_to "Cancel", scheme_details_path, html: { method: :get }, secondary: true %>
</div>
<% end %>
Loading…
Cancel
Save