WIP expense items

This commit is contained in:
2020-09-28 11:04:37 +02:00
parent 9f35add07f
commit 4722064337
5 changed files with 152 additions and 46 deletions
+43
View File
@@ -0,0 +1,43 @@
import EmberObject, { computed } from '@ember/object';
import moment from 'moment';
import { A } from '@ember/array';
export default EmberObject.extend({
title: null,
description: null,
currency: null,
amount: null,
date: null,
url: null,
tags: null,
init () {
this._super(...arguments);
this.setDefaultValues();
},
iso8601Date: computed('date', 'time', function() {
return this.time ? `${this.date}T${this.time}` : this.date;
}),
jsDate: computed('iso8601Date', function() {
return moment(this.iso8601Date).toDate();
}),
setDefaultValues () {
this.set('defaultDate', moment().startOf('hour').toDate());
this.setProperties({
title: '',
description: '',
currency: 'EUR',
amount: 0,
date: this.defaultDate,
url: null,
tags: A([])
});
},
serialize () {
return JSON.stringify(this);
}
});