1
0
Fork 0
discourse-custom-wizard-unl.../controllers/wizard.rb

26 Zeilen
791 B
Ruby

2017-09-25 16:47:40 +02:00
class CustomWizard::WizardController < ::ApplicationController
2017-10-17 09:18:53 +02:00
prepend_view_path(Rails.root.join('plugins', 'discourse-custom-wizard', 'views'))
layout 'wizard'
helper_method :wizard_page_title
def wizard_page_title
wizard = PluginStore.get('custom_wizard', params[:wizard_id].underscore)
2017-10-22 05:37:58 +02:00
wizard ? (wizard['name'] || wizard['id']) : I18n.t('wizard.custom_title')
2017-09-25 16:47:40 +02:00
end
def index
2017-09-23 04:34:07 +02:00
respond_to do |format|
format.json do
2017-10-22 05:37:58 +02:00
template = CustomWizard::Builder.new(current_user, params[:wizard_id].underscore)
if template.wizard.present?
wizard = template.build
render_serialized(wizard, WizardSerializer)
else
render json: { error: I18n.t('wizard.none') }
end
2017-09-23 04:34:07 +02:00
end
format.html {}
end
end
end