item deletion

This commit is contained in:
Mo Bitar
2016-12-15 20:50:16 -06:00
parent 1722eb299c
commit 36c74ed14d
17 changed files with 148 additions and 121 deletions

View File

@@ -46,10 +46,12 @@ class Item {
addReference(reference) {
this.content.references.push(reference);
this.content.references = _.uniq(this.content.references);
this.updateReferencesLocalMapping();
}
removeReference(reference) {
_.remove(this.content.references, _.find(this.content.references, {uuid: reference.uuid}));
this.updateReferencesLocalMapping();
}
referencesMatchingContentType(contentType) {
@@ -62,7 +64,6 @@ class Item {
// should be overriden to manage local properties
}
/* Returns true if note is shared individually or via tag */
isPublic() {
return this.presentation;
}

View File

@@ -18,6 +18,11 @@ class Note extends Item {
return filtered;
}
updateReferencesLocalMapping() {
super.updateReferencesLocalMapping();
this.tags = this.referencesMatchingContentType("Tag");
}
get hasOnePublicTag() {
var hasPublicTag = false;
this.tags.forEach(function(tag){
@@ -30,6 +35,10 @@ class Note extends Item {
return hasPublicTag;
}
toJSON() {
return {uuid: this.uuid}
}
isPublic() {
return super.isPublic() || this.hasOnePublicTag;
}

View File

@@ -19,6 +19,5 @@ class Tag extends Item {
updateReferencesLocalMapping() {
super.updateReferencesLocalMapping();
this.notes = this.referencesMatchingContentType("Note");
console.log("notes after maping", this.notes);
}
}