wizard.rb 791 B

12345678910111213141516171819202122232425
  1. class CustomWizard::WizardController < ::ApplicationController
  2. prepend_view_path(Rails.root.join('plugins', 'discourse-custom-wizard', 'views'))
  3. layout 'wizard'
  4. helper_method :wizard_page_title
  5. def wizard_page_title
  6. wizard = PluginStore.get('custom_wizard', params[:wizard_id].underscore)
  7. wizard ? (wizard['name'] || wizard['id']) : I18n.t('wizard.custom_title')
  8. end
  9. def index
  10. respond_to do |format|
  11. format.json do
  12. template = CustomWizard::Builder.new(current_user, params[:wizard_id].underscore)
  13. if template.wizard.present?
  14. wizard = template.build
  15. render_serialized(wizard, WizardSerializer)
  16. else
  17. render json: { error: I18n.t('wizard.none') }
  18. end
  19. end
  20. format.html {}
  21. end
  22. end
  23. end