WIP Generic data handling and caching

Add basic support for reimbursements via new, generic data handling
functions.
This commit is contained in:
2020-06-27 16:35:04 +02:00
parent 4a9dd5ff09
commit 95743330e4
8 changed files with 1409 additions and 519 deletions
+48
View File
@@ -0,0 +1,48 @@
import EmberObject, { computed } from '@ember/object';
import { isEmpty, isPresent } from '@ember/utils';
import moment from 'moment';
export default EmberObject.extend({
// Contract
id: null,
contributorId: null,
token: null,
amount: null,
confirmedAt: null,
vetoed: null,
ipfsHash: null,
// contributor model instance
contributor: null,
// TODO contributor who submitted the reimbursement
// recordedBy: null,
// IPFS
expenses: null, // Array of expense objects
pendingTx: null,
init () {
this._super(...arguments);
if (isEmpty(this.details)) this.set('details', {});
},
iso8601Date: computed('date', 'time', function() {
return this.time ? `${this.date}T${this.time}` : this.date;
}),
jsDate: computed('iso8601Date', function() {
return moment(this.iso8601Date).toDate();
}),
hasPendingChanges: computed('pendingTx', function() {
return isPresent(this.pendingTx);
}),
serialize () {
return JSON.stringify(this);
}
});