fix import uuid change, export all items

This commit is contained in:
Mo Bitar
2017-04-29 12:24:44 -05:00
parent 0070c9e460
commit 80c723b400
6 changed files with 42 additions and 1 deletions

View File

@@ -121,6 +121,14 @@ class Item {
_.merge(this, _.omit(item, ["content"]));
}
informReferencesOfUUIDChange(oldUUID, newUUID) {
// optional override
}
potentialItemOfInterestHasChangedItsUUID(newItem, oldUUID, newUUID) {
// optional override
}
allReferencedObjects() {
// must override
return [];

View File

@@ -66,6 +66,13 @@ class Editor extends Item {
this.notes = [];
}
potentialItemOfInterestHasChangedItsUUID(newItem, oldUUID, newUUID) {
if(newItem.content_type === "Note" && _.find(this.notes, {uuid: oldUUID})) {
_.pull(this.notes, {uuid: oldUUID});
this.notes.push(newItem);
}
}
allReferencedObjects() {
return this.notes;
}

View File

@@ -76,6 +76,13 @@ class Note extends Item {
return filtered;
}
informReferencesOfUUIDChange(oldUUID, newUUID) {
for(var tag of this.tags) {
_.pull(tag.notes, {uuid: oldUUID});
tag.notes.push(this);
}
}
allReferencedObjects() {
return this.tags;
}

View File

@@ -71,6 +71,13 @@ class Tag extends Item {
super.isBeingRemovedLocally();
}
informReferencesOfUUIDChange(oldUUID, newUUID) {
for(var note of this.notes) {
_.pull(note.tags, {uuid: oldUUID});
note.tags.push(this);
}
}
get content_type() {
return "Tag";
}