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 () { init () {
this._super(...arguments); this._super(...arguments);
this.set('defaultDate', moment().startOf('hour').toDate()); 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 // Default attributes used by reset
if (isEmpty(this.attributes)) { if (isEmpty(this.attributes)) {
this.set('attributes', { this.set('attributes', this.defaultAttr);
contributorId: null, } else {
kind: null, Object.keys(this.defaultAttr).forEach(a => {
date: this.defaultDate, if (typeof this.attributes[a] === 'undefined') {
amount: null, this.attributes[a] = this.defaultAttr[a];
description: null, }
url: null, })
details: null
});
} }
this.reset(); this.reset();