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

NEW FEATURE: can upload avatar in a wizard step

Dieser Commit ist enthalten in:
Robert Barrow 2019-09-11 12:58:57 +01:00
Ursprung 5befcd2f23
Commit 938e29fe3f
3 geänderte Dateien mit 12 neuen und 2 gelöschten Zeilen

Datei anzeigen

@ -12,6 +12,7 @@ const ACTION_TYPES = [
const PROFILE_FIELDS = [ const PROFILE_FIELDS = [
'name', 'name',
'user_avatar',
'date_of_birth', 'date_of_birth',
'title', 'title',
'locale', 'locale',

Datei anzeigen

@ -256,6 +256,8 @@ export default {
valid = val; valid = val;
} else if (type === 'category') { } else if (type === 'category') {
valid = val && val.toString().length > 0; valid = val && val.toString().length > 0;
} else if (type === 'upload') {
valid = val && val.id > 0;
} else if (StandardFieldValidation.indexOf(type) > -1) { } else if (StandardFieldValidation.indexOf(type) > -1) {
valid = val && val.length > 0; valid = val && val.length > 0;
} }

Datei anzeigen

@ -476,13 +476,20 @@ class CustomWizard::Builder
custom_fields[user_field || custom_field] = data[key] custom_fields[user_field || custom_field] = data[key]
else else
updater_key = value updater_key = value
if ['profile_background', 'card_background'].include?(value) if ['profile_background', 'card_background'].include?(value)
updater_key = "#{value}_upload_url" updater_key = "#{value}_upload_url"
end end
attributes[updater_key.to_sym] = data[key] if updater_key attributes[updater_key.to_sym] = data[key] if updater_key
end end
if ['user_avatar'].include?(value)
this_upload_id = data[key][:id]
user.create_user_avatar unless user.user_avatar
user.user_avatar.custom_upload_id = this_upload_id
user.uploaded_avatar_id = this_upload_id
user.save!
user.user_avatar.save!
end
end end
if custom_fields.present? if custom_fields.present?