Veto contributions #113

Merged
raucao merged 5 commits from feature/98-veto_unconfirmed_contributions into master 2019-05-01 18:43:29 +00:00
4 changed files with 31 additions and 23 deletions
Showing only changes of commit e1737392a7 - Show all commits
@@ -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">
raucao commented 2019-04-28 14:31:12 +00:00 (Migrated from github.com)
Review

This is a bit of a hack. It shouldn't required the if for 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 contribution vetoed to true. :/

@galfert @fsmanuel Any idea if that's an inherent limitation of helpers, or if I did something wrong?

This is a bit of a hack. It shouldn't required the `if` for 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 contribution `vetoed` to true. :/ @galfert @fsmanuel Any idea if that's an inherent limitation of helpers, or if I did something wrong?
galfert commented 2019-04-29 11:48:39 +00:00 (Migrated from github.com)
Review

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:

  1. Pass the two properties that the helper is using directly as parameters (contribution-status contribution.vetoed contribution.confirmedAt).

  2. Create a component for the contribution (e.g. contribution-item). This way the component can have a computed property for the class.

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: 1. Pass the two properties that the helper is using directly as parameters (`contribution-status contribution.vetoed contribution.confirmedAt`). 2. Create a component for the contribution (e.g. `contribution-item`). This way the component can have a computed property for the class.
raucao commented 2019-04-29 12:16:35 +00:00 (Migrated from github.com)
Review

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-boostrap instead of our handrolled everything, because otherwise we spend too much time re-inventing the wheel for all the various UI components.

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-boostrap` instead of our handrolled everything, because otherwise we spend too much time re-inventing the wheel for all the various UI components.
galfert commented 2019-04-29 12:17:46 +00:00 (Migrated from github.com)
Review

I like version 2 better as well.

I like version 2 better as well.
<span class="recipient">{{user-avatar contributor=contribution.contributor}}</span>
<span class="category {{contribution.kind}}">({{contribution.kind}})</span>
+2 -2
View File
@@ -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
View File
2
@@ -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);
+15 -14
View File
@@ -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;
}
}
}