From 704dbd7cfc514054ca5e22fd194036d1640a543a Mon Sep 17 00:00:00 2001 From: Vinoth Kannan Date: Thu, 30 Nov 2017 20:24:38 +0530 Subject: [PATCH] FIX: Unable to remove existing user title (#5386) --- .../discourse/components/badge-title.js.es6 | 4 +++- .../preferences/badge-title.js.es6 | 21 +------------------ 2 files changed, 4 insertions(+), 21 deletions(-) diff --git a/app/assets/javascripts/discourse/components/badge-title.js.es6 b/app/assets/javascripts/discourse/components/badge-title.js.es6 index 95da5718bbc..322db1f6c20 100644 --- a/app/assets/javascripts/discourse/components/badge-title.js.es6 +++ b/app/assets/javascripts/discourse/components/badge-title.js.es6 @@ -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, diff --git a/app/assets/javascripts/discourse/controllers/preferences/badge-title.js.es6 b/app/assets/javascripts/discourse/controllers/preferences/badge-title.js.es6 index f2c543e6be6..c39fb863956 100644 --- a/app/assets/javascripts/discourse/controllers/preferences/badge-title.js.es6 +++ b/app/assets/javascripts/discourse/controllers/preferences/badge-title.js.es6 @@ -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')); - }); - } - } });