Allow partial override of contribution attributes

This commit is contained in:
2019-12-10 13:40:08 +03:00
parent 863b542e3e
commit 04a7f9139d
+16 -9
View File
@@ -24,18 +24,25 @@ export default Component.extend({
init () {
this._super(...arguments);
this.set('defaultDate', moment().startOf('hour').toDate());
this.set('defaultAttr', {
contributorId: null,
kind: null,
date: this.defaultDate,
amount: null,
description: null,
url: null,
details: null
});
// Default attributes used by reset
if (isEmpty(this.attributes)) {
this.set('attributes', {
contributorId: null,
kind: null,
date: this.defaultDate,
amount: null,
description: null,
url: null,
details: null
});
this.set('attributes', this.defaultAttr);
} else {
Object.keys(this.defaultAttr).forEach(a => {
if (typeof this.attributes[a] === 'undefined') {
this.attributes[a] = this.defaultAttr[a];
}
})
}
this.reset();