handle local deletion relationships

This commit is contained in:
Mo Bitar
2017-01-28 23:16:22 -06:00
parent 46e9e91f46
commit aa6388d8b0
6 changed files with 25 additions and 17 deletions

View File

@@ -107,6 +107,10 @@ class Item {
// must override
}
isBeingRemovedLocally() {
}
removeAllRelationships() {
// must override
this.setDirty(true);

View File

@@ -56,6 +56,13 @@ class Note extends Item {
this.tags = [];
}
isBeingRemovedLocally() {
this.tags.forEach(function(tag){
_.pull(tag.notes, this);
}.bind(this))
super.isBeingRemovedLocally();
}
static filterDummyNotes(notes) {
var filtered = notes.filter(function(note){return note.dummy == false || note.dummy == null});
return filtered;

View File

@@ -55,6 +55,13 @@ class Tag extends Item {
this.notes = [];
}
isBeingRemovedLocally() {
this.notes.forEach(function(note){
_.pull(note.tags, this);
}.bind(this))
super.isBeingRemovedLocally();
}
get content_type() {
return "Tag";
}