FIX: Unable to remove existing user title (#5386)

This commit is contained in:
Vinoth Kannan 2017-11-30 20:24:38 +05:30 committed by Régis Hanol
parent fb735d78ef
commit 704dbd7cfc
2 changed files with 4 additions and 21 deletions

View File

@ -11,9 +11,11 @@ export default Ember.Component.extend(BadgeSelectController, {
save() {
this.setProperties({ saved: false, saving: true });
var badge_id = this.get('selectedUserBadgeId') || 0;
ajax(this.get('user.path') + "/preferences/badge_title", {
type: "PUT",
data: { user_badge_id: this.get('selectedUserBadgeId') }
data: { user_badge_id: badge_id }
}).then(() => {
this.setProperties({
saved: true,

View File

@ -1,28 +1,9 @@
import { ajax } from 'discourse/lib/ajax';
import BadgeSelectController from "discourse/mixins/badge-select-controller";
export default Ember.Controller.extend(BadgeSelectController, {
filteredList: function() {
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'));
});
}
}
});