Only show unique badge titles in the Badge Title dropdown

Filter the preference Badge Title to only show unique badge title names.
https://meta.discourse.org/t/set-title-dialog-shows-multiple-instances-of-the-same-badge/19071
This commit is contained in:
cpradio 2014-08-19 20:59:20 -04:00
parent bf5563e2fc
commit 04cd3c0551
1 changed files with 3 additions and 1 deletions

View File

@ -19,7 +19,9 @@ export default Ember.ArrayController.extend({
}.property('saving'),
selectableUserBadges: function() {
var items = this.get('model').filterBy('badge.allow_title', true);
var items = new Array();
this.get('model').filterBy('badge.allow_title', true).forEach(function(item, index, arr) {
if(!items.findBy('badge.name', item.badge.name)) items.push(item); });
items.unshiftObject(Em.Object.create({
badge: Discourse.Badge.create({name: I18n.t('badges.no_title')})
}));