Merge pull request #327 from tms/name-changing

Change the name displayed in the header on profile update
This commit is contained in:
Robin Ward 2013-03-02 08:10:26 -08:00
commit dfafadfe41
2 changed files with 7 additions and 3 deletions

View file

@ -53,14 +53,18 @@ Discourse.PreferencesController = Discourse.ObjectController.extend({
}).property(), }).property(),
save: function() { save: function() {
var _this = this; var _this = this, model = this.get('content');
this.set('saving', true); this.set('saving', true);
this.set('saved', false); this.set('saved', false);
// Cook the bio for preview // Cook the bio for preview
return this.get('content').save(function(result) { return model.save(function(result) {
_this.set('saving', false); _this.set('saving', false);
if (result) { if (result) {
if (Discourse.currentUser.id === model.get('id')) {
Discourse.currentUser.set('name', model.get('name'));
}
_this.set('content.bio_cooked', Discourse.Utilities.cook(_this.get('content.bio_raw'))); _this.set('content.bio_cooked', Discourse.Utilities.cook(_this.get('content.bio_raw')));
return _this.set('saved', true); return _this.set('saved', true);
} else { } else {

View file

@ -8,7 +8,7 @@
{{#unless controller.showExtraInfo}} {{#unless controller.showExtraInfo}}
<div class='current-username'> <div class='current-username'>
{{#if view.currentUser}} {{#if view.currentUser}}
<span class='username'><a {{bindAttr href="view.currentUser.path"}}>{{unbound view.currentUser.name}}</a></span> <span class='username'><a {{bindAttr href="view.currentUser.path"}}>{{view.currentUser.name}}</a></span>
{{else}} {{else}}
<button {{action showLogin}} class='btn btn-primary btn-small'>{{i18n log_in}}</button> <button {{action showLogin}} class='btn btn-primary btn-small'>{{i18n log_in}}</button>
{{/if}} {{/if}}