From a5df699583e36dd5f2010c3273fc6e3536151a17 Mon Sep 17 00:00:00 2001 From: natdeanlewissoftwire Date: Wed, 9 Nov 2022 13:52:59 +0000 Subject: [PATCH] feat: wip set deactivation_date to a datetime (to be more specific times later_ --- app/controllers/schemes_controller.rb | 13 ++++++++++++- app/views/schemes/toggle_active.html.erb | 2 +- app/views/schemes/toggle_active_confirm.html.erb | 16 ++++++++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 app/views/schemes/toggle_active_confirm.html.erb diff --git a/app/controllers/schemes_controller.rb b/app/controllers/schemes_controller.rb index 8eb46884d..186efb921 100644 --- a/app/controllers/schemes_controller.rb +++ b/app/controllers/schemes_controller.rb @@ -22,6 +22,16 @@ class SchemesController < ApplicationController end 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" } end @@ -210,7 +220,8 @@ private :support_type, :arrangement_type, :intended_stay, - :confirmed) + :confirmed, + :deactivation_date) if arrangement_type_changed_to_different_org?(required_params) required_params[:managing_organisation_id] = nil diff --git a/app/views/schemes/toggle_active.html.erb b/app/views/schemes/toggle_active.html.erb index 7d0738cf1..eb3c11b3c 100644 --- a/app/views/schemes/toggle_active.html.erb +++ b/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 %> <%= govuk_back_link(href: :back) %> <% end %> diff --git a/app/views/schemes/toggle_active_confirm.html.erb b/app/views/schemes/toggle_active_confirm.html.erb new file mode 100644 index 000000000..271a4df48 --- /dev/null +++ b/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 %> +

+ <%= @scheme.service_name %> + <%= "This change will affect SOME logs" %> +

+ <%= 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] %> +
+ <%= f.govuk_submit "Deactivate this scheme" %> + <%= govuk_button_link_to "Cancel", scheme_details_path, html: { method: :get }, secondary: true %> +
+<% end %>