Load more users on badge pages using infinite scrolling instead of a

button.
This commit is contained in:
Vikhyat Korrapati 2014-05-18 12:42:47 +05:30
parent 8fe8e66280
commit abd5263671
3 changed files with 17 additions and 10 deletions

View File

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

View File

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