Files
kredits-web/app/models/proposal.js
T
fsmanuel 99bbcda709 Move contributors + proposals to service
With this change we have all the contributors + proposals all the time in one place and can update them via events.
2018-04-15 19:02:57 +02:00

35 lines
1007 B
JavaScript

import EmberObject from 'ember-object';
import computed, { alias } from 'ember-computed';
import injectService from 'ember-service/inject';
import bignumber from 'kredits-web/utils/cps/bignumber';
export default EmberObject.extend({
kredits: injectService(),
// Contract
id: bignumber('idRaw', 'toString'),
creatorAddress: null,
recipientId: bignumber('recipientIdRaw', 'toString'),
amount: bignumber('amountRaw', 'toNumber'),
votesCount: bignumber('votesCountRaw', 'toNumber'),
votesNeeded: bignumber('votesNeededRaw', 'toNumber'),
executed: null,
ipfsHash: null,
// Shortcuts
isExecuted: alias('executed'),
// IPFS
kind: null,
description: null,
details: {},
url: null,
ipfsData: '',
// Relationships
// TODO: Optimize it. We don't need to find the contributor every time we add a new one
contributor: computed('recipientId', 'kredits.contributors.[]', function() {
return this.get('kredits.contributors').findBy('id', this.get('recipientId'));
})
});