diff --git a/assets/javascripts/discourse/models/custom-wizard.js.es6 b/assets/javascripts/discourse/models/custom-wizard.js.es6
index dc3f2c12..e7860c01 100644
--- a/assets/javascripts/discourse/models/custom-wizard.js.es6
+++ b/assets/javascripts/discourse/models/custom-wizard.js.es6
@@ -10,6 +10,7 @@ const wizardProperties = [
'after_time_scheduled',
'required',
'prompt_completion',
+ 'restart_on_revisit',
'min_trust',
'theme_id'
];
@@ -264,6 +265,7 @@ CustomWizard.reopenClass({
props['after_time'] = false;
props['required'] = false;
props['prompt_completion'] = false;
+ props['restart_on_revisit'] = false;
props['min_trust'] = 0;
props['steps'] = Ember.A();
};
diff --git a/assets/javascripts/discourse/templates/admin-wizard.hbs b/assets/javascripts/discourse/templates/admin-wizard.hbs
index ed610b8c..9b7a53ad 100644
--- a/assets/javascripts/discourse/templates/admin-wizard.hbs
+++ b/assets/javascripts/discourse/templates/admin-wizard.hbs
@@ -111,6 +111,16 @@
+
+
+
{{i18n 'admin.wizard.restart_on_revisit'}}
+
+
+ {{input type='checkbox' checked=model.restart_on_revisit}}
+ {{i18n 'admin.wizard.restart_on_revisit_label'}}
+
+
+
{{i18n 'admin.wizard.url'}}
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index 9372570c..6f0682e0 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -33,6 +33,8 @@ en:
required_label: "Users cannot skip the wizard."
prompt_completion: "Prompt"
prompt_completion_label: "Prompt user to complete wizard."
+ restart_on_revisit: "Restart"
+ restart_on_revisit_label: "Restart the the wizard whenever the user revists, regardless of prior progress."
min_trust: "Trust"
min_trust_label: "Trust level required to access wizard."
theme_id: "Theme"
diff --git a/lib/builder.rb b/lib/builder.rb
index e0d88494..90e54a27 100644
--- a/lib/builder.rb
+++ b/lib/builder.rb
@@ -79,7 +79,7 @@ class CustomWizard::Builder
def build(build_opts = {}, params = {})
unless (@wizard.completed? && !@wizard.multiple_submissions && !@wizard.user.admin) || !@steps || !@wizard.permitted?
- reset_submissions if build_opts[:reset]
+ reset_submissions if build_opts[:reset] || @wizard.restart_on_revisit
@steps.each do |step_template|
@wizard.append_step(step_template['id']) do |step|
diff --git a/lib/template.rb b/lib/template.rb
index ec1237f3..d531d7a7 100644
--- a/lib/template.rb
+++ b/lib/template.rb
@@ -26,6 +26,7 @@ class CustomWizard::Template
@save_submissions = data['save_submissions'] || false
@multiple_submissions = data['multiple_submissions'] || false
@prompt_completion = data['prompt_completion'] || false
+ @restart_on_revist = data['restart_on_revist'] || false
@min_trust = data['min_trust'] || 0
@after_signup = data['after_signup']
@after_time = data['after_time']
diff --git a/lib/wizard.rb b/lib/wizard.rb
index b47d68f1..8fe8a690 100644
--- a/lib/wizard.rb
+++ b/lib/wizard.rb
@@ -16,7 +16,8 @@ class CustomWizard::Wizard
:after_time_scheduled,
:after_signup,
:required,
- :prompt_completion
+ :prompt_completion,
+ :restart_on_revisit
def initialize(user=nil, attrs = {})
@steps = []
@@ -157,6 +158,16 @@ class CustomWizard::Wizard
end
end
+ def self.restart_on_revisit
+ rows = PluginStoreRow.where(plugin_name: 'custom_wizard')
+ wizards = [*rows].select { |r| r.value['restart_on_revisit'] }
+ if wizards.any?
+ wizards.first.key
+ else
+ false
+ end
+ end
+
def self.steps(wizard_id)
wizard = PluginStore.get('custom_wizard', wizard_id)
wizard ? wizard['steps'] : nil