Vote for proposals from the UI
This commit is contained in:
@@ -3,6 +3,14 @@ import Ember from 'ember';
|
||||
export default Ember.Component.extend({
|
||||
|
||||
tagName: 'ul',
|
||||
classNames: ['proposal-list']
|
||||
classNames: ['proposal-list'],
|
||||
|
||||
actions: {
|
||||
|
||||
confirm(proposalId) {
|
||||
this.sendAction('confirmAction', proposalId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@@ -6,6 +6,6 @@
|
||||
to <span class="recipient" title="{{proposal.recipientAddress}}">{{proposal.recipientName}}</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>
|
||||
{{/each}}
|
||||
|
||||
@@ -36,7 +36,16 @@ export default Ember.Controller.extend({
|
||||
findContributorByAddress(address) {
|
||||
return this.get('model.contributors')
|
||||
.findBy('address', address);
|
||||
},
|
||||
|
||||
actions: {
|
||||
|
||||
confirmProposal(proposalId) {
|
||||
this.get('kredits').vote(proposalId).then(transactionId => {
|
||||
window.confirm('Vote submitted to Ethereum blockhain: '+transactionId);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
@@ -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() {
|
||||
Ember.Logger.debug('[kredits] kreditsContract', this.get('kreditsContract'));
|
||||
}.on('init')
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<h2>Open Proposals</h2>
|
||||
</header>
|
||||
<div class="content">
|
||||
{{proposal-list proposals=proposalsOpen}}
|
||||
{{proposal-list proposals=proposalsOpen confirmAction="confirmProposal"}}
|
||||
</div>
|
||||
</section>
|
||||
{{/if}}
|
||||
@@ -30,7 +30,7 @@
|
||||
<h2>Closed Proposals</h2>
|
||||
</header>
|
||||
<div class="content">
|
||||
{{proposal-list proposals=proposalsClosed}}
|
||||
{{proposal-list proposals=proposalsClosed confirmAction="confirmProposal"}}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user