WIP
This commit is contained in:
parent
7f73046773
commit
4875f42152
3 changed files with 30 additions and 18 deletions
|
@ -5,28 +5,32 @@ const { Mixin, run: { once } } = Ember;
|
|||
export default Mixin.create({
|
||||
actions: {
|
||||
willTransition(transition) {
|
||||
if (confirm('Any unsaved changes will be discarded.')) {
|
||||
let model = this.get('controller.model');
|
||||
let hasMany = this.get('controller.hasMany');
|
||||
if (!this.get('controller.safeNavigate')) {
|
||||
if (confirm('Any unsaved changes will be discarded.')) {
|
||||
let model = this.get('controller.model');
|
||||
let hasMany = this.get('controller.hasMany');
|
||||
|
||||
hasMany.forEach((relationship) => {
|
||||
model.get(relationship).forEach((r) => {
|
||||
once(this, () => {
|
||||
if (r.get('isNew')) {
|
||||
r.deleteRecord();
|
||||
} else {
|
||||
r.rollbackAttributes();
|
||||
}
|
||||
}, this);
|
||||
hasMany.forEach((relationship) => {
|
||||
model.get(relationship).forEach((r) => {
|
||||
once(this, () => {
|
||||
if (r.get('isNew')) {
|
||||
r.deleteRecord();
|
||||
} else {
|
||||
r.rollbackAttributes();
|
||||
}
|
||||
}, this);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
if (model.get('isNew')) {
|
||||
model.deleteRecord();
|
||||
if (model.get('isNew')) {
|
||||
model.deleteRecord();
|
||||
}
|
||||
} else {
|
||||
transition.abort();
|
||||
return false
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue