mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 23:54:16 +08:00
FIX: Cancelling a title change does not revert the value
This commit is contained in:
parent
7d9f2265b9
commit
374657d9d5
|
@ -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');
|
||||
});
|
||||
},
|
||||
|
||||
|
|
|
@ -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}} </span>
|
||||
{{/if}}
|
||||
|
|
Loading…
Reference in New Issue
Block a user