diff --git a/app/controllers/custom_wizard/admin/wizard.rb b/app/controllers/custom_wizard/admin/wizard.rb
index 71a5623b..7a316c84 100644
--- a/app/controllers/custom_wizard/admin/wizard.rb
+++ b/app/controllers/custom_wizard/admin/wizard.rb
@@ -163,7 +163,8 @@ class CustomWizard::AdminWizardController < CustomWizard::AdminController
mentionable_level: mapped_params,
messageable_level: mapped_params,
visibility_level: mapped_params,
- members_visibility_level: mapped_params
+ members_visibility_level: mapped_params,
+ add_event: mapped_params
]
)
end
diff --git a/assets/javascripts/discourse/components/wizard-custom-action.js.es6 b/assets/javascripts/discourse/components/wizard-custom-action.js.es6
index a5aa06cd..c11e2b4f 100644
--- a/assets/javascripts/discourse/components/wizard-custom-action.js.es6
+++ b/assets/javascripts/discourse/components/wizard-custom-action.js.es6
@@ -101,4 +101,9 @@ export default Component.extend(UndoChanges, {
}
return apis.find((a) => a.name === api).endpoints;
},
+
+ @discourseComputed("fieldTypes")
+ hasEventsField(fieldTypes) {
+ return fieldTypes.map((ft) => ft.id).includes("event");
+ },
});
diff --git a/assets/javascripts/discourse/lib/wizard-schema.js.es6 b/assets/javascripts/discourse/lib/wizard-schema.js.es6
index f5a62c87..4953e59c 100644
--- a/assets/javascripts/discourse/lib/wizard-schema.js.es6
+++ b/assets/javascripts/discourse/lib/wizard-schema.js.es6
@@ -102,6 +102,7 @@ const action = {
custom_fields: null,
skip_redirect: null,
suppress_notifications: null,
+ add_event: null,
},
send_message: {
title: null,
@@ -198,6 +199,7 @@ const action = {
"messageable_level",
"visibility_level",
"members_visibility_level",
+ "add_event",
],
advanced: [
"code",
diff --git a/assets/javascripts/discourse/templates/admin-wizards-wizard-show.hbs b/assets/javascripts/discourse/templates/admin-wizards-wizard-show.hbs
index c5ed70a7..b1281a6a 100644
--- a/assets/javascripts/discourse/templates/admin-wizards-wizard-show.hbs
+++ b/assets/javascripts/discourse/templates/admin-wizards-wizard-show.hbs
@@ -192,7 +192,8 @@
wizard=wizard
apis=apis
removeAction="removeAction"
- wizardFields=wizardFields}}
+ wizardFields=wizardFields
+ fieldTypes=fieldTypes}}
{{/each}}
diff --git a/assets/javascripts/discourse/templates/components/wizard-custom-action.hbs b/assets/javascripts/discourse/templates/components/wizard-custom-action.hbs
index 4c645cf7..03aee3f4 100644
--- a/assets/javascripts/discourse/templates/components/wizard-custom-action.hbs
+++ b/assets/javascripts/discourse/templates/components/wizard-custom-action.hbs
@@ -158,6 +158,25 @@
)}}
+
+ {{#if hasEventsField}}
+
+
+
+
+
+
+ {{wizard-mapper
+ inputs=action.add_event
+ property="add_event"
+ onUpdate=(action "mappedFieldUpdated")
+ options=(hash
+ wizardFieldSelection=true
+ context="action"
+ )}}
+
+
+ {{/if}}
{{/if}}
{{#if sendMessage}}
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index d3d938dc..ba6d4f17 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -293,6 +293,7 @@ en:
date: Date
time: Time
date_time: Date & Time
+ event: Event (Events Plugin)
connector:
and: "and"
@@ -336,6 +337,7 @@ en:
category: "Category"
tags: "Tags"
visible: "Visible"
+ add_event: "Add Event (Events Plugin)"
open_composer:
label: "Open Composer"
update_profile:
diff --git a/lib/custom_wizard/action.rb b/lib/custom_wizard/action.rb
index 6de7d3f7..d532891c 100644
--- a/lib/custom_wizard/action.rb
+++ b/lib/custom_wizard/action.rb
@@ -46,6 +46,10 @@ class CustomWizard::Action
def create_topic
params = basic_topic_params.merge(public_topic_params)
+ CustomWizard::Field.action_callbacks.each do |acb|
+ params = acb.call(params, @wizard, @action, @submission)
+ end
+
if params[:title].present? && params[:raw].present?
creator = PostCreator.new(user, params)
post = creator.create
diff --git a/lib/custom_wizard/field.rb b/lib/custom_wizard/field.rb
index 12c46623..ee0fc379 100644
--- a/lib/custom_wizard/field.rb
+++ b/lib/custom_wizard/field.rb
@@ -131,18 +131,18 @@ class CustomWizard::Field
}
end
- def self.require_assets
- @require_assets ||= {}
+ def self.action_callbacks
+ @acbs ||= []
end
- def self.register(type, plugin = nil, asset_paths = [], opts = {})
+ def self.register(type, plugin = nil, opts = {})
if type
types[type.to_sym] ||= {}
types[type.to_sym] = opts[:type_opts] if opts[:type_opts].present?
end
- if plugin && asset_paths
- require_assets[plugin] = asset_paths
+ if opts[:action_callback].present? && opts[:action_callback].is_a?(Proc)
+ action_callbacks << opts[:action_callback]
end
end
end