Contributor list improvements #11
@@ -43,8 +43,14 @@ export default Ember.Controller.extend({
|
|||||||
proposalsClosedSorted: Ember.computed.sort('proposalsClosed', 'proposalsSorting'),
|
proposalsClosedSorted: Ember.computed.sort('proposalsClosed', 'proposalsSorting'),
|
||||||
proposalsOpenSorted: Ember.computed.sort('proposalsOpen', 'proposalsSorting'),
|
proposalsOpenSorted: Ember.computed.sort('proposalsOpen', 'proposalsSorting'),
|
||||||
|
|
||||||
|
contributorsWithKredits: function() {
|
||||||
|
return this.get('model.contributors').filter(c => {
|
||||||
|
return c.get('kredits') !== 0;
|
||||||
|
});
|
||||||
|
}.property('model.contributors.[]'),
|
||||||
|
|
||||||
contributorsSorting: ['kredits:desc'],
|
contributorsSorting: ['kredits:desc'],
|
||||||
contributorsSorted: Ember.computed.sort('model.contributors', 'contributorsSorting'),
|
contributorsSorted: Ember.computed.sort('contributorsWithKredits', 'contributorsSorting'),
|
||||||
|
|
||||||
watchContractEvents: function() {
|
watchContractEvents: function() {
|
||||||
let events = this.get('kredits.kreditsContract')
|
let events = this.get('kredits.kreditsContract')
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ export default Ember.Route.extend({
|
|||||||
return Ember.RSVP.hash({
|
return Ember.RSVP.hash({
|
||||||
contributors: kredits.getContributors(),
|
contributors: kredits.getContributors(),
|
||||||
totalSupply: kredits.getValueFromContract('tokenContract', 'totalSupply'),
|
totalSupply: kredits.getValueFromContract('tokenContract', 'totalSupply'),
|
||||||
contributorsCount: kredits.getValueFromContract('kreditsContract', 'contributorsCount'),
|
|
||||||
proposals: kredits.getProposals()
|
proposals: kredits.getProposals()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
<p class="stats">
|
<p class="stats">
|
||||||
<span class="number">{{model.totalSupply}}</span> kredits issued and distributed among
|
<span class="number">{{model.totalSupply}}</span> kredits issued and distributed among
|
||||||
<span class="number">{{model.contributorsCount}}</span> contributors.
|
<span class="number">{{contributorsWithKredits.length}}</span> contributors.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@@ -1,11 +1,38 @@
|
|||||||
// import { moduleFor, test } from 'ember-qunit';
|
import Ember from 'ember';
|
||||||
//
|
import Contributor from 'kredits-web/models/contributor';
|
||||||
// moduleFor('controller:index', 'Unit | Controller | index');
|
import { moduleFor, test } from 'ember-qunit';
|
||||||
|
|
||||||
// let addFixtures = function(controller) {
|
const {
|
||||||
// controller.set('model', { contributors: [
|
isPresent,
|
||||||
// { github_username: "neo", github_uid: "318", kredits: 10000 },
|
isEmpty
|
||||||
// { github_username: "morpheus", github_uid: "843", kredits: 15000 },
|
} = Ember;
|
||||||
// { github_username: "mouse", github_uid: "842", kredits: 5000 },
|
|
||||||
// ]});
|
moduleFor('controller:index', 'Unit | Controller | index', {
|
||||||
// };
|
needs: ['service:ipfs', 'service:kredits']
|
||||||
|
});
|
||||||
|
|
||||||
|
let addFixtures = function(controller) {
|
||||||
|
controller.set('model', {
|
||||||
|
contributors: [],
|
||||||
|
proposals: []
|
||||||
|
});
|
||||||
|
|
||||||
|
[
|
||||||
|
{ github_username: "neo", github_uid: "318", kredits: 10000 },
|
||||||
|
{ github_username: "morpheus", github_uid: "843", kredits: 15000 },
|
||||||
|
{ github_username: "trinity", github_uid: "123", kredits: 5000 },
|
||||||
|
{ github_username: "mouse", github_uid: "696", kredits: 0 }
|
||||||
|
].forEach(fixture => {
|
||||||
|
controller.get('model.contributors').push(Contributor.create(fixture));
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
test('doesn\'t contain people with 0 kredits', function(assert) {
|
||||||
|
let controller = this.subject();
|
||||||
|
addFixtures(controller);
|
||||||
|
|
||||||
|
let contributorsSorted = controller.get('contributorsSorted');
|
||||||
|
|
||||||
|
assert.ok(isPresent(contributorsSorted.findBy('github_username', 'neo')));
|
||||||
|
assert.ok(isEmpty(contributorsSorted.findBy('github_username', 'mouse')));
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user