mirror of https://github.com/zulip/zulip.git
account_settings: Refactor avatar settings hbs.
This refactor removes some slightly complex conditional logic for displaying avatar controls from the handlebar template to js.
This commit is contained in:
parent
71f0fecda7
commit
248fbadfb6
|
@ -119,6 +119,7 @@ exports.build_page = function () {
|
|||
settings_notifications.all_notifications.push_notification_tooltip,
|
||||
display_settings: settings_display.all_display_settings,
|
||||
user_can_change_name: settings_account.user_can_change_name(),
|
||||
user_can_change_avatar: settings_account.user_can_change_avatar(),
|
||||
});
|
||||
|
||||
$(".settings-box").html(rendered_settings_tab);
|
||||
|
|
|
@ -39,6 +39,16 @@ exports.user_can_change_name = function () {
|
|||
return true;
|
||||
};
|
||||
|
||||
exports.user_can_change_avatar = function () {
|
||||
if (page_params.is_admin) {
|
||||
return true;
|
||||
}
|
||||
if (page_params.realm_avatar_changes_disabled || page_params.server_avatar_changes_disabled) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
exports.update_name_change_display = function () {
|
||||
if (!exports.user_can_change_name()) {
|
||||
$('#full_name').attr('disabled', 'disabled');
|
||||
|
@ -60,9 +70,7 @@ exports.update_email_change_display = function () {
|
|||
};
|
||||
|
||||
exports.update_avatar_change_display = function () {
|
||||
if ((page_params.realm_avatar_changes_disabled ||
|
||||
page_params.server_avatar_changes_disabled)
|
||||
&& !page_params.is_admin) {
|
||||
if (!exports.user_can_change_avatar()) {
|
||||
$('#user_avatar_upload_button .button').attr('disabled', 'disabled');
|
||||
$('#user_avatar_delete_button .button').attr('disabled', 'disabled');
|
||||
} else {
|
||||
|
|
|
@ -156,7 +156,7 @@
|
|||
<div id="user-settings-avatar">
|
||||
<div id="user-avatar-block" style="background-image: url({{ page_params.avatar_url_medium }})" {{#if page_params.is_guest}} class="guest-avatar"{{/if}}/>
|
||||
<span id="user_avatar_delete_button" aria-label="{{t 'Delete profile picture'}}" role="button" tabindex="0"
|
||||
{{#unless page_params.is_admin}}{{#if page_params.realm_avatar_changes_disabled}}style="display:none"{{else}}{{#if page_params.server_avatar_changes_disabled}}style="display:none"{{/if}}{{/if}}{{/unless}}>
|
||||
{{#unless user_can_change_avatar}}style="display:none"{{/unless}}>
|
||||
×
|
||||
</span>
|
||||
<div id="user-avatar-source">
|
||||
|
|
Loading…
Reference in New Issue