Files
kredits-web/app/controllers/proposals/new.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

25 lines
887 B
JavaScript

import Controller from 'ember-controller';
import { alias, filterBy } from 'ember-computed';
import injectService from 'ember-service/inject';
export default Controller.extend({
kredits: injectService(),
contributors: alias('kredits.contributors'),
minedContributors: filterBy('contributors', 'id'),
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);
proposal.contributorIpfsHash = contributor.get('ipfsHash');
return this.get('kredits').addProposal(proposal)
.then((proposal) => {
this.transitionToRoute('index');
return proposal;
});
}
}
});