Merge pull request #50 from 67P/refactor/naming-conventions
Refactor/naming conventions
This commit was merged in pull request #50.
This commit is contained in:
@@ -8,7 +8,7 @@ export default Component.extend({
|
||||
|
||||
// Default attributes used by reset
|
||||
attributes: {
|
||||
recipientId: null,
|
||||
contributorId: null,
|
||||
kind: 'community',
|
||||
amount: null,
|
||||
description: null,
|
||||
@@ -22,7 +22,7 @@ export default Component.extend({
|
||||
|
||||
contributors: [],
|
||||
|
||||
isValidRecipient: isPresent('recipientId'),
|
||||
isValidRecipient: isPresent('contributorId'),
|
||||
isValidAmount: computed('amount', function() {
|
||||
return parseInt(this.get('amount'), 10) > 0;
|
||||
}),
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<form {{action "submit" on="submit"}}>
|
||||
<p>
|
||||
<select required onchange={{action (mut recipientId) value="target.value"}}>
|
||||
<select required onchange={{action (mut contributorId) value="target.value"}}>
|
||||
<option value="" selected disabled hidden>Contributor</option>
|
||||
{{#each contributors as |contributor|}}
|
||||
<option value={{contributor.id}} selected={{eq recipientId contributor.id}}>{{contributor.github_username}}</option>
|
||||
<option value={{contributor.id}} selected={{eq contributorId contributor.id}}>{{contributor.github_username}}</option>
|
||||
{{/each}}
|
||||
</select>
|
||||
</p>
|
||||
|
||||
@@ -26,7 +26,7 @@ export default Controller.extend({
|
||||
return this.get('model.proposals')
|
||||
.map((proposal) => {
|
||||
let contributor = this.get('contributors')
|
||||
.findBy('id', proposal.get('recipientId'));
|
||||
.findBy('id', proposal.get('contributorId'));
|
||||
|
||||
proposal.set('contributor', contributor);
|
||||
|
||||
@@ -52,10 +52,9 @@ export default Controller.extend({
|
||||
this.get('proposals').pushObject(proposal);
|
||||
},
|
||||
|
||||
_handleProposalExecuted(proposalId, recipientId, amount) {
|
||||
// TODO: check if proposalId is already a string
|
||||
_handleProposalExecuted(proposalId, contributorId, amount) {
|
||||
let proposal = this.get('proposals')
|
||||
.findBy('id', proposalId.toString());
|
||||
.findBy('id', proposalId);
|
||||
|
||||
if (proposal.get('isExecuted')) {
|
||||
Ember.Logger.debug('[index] proposal already executed, not adding from event');
|
||||
@@ -67,13 +66,13 @@ export default Controller.extend({
|
||||
});
|
||||
|
||||
this.get('contributors')
|
||||
.findBy('id', recipientId.toString())
|
||||
.findBy('id', contributorId)
|
||||
.incrementProperty('balance', amount);
|
||||
},
|
||||
|
||||
_handleProposalVoted(proposalId, voter, totalVotes) {
|
||||
this.get('proposals')
|
||||
.findBy('id', proposalId.toString())
|
||||
.findBy('id', proposalId)
|
||||
.setProperties({ 'votesCount': totalVotes });
|
||||
},
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ export default Controller.extend({
|
||||
actions: {
|
||||
save(proposal) {
|
||||
// contributorIpfsHash is needed for the proposal ipfs data. I'm not happy to do this here but I think to load all the contributors in addProposal again is a bit too much. I hope we can refactor it later.
|
||||
let contributor = this.get('contributors').findBy('id', proposal.recipientId);
|
||||
let contributor = this.get('contributors').findBy('id', proposal.contributorId);
|
||||
proposal.contributorIpfsHash = contributor.get('ipfsHash');
|
||||
|
||||
return this.get('kredits').addProposal(proposal)
|
||||
|
||||
@@ -47,7 +47,7 @@ export default class Operator extends Base {
|
||||
.add(json)
|
||||
.then((ipfsHashAttr) => {
|
||||
let proposal = [
|
||||
proposalAttr.recipientId,
|
||||
proposalAttr.contributorId,
|
||||
proposalAttr.amount,
|
||||
ipfsHashAttr.ipfsHash,
|
||||
ipfsHashAttr.hashFunction,
|
||||
|
||||
@@ -5,8 +5,8 @@ import bignumber from 'kredits-web/utils/cps/bignumber';
|
||||
export default EmberObject.extend({
|
||||
// Contract
|
||||
id: bignumber('idRaw', 'toString'),
|
||||
creatorAddress: null,
|
||||
recipientId: bignumber('recipientIdRaw', 'toString'),
|
||||
creatorAccount: null,
|
||||
contributorId: bignumber('contributorIdRaw', 'toString'),
|
||||
amount: bignumber('amountRaw', 'toNumber'),
|
||||
votesCount: bignumber('votesCountRaw', 'toNumber'),
|
||||
votesNeeded: bignumber('votesNeededRaw', 'toNumber'),
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import computed from 'ember-computed';
|
||||
import ethers from 'npm:ethers';
|
||||
|
||||
export default function(dependentKey, converterMethod) {
|
||||
return computed(dependentKey, {
|
||||
@@ -6,6 +7,7 @@ export default function(dependentKey, converterMethod) {
|
||||
return this.get(dependentKey)[converterMethod]();
|
||||
},
|
||||
set (key, value) {
|
||||
value = ethers.utils.bigNumberify(value);
|
||||
this.set(dependentKey, value);
|
||||
return value[converterMethod]();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user