Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-22 09:20:29 +01:00
FIX: Refine Topic Creation Hook to Allow Wizard Multi-Step Functionality
Dieser Commit ist enthalten in:
Ursprung
d5aa616ff8
Commit
24d7ca646a
2 geänderte Dateien mit 7 neuen und 4 gelöschten Zeilen
|
@ -63,6 +63,7 @@ class CustomWizard::Action
|
||||||
|
|
||||||
def create_topic
|
def create_topic
|
||||||
params = basic_topic_params.merge(public_topic_params)
|
params = basic_topic_params.merge(public_topic_params)
|
||||||
|
params[:from_wizard] = true
|
||||||
|
|
||||||
callbacks_for(:before_create_topic).each do |acb|
|
callbacks_for(:before_create_topic).each do |acb|
|
||||||
params = acb.call(params, @wizard, @action, @submission)
|
params = acb.call(params, @wizard, @action, @submission)
|
||||||
|
|
|
@ -238,11 +238,13 @@ after_initialize do
|
||||||
DiscourseEvent.trigger(:custom_wizard_ready)
|
DiscourseEvent.trigger(:custom_wizard_ready)
|
||||||
|
|
||||||
on(:before_create_topic) do |topic_params, user|
|
on(:before_create_topic) do |topic_params, user|
|
||||||
category = topic_params.category
|
next if topic_params[:archetype] == 'message'
|
||||||
if category&.custom_fields&.[]('create_topic_wizard').present?
|
|
||||||
|
if topic_params[:category]&.custom_fields&.[]('create_topic_wizard').present? && !topic_params[:from_wizard]
|
||||||
raise Discourse::InvalidParameters.new(
|
raise Discourse::InvalidParameters.new(
|
||||||
I18n.t('wizard.error_messages.wizard_replacing_composer')
|
I18n.t('wizard.error_messages.wizard_replacing_composer')
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Laden …
In neuem Issue referenzieren