FIX: Badge loading more was stuck
This commit is contained in:
parent
9e9c81c30b
commit
d129c61a4a
|
@ -1,4 +1,5 @@
|
||||||
import UserBadge from 'discourse/models/user-badge';
|
import UserBadge from 'discourse/models/user-badge';
|
||||||
|
import computed from 'ember-addons/ember-computed-decorators';
|
||||||
|
|
||||||
export default Ember.Controller.extend({
|
export default Ember.Controller.extend({
|
||||||
queryParams: ['username'],
|
queryParams: ['username'],
|
||||||
|
@ -22,30 +23,25 @@ export default Ember.Controller.extend({
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
loadMore() {
|
loadMore() {
|
||||||
const self = this;
|
|
||||||
const userBadges = this.get('userBadges');
|
const userBadges = this.get('userBadges');
|
||||||
|
|
||||||
UserBadge.findByBadgeId(this.get('model.id'), {
|
UserBadge.findByBadgeId(this.get('model.id'), {
|
||||||
offset: userBadges.length,
|
offset: userBadges.length,
|
||||||
username: this.get('username'),
|
username: this.get('username'),
|
||||||
}).then(function(result) {
|
}).then(result => {
|
||||||
userBadges.pushObjects(result);
|
userBadges.pushObjects(result);
|
||||||
if(userBadges.length === 0){
|
if (userBadges.length === 0){
|
||||||
self.set('noMoreBadges', true);
|
this.set('noMoreBadges', true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
canLoadMore: function() {
|
@computed('noMoreBadges', 'model.grant_count', 'userBadges.length')
|
||||||
if (this.get('noMoreBadges')) { return false; }
|
canLoadMore(noMoreBadges, grantCount, userBadgeLength) {
|
||||||
|
if (noMoreBadges) { return false; }
|
||||||
if (this.get('userBadges')) {
|
return grantCount > (userBadgeLength || 0);
|
||||||
return this.get('grantCount') > this.get('userBadges.length');
|
},
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}.property('noMoreBadges', 'model.grant_count', 'userBadges.length'),
|
|
||||||
|
|
||||||
_showFooter: function() {
|
_showFooter: function() {
|
||||||
this.set("controllers.application.showFooter", !this.get("canLoadMore"));
|
this.set("controllers.application.showFooter", !this.get("canLoadMore"));
|
||||||
|
|
|
@ -2,12 +2,12 @@ import Eyeline from 'discourse/lib/eyeline';
|
||||||
import Scrolling from 'discourse/mixins/scrolling';
|
import Scrolling from 'discourse/mixins/scrolling';
|
||||||
import { on } from 'ember-addons/ember-computed-decorators';
|
import { on } from 'ember-addons/ember-computed-decorators';
|
||||||
|
|
||||||
// Provides the ability to load more items for a view which is scrolled to the bottom.
|
// Provides the ability to load more items for a view which is scrolled to the bottom.
|
||||||
export default Ember.Mixin.create(Ember.ViewTargetActionSupport, Scrolling, {
|
export default Ember.Mixin.create(Ember.ViewTargetActionSupport, Scrolling, {
|
||||||
|
|
||||||
scrolled() {
|
scrolled() {
|
||||||
const eyeline = this.get('eyeline');
|
const eyeline = this.get('eyeline');
|
||||||
if (eyeline) { eyeline.update(); }
|
return eyeline && eyeline.update();
|
||||||
},
|
},
|
||||||
|
|
||||||
loadMoreUnlessFull() {
|
loadMoreUnlessFull() {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import LoadMore from "discourse/mixins/load-more";
|
import LoadMore from "discourse/mixins/load-more";
|
||||||
|
|
||||||
export default Ember.View.extend(LoadMore, {
|
export default Ember.View.extend(LoadMore, {
|
||||||
eyelineSelector: '.badge-user',
|
eyelineSelector: '.badge-info',
|
||||||
tickOrX: function(field){
|
tickOrX: function(field){
|
||||||
var icon = this.get('controller.model.' + field) ? "fa-check" : "fa-times";
|
var icon = this.get('controller.model.' + field) ? "fa-check" : "fa-times";
|
||||||
return "<i class='fa " + icon + "'></i>";
|
return "<i class='fa " + icon + "'></i>";
|
||||||
|
|
Loading…
Reference in New Issue