From 374657d9d566b0dd3eb3ae7e060b08f6f4b44f04 Mon Sep 17 00:00:00 2001 From: Arpit Jalan Date: Tue, 19 Apr 2016 08:42:14 +0530 Subject: [PATCH] FIX: Cancelling a title change does not revert the value --- .../javascripts/admin/controllers/admin-user-index.js.es6 | 7 +++++-- app/assets/javascripts/admin/templates/user-index.hbs | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/admin/controllers/admin-user-index.js.es6 b/app/assets/javascripts/admin/controllers/admin-user-index.js.es6 index fdea272ab1e..454aa96f84d 100644 --- a/app/assets/javascripts/admin/controllers/admin-user-index.js.es6 +++ b/app/assets/javascripts/admin/controllers/admin-user-index.js.es6 @@ -5,6 +5,7 @@ export default Ember.Controller.extend(CanCheckEmails, { editingTitle: false, originalPrimaryGroupId: null, availableGroups: null, + userTitleValue: null, showApproval: setting('must_approve_users'), showBadges: setting('enable_badges'), @@ -30,6 +31,7 @@ export default Ember.Controller.extend(CanCheckEmails, { actions: { toggleTitleEdit() { + this.set('userTitleValue', this.get('model.title')); this.toggleProperty('editingTitle'); }, @@ -37,12 +39,13 @@ export default Ember.Controller.extend(CanCheckEmails, { const self = this; return Discourse.ajax("/users/" + this.get('model.username').toLowerCase(), { - data: {title: this.get('model.title')}, + data: {title: this.get('userTitleValue')}, type: 'PUT' }).catch(function(e) { bootbox.alert(I18n.t("generic_error_with_reason", {error: "http: " + e.status + " - " + e.body})); }).finally(function() { - self.send('toggleTitleEdit'); + self.set('model.title', self.get('userTitleValue')); + self.toggleProperty('editingTitle'); }); }, diff --git a/app/assets/javascripts/admin/templates/user-index.hbs b/app/assets/javascripts/admin/templates/user-index.hbs index 608d7c38ba8..58bb85863b3 100644 --- a/app/assets/javascripts/admin/templates/user-index.hbs +++ b/app/assets/javascripts/admin/templates/user-index.hbs @@ -75,7 +75,7 @@
{{i18n 'user.title.title'}}
{{#if editingTitle}} - {{text-field value=model.title autofocus="autofocus"}} + {{text-field value=userTitleValue autofocus="autofocus"}} {{else}} {{model.title}}  {{/if}}