FIX: Cancelling a title change does not revert the value

This commit is contained in:
Arpit Jalan 2016-04-19 08:42:14 +05:30
parent 7d9f2265b9
commit 374657d9d5
2 changed files with 6 additions and 3 deletions

View File

@ -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');
});
},

View File

@ -75,7 +75,7 @@
<div class='field'>{{i18n 'user.title.title'}}</div>
<div class='value'>
{{#if editingTitle}}
{{text-field value=model.title autofocus="autofocus"}}
{{text-field value=userTitleValue autofocus="autofocus"}}
{{else}}
<span {{action "toggleTitleEdit"}}>{{model.title}}&nbsp;</span>
{{/if}}