Allow partial override of contribution attributes
This commit is contained in:
@@ -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();
|
||||||
|
|||||||
Reference in New Issue
Block a user