BUG: Rollback hasMany changesets sanely (#90)
This commit is contained in:
parent
6f6148df9d
commit
bf6023a7b4
1 changed files with 7 additions and 4 deletions
|
@ -2,7 +2,6 @@ import Mixin from '@ember/object/mixin';
|
||||||
import { get } from '@ember/object';
|
import { get } from '@ember/object';
|
||||||
import RSVP from 'rsvp';
|
import RSVP from 'rsvp';
|
||||||
const { keys } = Object;
|
const { keys } = Object;
|
||||||
const { isArray } = Array;
|
|
||||||
|
|
||||||
export default Mixin.create({
|
export default Mixin.create({
|
||||||
validationSave(changesets, postSave) {
|
validationSave(changesets, postSave) {
|
||||||
|
@ -55,9 +54,13 @@ export default Mixin.create({
|
||||||
for (const model of changesets[key]) {
|
for (const model of changesets[key]) {
|
||||||
model.destroyRecord();
|
model.destroyRecord();
|
||||||
}
|
}
|
||||||
} else if (isArray(changesets[key])) { // hasMany
|
} else if (key === 'hasMany') {
|
||||||
for (const { changeset } of changesets[key]) {
|
const hasMany = changesets[key];
|
||||||
changeset.rollback();
|
for (const hasManyKey of keys(changesets[key])) {
|
||||||
|
const hasManyChangesets = hasMany[hasManyKey];
|
||||||
|
for (const changeset of hasManyChangesets) {
|
||||||
|
changeset.rollback();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else { // single
|
} else { // single
|
||||||
const changeset = changesets[key];
|
const changeset = changesets[key];
|
||||||
|
|
Loading…
Add table
Reference in a new issue