mirror of
https://github.com/discourse/discourse.git
synced 2024-11-29 20:24:05 -06:00
Merge pull request #2354 from vikhyat/badge-system
Badge system updates
This commit is contained in:
commit
9e3c08b5ee
@ -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) {
|
||||
|
@ -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')
|
||||
});
|
||||
|
@ -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}}
|
||||
|
11
app/assets/javascripts/discourse/views/badges_show_view.js
Normal file
11
app/assets/javascripts/discourse/views/badges_show_view.js
Normal 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'
|
||||
});
|
Loading…
Reference in New Issue
Block a user