0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-22 17:30:29 +01:00

FEATURE: new option to force restart at each revisit

Dieser Commit ist enthalten in:
Robert Barrow 2019-11-04 17:49:30 +00:00
Ursprung fd9cc78e58
Commit 1c3d272b79
6 geänderte Dateien mit 28 neuen und 2 gelöschten Zeilen

Datei anzeigen

@ -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();
};

Datei anzeigen

@ -111,6 +111,16 @@
</div>
</div>
<div class="setting">
<div class="setting-label">
<h3>{{i18n 'admin.wizard.restart_on_revisit'}}</h3>
</div>
<div class="setting-value">
{{input type='checkbox' checked=model.restart_on_revisit}}
<span>{{i18n 'admin.wizard.restart_on_revisit_label'}}</span>
</div>
</div>
<div class="setting full">
<div class="setting-label">
<h3>{{i18n 'admin.wizard.url'}}</h3>

Datei anzeigen

@ -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"

Datei anzeigen

@ -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|

Datei anzeigen

@ -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']

Datei anzeigen

@ -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