Merge pull request #2354 from vikhyat/badge-system

Badge system updates
This commit is contained in:
Sam 2014-05-18 20:03:20 +10:00
commit 9e3c08b5ee
4 changed files with 22 additions and 11 deletions

View File

@ -1,7 +1,11 @@
Discourse.AdminBadgesRoute = Discourse.Route.extend({
model: function() {
return Discourse.Badge.findAll();
return Discourse.Badge.findAll().then(function(badges) {
return badges.filter(function(badge) {
return badge.id >= 100;
});
});
},
setupController: function(controller, model) {

View File

@ -10,13 +10,11 @@ export default Discourse.ObjectController.extend({
grantDates: Em.computed.mapBy('userBadges', 'grantedAt'),
minGrantedAt: Em.computed.min('grantDates'),
moreUserCount: function() {
canLoadMore: function() {
if (this.get('userBadges')) {
return this.get('model.grant_count') - this.get('userBadges.length');
return this.get('model.grant_count') > this.get('userBadges.length');
} else {
return 0;
return false;
}
}.property('model.grant_count', 'userBadges.length'),
showMoreUsers: Em.computed.gt('moreUserCount', 0)
}.property('model.grant_count', 'userBadges.length')
});

View File

@ -27,10 +27,8 @@
{{/link-to}}
{{/each}}
</div>
{{#if showMoreUsers}}
<button class="btn" {{action loadMore}}>
{{countI18n badges.more_badges count=moreUserCount}}
</button>
{{#if canLoadMore}}
<div class='spinner'>{{i18n loading}}</div>
{{/if}}
{{else}}
{{#unless userBadgesLoaded}}

View File

@ -0,0 +1,11 @@
/**
View for showing a particular badge.
@class BadgesShowView
@extends Discourse.View
@namespace Discourse
@module Discourse
**/
Discourse.BadgesShowView = Discourse.View.extend(Discourse.LoadMore, {
eyelineSelector: '.badge-user'
});