diff --git a/app/assets/javascripts/discourse/controllers/preferences_controller.js b/app/assets/javascripts/discourse/controllers/preferences_controller.js index cfe7efeae83..32c5805cc62 100644 --- a/app/assets/javascripts/discourse/controllers/preferences_controller.js +++ b/app/assets/javascripts/discourse/controllers/preferences_controller.js @@ -16,11 +16,15 @@ Discourse.PreferencesController = Discourse.ObjectController.extend({ saveDisabled: function() { if (this.get('saving')) return true; - if (this.blank('name')) return true; + if (Discourse.SiteSettings.enable_names && this.blank('name')) return true; if (this.blank('email')) return true; return false; }.property('saving', 'name', 'email'), + canEditName: function() { + return Discourse.SiteSettings.enable_names; + }.property(), + digestFrequencies: [{ name: I18n.t('user.email_digests.daily'), value: 1 }, { name: I18n.t('user.email_digests.weekly'), value: 7 }, { name: I18n.t('user.email_digests.bi_weekly'), value: 14 }], diff --git a/app/assets/javascripts/discourse/models/user.js b/app/assets/javascripts/discourse/models/user.js index 7fa3df262a1..646aed889ad 100644 --- a/app/assets/javascripts/discourse/models/user.js +++ b/app/assets/javascripts/discourse/models/user.js @@ -35,6 +35,20 @@ Discourse.User = Discourse.Model.extend({ }; }.property('username_lower'), + /** + This user's display name. Returns the name if possible, otherwise returns the + username. + + @property displayName + @type {String} + **/ + displayName: function() { + if (Discourse.SiteSettings.enable_names && !this.blank('name')) { + return this.get('name'); + } + return this.get('username'); + }.property('username', 'name'), + /** This user's website. diff --git a/app/assets/javascripts/discourse/models/user_action.js b/app/assets/javascripts/discourse/models/user_action.js index 0d0a2c2bc21..3adebb62748 100644 --- a/app/assets/javascripts/discourse/models/user_action.js +++ b/app/assets/javascripts/discourse/models/user_action.js @@ -85,7 +85,7 @@ Discourse.UserAction = Discourse.Model.extend({ post_number: '#' + this.get('reply_to_post_number'), user1Url: this.get('userUrl'), user2Url: this.get('targetUserUrl'), - another_user: this.get('target_name') + another_user: this.get('targetDisplayName') })); }.property('descriptionKey'), @@ -99,6 +99,9 @@ Discourse.UserAction = Discourse.Model.extend({ }.property('target_username'), presentName: Em.computed.any('name', 'username'), + targetDisplayName: Em.computed.any('target_name', 'target_username'), + actingDisplayName: Em.computed.any('acting_name', 'acting_username'), + targetUserUrl: Discourse.computed.url('target_username', '/users/%@'), usernameLower: function() { @@ -170,7 +173,7 @@ Discourse.UserAction = Discourse.Model.extend({ this.setProperties({ username: this.get('acting_username'), avatar_template: this.get('acting_avatar_template'), - name: this.get('acting_name') + name: this.get('actingDisplayName') }); } }); diff --git a/app/assets/javascripts/discourse/templates/header.js.handlebars b/app/assets/javascripts/discourse/templates/header.js.handlebars index 506d98d710d..eb420815f59 100644 --- a/app/assets/javascripts/discourse/templates/header.js.handlebars +++ b/app/assets/javascripts/discourse/templates/header.js.handlebars @@ -30,7 +30,7 @@ {{#unless showExtraInfo}}