0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-09 20:02:54 +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 = [
'name',
'user_avatar',
'date_of_birth',
'title',
'locale',

Datei anzeigen

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

Datei anzeigen

@ -476,13 +476,20 @@ class CustomWizard::Builder
custom_fields[user_field || custom_field] = data[key]
else
updater_key = value
if ['profile_background', 'card_background'].include?(value)
updater_key = "#{value}_upload_url"
end
attributes[updater_key.to_sym] = data[key] if updater_key
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
if custom_fields.present?