0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-25 18:50:27 +01:00

Add existing profile values to fields associated with profile update actions

Dieser Commit ist enthalten in:
Angus McLeod 2017-11-06 19:50:19 +08:00
Ursprung 7f15e2a657
Commit 5d8dce986d

Datei anzeigen

@ -61,6 +61,22 @@ class CustomWizard::Builder
params[:value] = submission[f['id']] if submission[f['id']] params[:value] = submission[f['id']] if submission[f['id']]
end end
if s['actions'].any?
profile_actions = s['actions'].select { |a| a['type'] === 'update_profile' }
if profile_actions.any?
profile_actions.each do |action|
if update = action['profile_updates'].select { |u| u['key'] === f['id'] }.first
attribute = update['value']
if UserProfile.column_names.include? attribute
params[:value] = UserProfile.find_by(user_id: @wizard.user.id).send(attribute)
elsif User.column_names.include? attribute
params[:value] = User.find(@wizard.user.id).send(attribute)
end
end
end
end
end
field = step.add_field(params) field = step.add_field(params)
if f['type'] === 'dropdown' if f['type'] === 'dropdown'