From ad18ec9809709ffe97d72899a5cdf986d44b9c24 Mon Sep 17 00:00:00 2001 From: Angus McLeod Date: Thu, 29 Aug 2019 09:51:18 +1000 Subject: [PATCH] Improve redirect code clarity --- .../javascripts/wizard/controllers/custom-step.js.es6 | 4 ++-- lib/builder.rb | 10 ++++------ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/assets/javascripts/wizard/controllers/custom-step.js.es6 b/assets/javascripts/wizard/controllers/custom-step.js.es6 index 01f02753..1881764c 100644 --- a/assets/javascripts/wizard/controllers/custom-step.js.es6 +++ b/assets/javascripts/wizard/controllers/custom-step.js.es6 @@ -5,8 +5,8 @@ export default StepController.extend({ actions: { goNext(response) { const next = this.get('step.next'); - if (response.route_to) { - window.location.href = response.route_to; + if (response.redirect_on_next) { + window.location.href = response.redirect_on_next; } else if (response.refresh_required) { const id = this.get('wizard.id'); window.location.href = getUrl(`/w/${id}/steps/${next}`); diff --git a/lib/builder.rb b/lib/builder.rb index c823ee75..73248d0d 100644 --- a/lib/builder.rb +++ b/lib/builder.rb @@ -161,12 +161,10 @@ class CustomWizard::Builder end if updater.errors.empty? - if route_to = data['route_to'] - updater.result[:route_to] = route_to - end - - if redirect_on_complete = data['redirect_on_complete'] - updater.result[:redirect_on_complete] = redirect_on_complete + if final_step + updater.result[:redirect_on_complete] = data['redirect_on_complete'] || data['route_to'] + elsif route_to = data['route_to'] + updater.result[:redirect_on_next] = route_to end end end