From 0d2f3d1cb52b917fc4c3cd838cfa295e883decff Mon Sep 17 00:00:00 2001 From: Faizaan Gagan Date: Thu, 12 Aug 2021 20:02:04 +0530 Subject: [PATCH] FIX: reset step progress on wizard skip --- controllers/custom_wizard/wizard.rb | 1 + lib/custom_wizard/wizard.rb | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/controllers/custom_wizard/wizard.rb b/controllers/custom_wizard/wizard.rb index 539b4b80..1f259a59 100644 --- a/controllers/custom_wizard/wizard.rb +++ b/controllers/custom_wizard/wizard.rb @@ -69,6 +69,7 @@ class CustomWizard::WizardController < ::ApplicationController end submission.remove if submission.present? + wizard.cleanup! end render json: result diff --git a/lib/custom_wizard/wizard.rb b/lib/custom_wizard/wizard.rb index 8f5a897f..b4b3b8fd 100644 --- a/lib/custom_wizard/wizard.rb +++ b/lib/custom_wizard/wizard.rb @@ -286,11 +286,15 @@ class CustomWizard::Wizard end end - def final_cleanup! + def cleanup! if id == user.custom_fields['redirect_to_wizard'] user.custom_fields.delete('redirect_to_wizard') user.save_custom_fields(true) end + end + + def final_cleanup! + cleanup! if current_submission.present? current_submission.submitted_at = Time.now.iso8601