Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-22 09:20:29 +01:00
Merge branch 'main' into frontend_updates
Dieser Commit ist enthalten in:
Commit
978aaf89b0
3 geänderte Dateien mit 33 neuen und 0 gelöschten Zeilen
|
@ -84,6 +84,10 @@ class CustomWizard::Submission
|
|||
data
|
||||
end
|
||||
|
||||
def submitted?
|
||||
!!submitted_at
|
||||
end
|
||||
|
||||
def self.get(wizard)
|
||||
data = PluginStore.get("#{wizard.id}_#{KEY}", wizard.actor_id).last
|
||||
new(wizard, data)
|
||||
|
|
|
@ -176,6 +176,7 @@ class CustomWizard::Wizard
|
|||
|
||||
def unfinished?
|
||||
return nil unless actor_id
|
||||
return false if last_submission&.submitted?
|
||||
|
||||
most_recent = CustomWizard::UserHistory.where(
|
||||
actor_id: actor_id,
|
||||
|
@ -194,6 +195,7 @@ class CustomWizard::Wizard
|
|||
|
||||
def completed?
|
||||
return nil unless actor_id
|
||||
return true if last_submission&.submitted?
|
||||
|
||||
history = CustomWizard::UserHistory.where(
|
||||
actor_id: actor_id,
|
||||
|
@ -282,6 +284,10 @@ class CustomWizard::Wizard
|
|||
@submissions ||= CustomWizard::Submission.list(self).submissions
|
||||
end
|
||||
|
||||
def last_submission
|
||||
@last_submission ||= submissions&.last
|
||||
end
|
||||
|
||||
def current_submission
|
||||
@current_submission ||= begin
|
||||
if submissions.present?
|
||||
|
|
|
@ -7,6 +7,7 @@ describe CustomWizard::Wizard do
|
|||
let(:template_json) { get_wizard_fixture("wizard") }
|
||||
let(:permitted_json) { get_wizard_fixture("wizard/permitted") }
|
||||
let(:guests_permitted_json) { get_wizard_fixture("wizard/guests_permitted") }
|
||||
let(:step_json) { get_wizard_fixture("step/step") }
|
||||
|
||||
before do
|
||||
Group.refresh_automatic_group!(:trust_level_3)
|
||||
|
@ -75,6 +76,28 @@ describe CustomWizard::Wizard do
|
|||
expect(@wizard.start).to eq('step_2')
|
||||
end
|
||||
|
||||
it "determines the user's current step if steps are added" do
|
||||
append_steps
|
||||
progress_step('step_1')
|
||||
progress_step('step_2')
|
||||
progress_step("step_3")
|
||||
|
||||
fourth_step = step_json.dup
|
||||
fourth_step['id'] = "step_4"
|
||||
template = template_json.dup
|
||||
template['steps'] << fourth_step
|
||||
|
||||
CustomWizard::Template.save(template, skip_jobs: true)
|
||||
|
||||
wizard = CustomWizard::Wizard.new(template, user)
|
||||
template['steps'].each do |step_template|
|
||||
wizard.append_step(step_template['id'])
|
||||
end
|
||||
|
||||
expect(wizard.steps.size).to eq(4)
|
||||
expect(wizard.start).to eq(nil)
|
||||
end
|
||||
|
||||
it "creates a step updater" do
|
||||
expect(
|
||||
@wizard.create_updater('step_1', step_1_field_1: "Text input")
|
||||
|
|
Laden …
In neuem Issue referenzieren