Implement batch voting
This commit is contained in:
@@ -1,20 +1,23 @@
|
||||
import Component from '@ember/component';
|
||||
import { inject } from '@ember/service';
|
||||
import { empty } from '@ember/object/computed';
|
||||
|
||||
export default Component.extend({
|
||||
kredits: inject(),
|
||||
|
||||
tagName: 'ul',
|
||||
classNames: ['proposal-list'],
|
||||
|
||||
selectedProposals: [],
|
||||
submitButtonDisabled: empty('selectedProposals'),
|
||||
|
||||
actions: {
|
||||
|
||||
confirm(proposalId) {
|
||||
if (this.contractInteractionEnabled) {
|
||||
this.confirmProposal(proposalId);
|
||||
toggleSelect(proposalId, selected) {
|
||||
if (selected) {
|
||||
this.selectedProposals.removeObject(proposalId);
|
||||
} else {
|
||||
window.alert('Only members can vote on proposals. Please ask someone to set you up.');
|
||||
this.selectedProposals.addObject(proposalId);
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@@ -1,12 +1,18 @@
|
||||
{{#each proposals as |proposal|}}
|
||||
<li data-proposal-id={{proposal.id}} title="({{proposal.kind}}) {{proposal.description}}">
|
||||
<span class="category {{proposal.kind}}">♥</span>
|
||||
<span class="amount">{{proposal.amount}}</span><span class="symbol">₭S</span>
|
||||
for <span class="recipient">{{proposal.contributor.name}}</span>
|
||||
<span class="votes">({{proposal.votesCount}}/{{proposal.votesNeeded}} votes)</span>
|
||||
|
||||
{{#unless proposal.isExecuted}}
|
||||
<button {{action "confirm" proposal.id}}>+1</button>
|
||||
{{/unless}}
|
||||
</li>
|
||||
{{proposal-list/item
|
||||
proposal=proposal
|
||||
selectedProposals=selectedProposals
|
||||
toggleSelect=(action 'toggleSelect')
|
||||
}}
|
||||
{{/each}}
|
||||
|
||||
{{#if confirmProposals}}
|
||||
<center>
|
||||
<button
|
||||
disabled={{submitButtonDisabled}}
|
||||
{{action confirmProposals selectedProposals}}
|
||||
>
|
||||
Submit selected
|
||||
</button>
|
||||
</center>
|
||||
{{/if}}
|
||||
|
||||
Reference in New Issue
Block a user