Vote for proposals from the UI

This commit is contained in:
2017-02-05 17:31:36 +08:00
parent aaa1102563
commit 79412e2032
5 changed files with 33 additions and 5 deletions
+9 -1
View File
@@ -3,6 +3,14 @@ import Ember from 'ember';
export default Ember.Component.extend({ export default Ember.Component.extend({
tagName: 'ul', tagName: 'ul',
classNames: ['proposal-list'] classNames: ['proposal-list'],
actions: {
confirm(proposalId) {
this.sendAction('confirmAction', proposalId);
}
}
}); });
+1 -1
View File
@@ -6,6 +6,6 @@
to <span class="recipient" title="{{proposal.recipientAddress}}">{{proposal.recipientName}}</span> to <span class="recipient" title="{{proposal.recipientAddress}}">{{proposal.recipientName}}</span>
<span class="votes">({{proposal.votesCount}}/{{proposal.votesNeeded}} votes)</span> <span class="votes">({{proposal.votesCount}}/{{proposal.votesNeeded}} votes)</span>
<button {{action "confirm"}}>+1</button> {{#unless proposal.executed}}<button {{action "confirm" proposal.id}}>+1</button>{{/unless}}
</li> </li>
{{/each}} {{/each}}
+9
View File
@@ -36,7 +36,16 @@ export default Ember.Controller.extend({
findContributorByAddress(address) { findContributorByAddress(address) {
return this.get('model.contributors') return this.get('model.contributors')
.findBy('address', address); .findBy('address', address);
},
actions: {
confirmProposal(proposalId) {
this.get('kredits').vote(proposalId).then(transactionId => {
window.confirm('Vote submitted to Ethereum blockhain: '+transactionId);
});
} }
}
}); });
+11
View File
@@ -116,6 +116,17 @@ export default Ember.Service.extend({
}); });
}, },
vote(proposalId) {
Ember.Logger.debug('[kredits] vote for', proposalId);
return new Ember.RSVP.Promise((resolve, reject) => {
this.get('kreditsContract').vote(proposalId, (err, data) => {
if (err) { reject(err); }
Ember.Logger.debug('[kredits] vote response', data);
resolve(data);
});
});
},
logKreditsContract: function() { logKreditsContract: function() {
Ember.Logger.debug('[kredits] kreditsContract', this.get('kreditsContract')); Ember.Logger.debug('[kredits] kreditsContract', this.get('kreditsContract'));
}.on('init') }.on('init')
+2 -2
View File
@@ -20,7 +20,7 @@
<h2>Open Proposals</h2> <h2>Open Proposals</h2>
</header> </header>
<div class="content"> <div class="content">
{{proposal-list proposals=proposalsOpen}} {{proposal-list proposals=proposalsOpen confirmAction="confirmProposal"}}
</div> </div>
</section> </section>
{{/if}} {{/if}}
@@ -30,7 +30,7 @@
<h2>Closed Proposals</h2> <h2>Closed Proposals</h2>
</header> </header>
<div class="content"> <div class="content">
{{proposal-list proposals=proposalsClosed}} {{proposal-list proposals=proposalsClosed confirmAction="confirmProposal"}}
</div> </div>
</section> </section>