1
0
Fork 0

FIX: Refine Topic Creation Hook to Allow Wizard Multi-Step Functionality

Dieser Commit ist enthalten in:
jumagura 2023-10-02 18:18:00 -04:00
Ursprung d5aa616ff8
Commit 24d7ca646a
2 geänderte Dateien mit 7 neuen und 4 gelöschten Zeilen

Datei anzeigen

@ -63,6 +63,7 @@ class CustomWizard::Action
def create_topic
params = basic_topic_params.merge(public_topic_params)
params[:from_wizard] = true
callbacks_for(:before_create_topic).each do |acb|
params = acb.call(params, @wizard, @action, @submission)

Datei anzeigen

@ -238,11 +238,13 @@ after_initialize do
DiscourseEvent.trigger(:custom_wizard_ready)
on(:before_create_topic) do |topic_params, user|
category = topic_params.category
if category&.custom_fields&.[]('create_topic_wizard').present?
next if topic_params[:archetype] == 'message'
if topic_params[:category]&.custom_fields&.[]('create_topic_wizard').present? && !topic_params[:from_wizard]
raise Discourse::InvalidParameters.new(
I18n.t('wizard.error_messages.wizard_replacing_composer')
)
I18n.t('wizard.error_messages.wizard_replacing_composer')
)
end
end
end