Designing the First Time Setup Wizard

I’ve confirmed that the API works well from a plugin. Here’s an example from the Akismet plugin:

Basically to add a step from the plugin you do this:

plugin.rb


on(:wizard_build) do |wizard|
  wizard.append_step('akismet') do |step|
    step.add_field(id: 'akismet_api_key', type: 'text', value: SiteSetting.akismet_api_key)

    step.on_update do |updater|
      updater.apply_settings(:akismet_api_key)
    end
  end
end

You also then have to fill in the translation keys for the step and the labels. This is pretty straightforward but if you want to see an example view the akismet commit.

Notice that this API doesn’t use any Javascript! If you’re just using basic form elements like text fields, drop downs and radio buttons you can just assemble the step using the ruby DSL. If you want to do something more advanced such as the color scheme preview in the screenshots earlier in this topic, you’ll have to write your own Ember component.

If you’re curious how this works: the API creates a bunch of objects that are serialized the JSON. The accompanying Ember app is smart enough to read that JSON and render a multi step wizard, submitting each step to the server as it goes along.

9 Mi Piace