diff --git a/static/js/settings_account.js b/static/js/settings_account.js index 100dd57e38..9813f322df 100644 --- a/static/js/settings_account.js +++ b/static/js/settings_account.js @@ -74,14 +74,28 @@ function settings_change_error(message, xhr) { ui_report.error(message, xhr, $('#account-settings-status').expectOne()); } +function update_custom_profile_field(field, method) { + var field_id; + if (method === channel.del) { + field_id = field; + } else { + field_id = field.id; + } + + var spinner = $('.custom_user_field[data-field-id="' + field_id + + '"] .custom-field-status').expectOne(); + loading.make_indicator(spinner, {text: 'Saving ...'}); + settings_ui.do_settings_change(method, "/json/users/me/profile_data", + {data: JSON.stringify([field])}, spinner); +} + function update_user_custom_profile_fields(fields, method) { if (method === undefined) { blueslip.error("Undefined method in update_user_custom_profile_fields"); } - var spinner = $("#custom-field-status").expectOne(); - loading.make_indicator(spinner, {text: 'Saving ...'}); - settings_ui.do_settings_change(method, "/json/users/me/profile_data", - {data: JSON.stringify(fields)}, spinner); + _.each(fields, function (field) { + update_custom_profile_field(field, method); + }); } exports.append_custom_profile_fields = function (element_id, user_id) { diff --git a/static/styles/settings.scss b/static/styles/settings.scss index 241c687095..82e73fb063 100644 --- a/static/styles/settings.scss +++ b/static/styles/settings.scss @@ -651,6 +651,16 @@ input[type=checkbox].inline-block { text-align: left; } +#account-settings .custom-profile-fields-form .custom_user_field label { + min-width: fit-content; +} + +#account-settings .alert-notification.custom-field-status { + margin-top: 0px; + font-size: 14px; + margin-bottom: 4px; +} + #realm_notifications_stream_label > button, #realm_signup_notifications_stream_label > button { margin: 0px 5px; diff --git a/static/templates/settings/account_settings.hbs b/static/templates/settings/account_settings.hbs index 08d9f33eca..20f21abecd 100644 --- a/static/templates/settings/account_settings.hbs +++ b/static/templates/settings/account_settings.hbs @@ -141,7 +141,6 @@

{{t "Profile" }}

-