0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-09 20:02:54 +01:00
discourse-custom-wizard/controllers/wizard.rb
Angus McLeod f6251ace06 various
2017-10-22 11:37:58 +08:00

25 Zeilen
791 B
Ruby

class CustomWizard::WizardController < ::ApplicationController
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)
wizard ? (wizard['name'] || wizard['id']) : I18n.t('wizard.custom_title')
end
def index
respond_to do |format|
format.json do
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
end
format.html {}
end
end
end