FIX: Unable to remove existing user title (#5386)
This commit is contained in:
parent
fb735d78ef
commit
704dbd7cfc
|
@ -11,9 +11,11 @@ export default Ember.Component.extend(BadgeSelectController, {
|
||||||
save() {
|
save() {
|
||||||
this.setProperties({ saved: false, saving: true });
|
this.setProperties({ saved: false, saving: true });
|
||||||
|
|
||||||
|
var badge_id = this.get('selectedUserBadgeId') || 0;
|
||||||
|
|
||||||
ajax(this.get('user.path') + "/preferences/badge_title", {
|
ajax(this.get('user.path') + "/preferences/badge_title", {
|
||||||
type: "PUT",
|
type: "PUT",
|
||||||
data: { user_badge_id: this.get('selectedUserBadgeId') }
|
data: { user_badge_id: badge_id }
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
this.setProperties({
|
this.setProperties({
|
||||||
saved: true,
|
saved: true,
|
||||||
|
|
|
@ -1,28 +1,9 @@
|
||||||
import { ajax } from 'discourse/lib/ajax';
|
|
||||||
import BadgeSelectController from "discourse/mixins/badge-select-controller";
|
import BadgeSelectController from "discourse/mixins/badge-select-controller";
|
||||||
|
|
||||||
export default Ember.Controller.extend(BadgeSelectController, {
|
export default Ember.Controller.extend(BadgeSelectController, {
|
||||||
|
|
||||||
filteredList: function() {
|
filteredList: function() {
|
||||||
return this.get('model').filterBy('badge.allow_title', true);
|
return this.get('model').filterBy('badge.allow_title', true);
|
||||||
}.property('model'),
|
}.property('model')
|
||||||
|
|
||||||
actions: {
|
|
||||||
save() {
|
|
||||||
this.setProperties({ saved: false, saving: true });
|
|
||||||
|
|
||||||
ajax(this.get('user.path') + "/preferences/badge_title", {
|
|
||||||
type: "PUT",
|
|
||||||
data: { user_badge_id: this.get('selectedUserBadgeId') }
|
|
||||||
}).then(() => {
|
|
||||||
this.setProperties({
|
|
||||||
saved: true,
|
|
||||||
saving: false,
|
|
||||||
"user.title": this.get('selectedUserBadge.badge.name')
|
|
||||||
});
|
|
||||||
}, () => {
|
|
||||||
bootbox.alert(I18n.t('generic_error'));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue