editor note references

This commit is contained in:
Mo Bitar
2017-02-27 13:59:11 -06:00
parent e08c284a30
commit 1f90bf0286
6 changed files with 74 additions and 13 deletions

View File

@@ -2,6 +2,9 @@ class Editor extends Item {
constructor(json_obj) {
super(json_obj);
if(!this.notes) {
this.notes = [];
}
}
mapContentToLocalProperties(contentObject) {
@@ -22,6 +25,44 @@ class Editor extends Item {
return params;
}
referenceParams() {
var references = _.map(this.notes, function(note){
return {uuid: note.uuid, content_type: note.content_type};
})
return references;
}
addItemAsRelationship(item) {
if(item.content_type == "Note") {
if(!_.find(this.notes, item)) {
this.notes.push(item);
}
}
super.addItemAsRelationship(item);
}
removeItemAsRelationship(item) {
if(item.content_type == "Note") {
_.pull(this.notes, item);
}
super.removeItemAsRelationship(item);
}
removeAllRelationships() {
super.removeAllRelationships();
this.notes = [];
}
locallyClearAllReferences() {
super.locallyClearAllReferences();
this.notes = [];
}
allReferencedObjects() {
return this.notes;
}
toJSON() {
return {uuid: this.uuid}
}

View File

@@ -62,7 +62,7 @@ class Note extends Item {
_.pull(tag.notes, this);
}.bind(this))
this.tags = [];
}
}
isBeingRemovedLocally() {
this.tags.forEach(function(tag){

View File

@@ -16,7 +16,7 @@ class ItemParams {
}
paramsForLocalStorage() {
this.additionalFields = ["updated_at", "dirty", "editorUrl"];
this.additionalFields = ["updated_at", "dirty"];
this.forExportFile = true;
return this.__params();
}