Allow partial override of contribution attributes

This commit is contained in:
2019-12-10 13:40:08 +03:00
parent 863b542e3e
commit 04a7f9139d
+11 -4
View File
@@ -24,10 +24,7 @@ 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', {
// Default attributes used by reset
if (isEmpty(this.attributes)) {
this.set('attributes', {
contributorId: null, contributorId: null,
kind: null, kind: null,
date: this.defaultDate, date: this.defaultDate,
@@ -36,6 +33,16 @@ export default Component.extend({
url: null, url: null,
details: null details: null
}); });
// Default attributes used by reset
if (isEmpty(this.attributes)) {
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(); this.reset();