2017-09-23 04:34:07 +02:00
|
|
|
# name: discourse-custom-wizard
|
2017-10-05 02:36:46 +02:00
|
|
|
# about: Create custom wizards
|
2017-09-23 04:34:07 +02:00
|
|
|
# version: 0.1
|
|
|
|
# authors: Angus McLeod
|
|
|
|
|
2017-10-13 15:02:34 +02:00
|
|
|
register_asset 'stylesheets/wizard_custom_admin.scss'
|
2017-09-23 04:34:07 +02:00
|
|
|
|
2017-09-25 16:47:40 +02:00
|
|
|
config = Rails.application.config
|
|
|
|
config.assets.paths << Rails.root.join("plugins", "discourse-custom-wizard", "assets", "javascripts")
|
2017-10-13 15:02:34 +02:00
|
|
|
config.assets.paths << Rails.root.join("plugins", "discourse-custom-wizard", "assets", "stylesheets", "wizard")
|
2017-09-25 16:47:40 +02:00
|
|
|
|
2017-09-23 04:34:07 +02:00
|
|
|
after_initialize do
|
2017-10-15 05:58:22 +02:00
|
|
|
UserHistory.actions[:custom_wizard_step] = 100
|
|
|
|
|
2017-09-23 04:34:07 +02:00
|
|
|
require_dependency "application_controller"
|
|
|
|
module ::CustomWizard
|
|
|
|
class Engine < ::Rails::Engine
|
|
|
|
engine_name "custom_wizard"
|
|
|
|
isolate_namespace CustomWizard
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
CustomWizard::Engine.routes.draw do
|
2017-09-29 13:27:03 +02:00
|
|
|
get ':wizard_id' => 'wizard#index'
|
|
|
|
get ':wizard_id/steps' => 'steps#index'
|
|
|
|
get ':wizard_id/steps/:step_id' => 'wizard#index'
|
|
|
|
put ':wizard_id/steps/:step_id' => 'steps#update'
|
2017-09-23 04:34:07 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
require_dependency 'admin_constraint'
|
|
|
|
Discourse::Application.routes.append do
|
2017-10-13 15:02:34 +02:00
|
|
|
mount ::CustomWizard::Engine, at: 'w'
|
2017-09-23 04:34:07 +02:00
|
|
|
|
2017-09-25 16:47:40 +02:00
|
|
|
scope module: 'custom_wizard', constraints: AdminConstraint.new do
|
2017-10-05 02:36:46 +02:00
|
|
|
get 'admin/wizards' => 'admin#index'
|
|
|
|
get 'admin/wizards/field-types' => 'admin#field_types'
|
2017-09-25 16:47:40 +02:00
|
|
|
get 'admin/wizards/custom' => 'admin#index'
|
|
|
|
get 'admin/wizards/custom/new' => 'admin#index'
|
2017-10-05 02:36:46 +02:00
|
|
|
get 'admin/wizards/custom/all' => 'admin#custom_wizards'
|
|
|
|
get 'admin/wizards/custom/:wizard_id' => 'admin#find_wizard'
|
2017-09-25 16:47:40 +02:00
|
|
|
put 'admin/wizards/custom/save' => 'admin#save'
|
|
|
|
delete 'admin/wizards/custom/remove' => 'admin#remove'
|
2017-10-05 02:36:46 +02:00
|
|
|
get 'admin/wizards/submissions' => 'admin#index'
|
|
|
|
get 'admin/wizards/submissions/all' => 'admin#submissions'
|
|
|
|
get 'admin/wizards/submissions/:wizard_id' => 'admin#find_submissions'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-10-15 05:58:22 +02:00
|
|
|
load File.expand_path('../lib/builder.rb', __FILE__)
|
|
|
|
load File.expand_path('../lib/field.rb', __FILE__)
|
|
|
|
load File.expand_path('../lib/step_updater.rb', __FILE__)
|
|
|
|
load File.expand_path('../lib/template.rb', __FILE__)
|
|
|
|
load File.expand_path('../lib/wizard.rb', __FILE__)
|
|
|
|
load File.expand_path('../lib/wizard_edits.rb', __FILE__)
|
|
|
|
load File.expand_path('../controllers/wizard.rb', __FILE__)
|
|
|
|
load File.expand_path('../controllers/steps.rb', __FILE__)
|
|
|
|
load File.expand_path('../controllers/admin.rb', __FILE__)
|
2017-09-23 04:34:07 +02:00
|
|
|
end
|