2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-09-06 10:50:21 +08:00
discourse/app/assets/javascripts/discourse/controllers/badges/index.js.es6
Sam fe51f84aa7 FEATURE: allow admins to enter badge long descriptions
FIX: fallback to description if badge long description is missing

Also moves all badge localization into server.en, this slims the client down

serializers pass down localized names/descriptions/long descriptions
2016-03-28 18:38:57 +11:00

32 lines
868 B
JavaScript

export default Ember.Controller.extend({
badgeGroups: function(){
var sorted = _.sortBy(this.get('model'), function(badge){
var pos = badge.get('badge_grouping.position');
var type = badge.get('badge_type_id');
var name = badge.get('name');
return ("000" + pos).slice(-4) + (10-type) + name;
});
var grouped = [];
var group = [], groupId;
sorted.forEach(function(badge){
if(groupId !== badge.badge_grouping_id){
if(group && group.length > 0){
grouped.push({badges: group, badgeGrouping: group[0].badge_grouping});
}
group = [];
groupId = badge.badge_grouping_id;
}
group.push(badge);
});
if(group && group.length > 0){
grouped.push({badges: group, badgeGrouping: group[0].badge_grouping});
}
return grouped;
}.property('model')
});