Show open/closed proposals

This commit is contained in:
2017-02-05 15:59:41 +08:00
parent 227c6f5c4b
commit c676c6ae68
6 changed files with 79 additions and 0 deletions
@@ -0,0 +1,5 @@
import Ember from 'ember';
export default Ember.Component.extend({
});
+11
View File
@@ -0,0 +1,11 @@
<ul>
{{#each proposals as |proposal|}}
<li>
Issue{{#if proposal.executed}}d{{/if}}
<span class="amount">{{proposal.amount}}</span>
<span class="symbol">₭S</span>
to
<span class="recipient">{{proposal.recipientName}}</span>
</li>
{{/each}}
</ul>
+26
View File
@@ -13,4 +13,30 @@ export default Ember.Controller.extend({
contractInteractionEnabled: computed.alias('kredits.web3Provided'), contractInteractionEnabled: computed.alias('kredits.web3Provided'),
proposalsOpen: function() {
let proposals = this.get('model.proposals')
.filterBy('executed', false)
.map(p => {
p.recipientName = this.findContributorByAddress(p.recipientAddress).github_username;
return p;
});
return proposals;
}.property('model.proposals.[]', 'model.contributors.[]'),
proposalsClosed: function() {
let proposals = this.get('model.proposals')
.filterBy('executed', true)
.map(p => {
p.recipientName = this.findContributorByAddress(p.recipientAddress).github_username;
return p;
});
return proposals;
}.property('model.proposals.[]', 'model.contributors.[]'),
findContributorByAddress(address) {
return this.get('model.contributors')
.findBy('address', address);
}
}); });
+1
View File
@@ -5,6 +5,7 @@ export default Ember.Object.extend({
github_username: null, github_username: null,
github_uid: null, github_uid: null,
kredits: null, kredits: null,
address: null,
avatarURL: function() { avatarURL: function() {
return `https\:\/\/avatars2.githubusercontent.com/u/${this.get('github_uid')}?v=3&s=128`; return `https\:\/\/avatars2.githubusercontent.com/u/${this.get('github_uid')}?v=3&s=128`;
+20
View File
@@ -13,6 +13,26 @@
</div> </div>
</section> </section>
{{#if proposalsOpen}}
<section id="proposals-open">
<header>
<h2>Open Proposals</h2>
</header>
<div class="content">
{{proposal-list proposals=proposalsOpen}}
</div>
</section>
{{/if}}
<section id="proposals-closed">
<header>
<h2>Closed Proposals</h2>
</header>
<div class="content">
{{proposal-list proposals=proposalsClosed}}
</div>
</section>
{{#if contractInteractionEnabled}} {{#if contractInteractionEnabled}}
<section id="add-contributor"> <section id="add-contributor">
<header> <header>
@@ -0,0 +1,16 @@
import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';
moduleForComponent('proposal-list', 'Integration | Component | proposal list', {
integration: true
});
test('it renders', function(assert) {
// Set any properties with this.set('myProperty', 'value');
// Handle any actions with this.on('myAction', function(val) { ... });
this.render(hbs`{{proposal-list}}`);
assert.equal(this.$().text().trim(), '');
});