1
0
Fork 0

FIX: action category selection

Dieser Commit ist enthalten in:
Angus McLeod 2019-10-02 14:24:02 +10:00
Ursprung 9a3506a9d6
Commit e328331249

Datei anzeigen

@ -364,22 +364,7 @@ class CustomWizard::Builder
skip_validations: true skip_validations: true
} }
if action['custom_category_enabled'] params[:category] = action_category_id(action, data)
if action['custom_category_wizard_field']
category_id = data[action['category_id']]
elsif action['custom_category_user_field_key']
if action['custom_category_user_field_key'].include?('custom_fields')
field = action['custom_category_user_field_key'].split('.').last
category_id = user.custom_fields[field]
else
category_id = user.send(action['custom_category_user_field_key'])
end
end
else
category_id = action['category_id']
end
params[:category] = category_id
topic_custom_fields = {} topic_custom_fields = {}
@ -544,8 +529,8 @@ class CustomWizard::Builder
url += "&body=#{post}" url += "&body=#{post}"
if action['category_id'] if category_id = action_category_id(action, data)
if category = Category.find(action['category_id']) if category = Category.find(category_id)
url += "&category=#{category.full_slug('/')}" url += "&category=#{category.full_slug('/')}"
end end
end end
@ -591,4 +576,21 @@ class CustomWizard::Builder
PluginStore.set("#{@wizard.id}_submissions", @wizard.user.id, @submissions) PluginStore.set("#{@wizard.id}_submissions", @wizard.user.id, @submissions)
@wizard.reset @wizard.reset
end end
def action_category_id(action, data)
if action['custom_category_enabled']
if action['custom_category_wizard_field']
category_id = data[action['category_id']]
elsif action['custom_category_user_field_key']
if action['custom_category_user_field_key'].include?('custom_fields')
field = action['custom_category_user_field_key'].split('.').last
user.custom_fields[field]
else
user.send(action['custom_category_user_field_key'])
end
end
else
action['category_id']
end
end
end end