Trash bin

This commit is contained in:
Mo Bitar
2019-01-10 17:03:37 -06:00
parent e05580d597
commit 348dd9edb5
6 changed files with 81 additions and 11 deletions

View File

@@ -116,9 +116,29 @@ class ModelManager extends SFModelManager {
}
}
notesMatchingPredicate(predicate) {
notesMatchingSmartTag(tag) {
let contentTypePredicate = new SFPredicate("content_type", "=", "Note");
return this.itemsMatchingPredicates([contentTypePredicate, predicate]);
let predicates = [contentTypePredicate, tag.content.predicate];
if(!tag.content.isTrashTag) {
let notTrashedPredicate = new SFPredicate("content.trashed", "=", false);
predicates.push(notTrashedPredicate);
}
return this.itemsMatchingPredicates(predicates);
}
trashSmartTag() {
return this.systemSmartTags.find((tag) => tag.content.isTrashTag);
}
trashedItems() {
return this.notesMatchingSmartTag(this.trashSmartTag());
}
emptyTrash() {
let notes = this.trashedItems();
for(let note of notes) {
this.setItemToBeDeleted(note);
}
}
buildSystemSmartTags() {