diff --git a/app/assets/javascripts/discourse/controllers/preferences_controller.js b/app/assets/javascripts/discourse/controllers/preferences_controller.js index b784fefee0a..a4fd1486ba9 100644 --- a/app/assets/javascripts/discourse/controllers/preferences_controller.js +++ b/app/assets/javascripts/discourse/controllers/preferences_controller.js @@ -14,12 +14,14 @@ Discourse.PreferencesController = Discourse.ObjectController.extend({ // By default we haven't saved anything saved: false, + newNameInput: null, + saveDisabled: function() { if (this.get('saving')) return true; - if (Discourse.SiteSettings.enable_names && this.blank('name')) return true; + if (Discourse.SiteSettings.enable_names && this.blank('newNameInput')) return true; if (this.blank('email')) return true; return false; - }.property('saving', 'name', 'email'), + }.property('saving', 'newNameInput', 'email'), canEditName: function() { return Discourse.SiteSettings.enable_names; @@ -57,6 +59,7 @@ Discourse.PreferencesController = Discourse.ObjectController.extend({ // Cook the bio for preview var model = this.get('model'); + model.set('name', this.get('newNameInput')); return model.save().then(function() { // model was saved self.set('saving', false); diff --git a/app/assets/javascripts/discourse/routes/preferences_routes.js b/app/assets/javascripts/discourse/routes/preferences_routes.js index d0a0b798609..9f4382134b4 100644 --- a/app/assets/javascripts/discourse/routes/preferences_routes.js +++ b/app/assets/javascripts/discourse/routes/preferences_routes.js @@ -11,8 +11,8 @@ Discourse.PreferencesRoute = Discourse.RestrictedUserRoute.extend({ return this.modelFor('user'); }, - setupController: function(controller, model) { - controller.set('model', model); + setupController: function(controller, user) { + controller.setProperties({ model: user, newNameInput: user.get('name') }); this.controllerFor('user').set('indexStream', false); }, diff --git a/app/assets/javascripts/discourse/templates/user/preferences.js.handlebars b/app/assets/javascripts/discourse/templates/user/preferences.js.handlebars index d2547025795..566dbc74bd7 100644 --- a/app/assets/javascripts/discourse/templates/user/preferences.js.handlebars +++ b/app/assets/javascripts/discourse/templates/user/preferences.js.handlebars @@ -19,7 +19,7 @@