Veto contributions #113
@@ -1,5 +1,5 @@
|
||||
{{#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">
|
||||
|
|
||||
<span class="recipient">{{user-avatar contributor=contribution.contributor}}</span>
|
||||
<span class="category {{contribution.kind}}">({{contribution.kind}})</span>
|
||||
|
||||
@@ -35,13 +35,13 @@ export default Controller.extend({
|
||||
|
||||
vetoContribution (contributionId) {
|
||||
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) {
|
||||
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());
|
||||
},
|
||||
|
||||
findContributionById(contributionId) {
|
||||
return this.contributions.findBy('id', contributionId.toString());
|
||||
},
|
||||
|
||||
// Contract events
|
||||
addContractEventHandlers() {
|
||||
// Proposal events
|
||||
this.kredits.Contribution
|
||||
.on('ContributionVetoed', this.handleContributionVetoed.bind(this))
|
||||
|
||||
this.kredits.Proposal
|
||||
.on('ProposalCreated', this.handleProposalCreated.bind(this))
|
||||
.on('ProposalVoted', this.handleProposalVoted.bind(this))
|
||||
.on('ProposalExecuted', this.handleProposalExecuted.bind(this));
|
||||
|
||||
// Token events
|
||||
this.kredits.Token
|
||||
.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) {
|
||||
let proposal = this.findProposalById(proposalId);
|
||||
|
||||
|
||||
@@ -13,13 +13,27 @@ ul.contribution-list {
|
||||
|
||||
li {
|
||||
display: grid;
|
||||
grid-template-columns: auto 5rem;
|
||||
grid-template-columns: auto 5rem 5rem;
|
||||
grid-row-gap: 0.5rem;
|
||||
padding: 1rem 1.2rem;
|
||||
background-color: rgba(255,255,255,0.1);
|
||||
font-size: 1.2rem;
|
||||
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 {
|
||||
align-self: center;
|
||||
margin: 0;
|
||||
@@ -80,19 +94,6 @@ ul.contribution-list {
|
||||
color: $primary-color;
|
||||
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
This is a bit of a hack. It shouldn't required the
iffor the second class. But apparently with the helper, it doesn't bind the contribution property updates, so the value stays the same after setting the contributionvetoedto true. :/@galfert @fsmanuel Any idea if that's an inherent limitation of helpers, or if I did something wrong?
Mmh, indeed it looks like when passing objects to a helper, it doesn't recalculate when one of the object's properties changes.
I see two options:
Pass the two properties that the helper is using directly as parameters (
contribution-status contribution.vetoed contribution.confirmedAt).Create a component for the contribution (e.g.
contribution-item). This way the component can have a computed property for the class.Thanks!
I think version 2 is better, but that it should be done when refactoring the UI soon. I think we'll want to use something like
ember-boostrapinstead of our handrolled everything, because otherwise we spend too much time re-inventing the wheel for all the various UI components.I like version 2 better as well.