Mark contributions as vetoed on incoming event
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
{{#each contributions as |contribution|}}
|
{{#each contributions as |contribution|}}
|
||||||
<li data-contribution-id={{contribution.id}} class={{contribution-status contribution}}>
|
<li data-contribution-id={{contribution.id}} class="{{contribution-status contribution}} {{if contribution.vetoed "vetoed"}}">
|
||||||
<p class="meta">
|
<p class="meta">
|
||||||
<span class="recipient">{{user-avatar contributor=contribution.contributor}}</span>
|
<span class="recipient">{{user-avatar contributor=contribution.contributor}}</span>
|
||||||
<span class="category {{contribution.kind}}">({{contribution.kind}})</span>
|
<span class="category {{contribution.kind}}">({{contribution.kind}})</span>
|
||||||
|
|||||||
@@ -35,13 +35,13 @@ export default Controller.extend({
|
|||||||
|
|
||||||
vetoContribution (contributionId) {
|
vetoContribution (contributionId) {
|
||||||
this.kredits.veto(contributionId).then(transaction => {
|
this.kredits.veto(contributionId).then(transaction => {
|
||||||
window.confirm('Veto submitted to Ethereum blockhain: '+transaction.hash);
|
console.debug('[controllers:index] Veto submitted to Ethereum blockhain: '+transaction.hash);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
confirmProposal (proposalId) {
|
confirmProposal (proposalId) {
|
||||||
this.kredits.vote(proposalId).then(transaction => {
|
this.kredits.vote(proposalId).then(transaction => {
|
||||||
window.confirm('Vote submitted to Ethereum blockhain: '+transaction.hash);
|
console.debug('[controllers:index] Vote submitted to Ethereum blockhain: '+transaction.hash);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
+13
-6
@@ -220,23 +220,30 @@ export default Service.extend({
|
|||||||
return this.proposals.findBy('id', proposalId.toString());
|
return this.proposals.findBy('id', proposalId.toString());
|
||||||
},
|
},
|
||||||
|
|
||||||
findContributionById(contributionId) {
|
|
||||||
return this.contributions.findBy('id', contributionId.toString());
|
|
||||||
},
|
|
||||||
|
|
||||||
// Contract events
|
// Contract events
|
||||||
addContractEventHandlers() {
|
addContractEventHandlers() {
|
||||||
// Proposal events
|
this.kredits.Contribution
|
||||||
|
.on('ContributionVetoed', this.handleContributionVetoed.bind(this))
|
||||||
|
|
||||||
this.kredits.Proposal
|
this.kredits.Proposal
|
||||||
.on('ProposalCreated', this.handleProposalCreated.bind(this))
|
.on('ProposalCreated', this.handleProposalCreated.bind(this))
|
||||||
.on('ProposalVoted', this.handleProposalVoted.bind(this))
|
.on('ProposalVoted', this.handleProposalVoted.bind(this))
|
||||||
.on('ProposalExecuted', this.handleProposalExecuted.bind(this));
|
.on('ProposalExecuted', this.handleProposalExecuted.bind(this));
|
||||||
|
|
||||||
// Token events
|
|
||||||
this.kredits.Token
|
this.kredits.Token
|
||||||
.on('Transfer', this.handleTransfer.bind(this));
|
.on('Transfer', this.handleTransfer.bind(this));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
handleContributionVetoed(contributionId) {
|
||||||
|
console.debug('[kredits] ContributionVetoed event received for ', contributionId);
|
||||||
|
const contribution = this.contributions.findBy('id', contributionId);
|
||||||
|
console.debug('[kredits] contribution', contribution);
|
||||||
|
|
||||||
|
if (contribution) {
|
||||||
|
contribution.set('vetoed', true);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
handleProposalCreated(proposalId) {
|
handleProposalCreated(proposalId) {
|
||||||
let proposal = this.findProposalById(proposalId);
|
let proposal = this.findProposalById(proposalId);
|
||||||
|
|
||||||
|
|||||||
@@ -13,13 +13,27 @@ ul.contribution-list {
|
|||||||
|
|
||||||
li {
|
li {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: auto 5rem;
|
grid-template-columns: auto 5rem 5rem;
|
||||||
grid-row-gap: 0.5rem;
|
grid-row-gap: 0.5rem;
|
||||||
padding: 1rem 1.2rem;
|
padding: 1rem 1.2rem;
|
||||||
background-color: rgba(255,255,255,0.1);
|
background-color: rgba(255,255,255,0.1);
|
||||||
font-size: 1.2rem;
|
font-size: 1.2rem;
|
||||||
border-bottom: 1px solid rgba(255,255,255,0.2);
|
border-bottom: 1px solid rgba(255,255,255,0.2);
|
||||||
|
|
||||||
|
&:first-of-type {
|
||||||
|
border-top: 1px solid rgba(255,255,255,0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
&.confirmed {
|
||||||
|
grid-template-columns: auto 5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.vetoed {
|
||||||
|
grid-template-columns: auto 5rem;
|
||||||
|
text-decoration: line-through;
|
||||||
|
opacity: 0.6;
|
||||||
|
}
|
||||||
|
|
||||||
p {
|
p {
|
||||||
align-self: center;
|
align-self: center;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
@@ -80,19 +94,6 @@ ul.contribution-list {
|
|||||||
color: $primary-color;
|
color: $primary-color;
|
||||||
margin-right: 0.5rem;
|
margin-right: 0.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
&:first-of-type {
|
|
||||||
border-top: 1px solid rgba(255,255,255,0.2);
|
|
||||||
}
|
|
||||||
|
|
||||||
&.unconfirmed {
|
|
||||||
grid-template-columns: auto 5rem 5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.vetoed {
|
|
||||||
text-decoration: line-through;
|
|
||||||
opacity: 0.6;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user