0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-10 04:12:53 +01:00
discourse-custom-wizard/lib/builder.rb

36 Zeilen
805 B
Ruby

2017-09-23 04:34:07 +02:00
class CustomWizard::Builder
def initialize(user, wizard_id)
@wizard = Wizard.new(user)
@template = PluginStore.get('custom_wizard', wizard_id)
end
def build
@template.each do |s|
@wizard.append_step(s.title) do |step|
step.banner = s.banner if s.banner
s.fields.each do |f|
field = step.add_field(id: f.id,
type: f.type,
required: f.required,
value: f.value)
if f.type == 'dropdown'
f.choices.each do |c|
field.add_choice(c)
end
end
end
step.on_update do |updater|
puts "UPDATER: #{updater}"
## do stuff
end
end
end
@wizard
end
end