Skip to content

Commit 629fe26

Browse files
author
leon dmello
committed
CP to allow access to many to many deleted models
1 parent a9f2af9 commit 629fe26

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

addon/mixins/model.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import Ember from 'ember';
22

3+
const {
4+
defineProperty,
5+
computed
6+
} = Ember;
7+
38
const resetRelations = function(record) {
49
Object.keys(record.get('__recordsJustSaved')).forEach((relationName) => {
510
let relationRecords = record.get('__recordsJustSaved')[relationName];
@@ -62,19 +67,14 @@ export default Ember.Mixin.create({
6267

6368
if(!deletedRelations.get(relation)) {
6469
deletedRelations.set(relation, Ember.A());
70+
defineProperty(this, `manyToManyDeleted${relation}`, computed.readOnly(`_manyToManyDeleted.${relation}`));
6571
}
6672

6773
if(!deletedRelations.get(relation).includes(model)) {
6874
deletedRelations.get(relation).pushObject(model);
6975
}
7076
},
7177

72-
manyToManyMarkedForDeletion(relation, model) {
73-
return this.get('_manyToManyDeleted') &&
74-
this.get(`_manyToManyDeleted.${relation}`) &&
75-
this.get(`_manyToManyDeleted.${relation}`).includes(model);
76-
},
77-
7878
manyToManyMarkedForDeletionModels(relation) {
7979
const relationModels = this.get('_manyToManyDeleted') &&
8080
this.get(`_manyToManyDeleted.${relation}`);

0 commit comments

Comments
 (0)