Tag predicate matching

This commit is contained in:
Mo Bitar
2018-07-04 09:46:21 -05:00
parent 428458e821
commit b33cdea814
5 changed files with 26 additions and 18 deletions

View File

@@ -156,11 +156,6 @@ angular.module('app')
Tags Ctrl Callbacks
*/
$scope.tagsWillMakeSelection = function(tag) {
}
$scope.tagsSelectionMade = function(tag) {
if($scope.selectedNote && $scope.selectedNote.dummy) {
modelManager.removeItemLocally($scope.selectedNote);
@@ -205,7 +200,7 @@ angular.module('app')
$scope.notesAddNew = function(note) {
modelManager.addItem(note);
if(!$scope.selectedTag.all && !$scope.selectedTag.archiveTag) {
if(!$scope.selectedTag.all && !$scope.selectedTag.archiveTag && !$scope.selectedTag.isSmartTag()) {
$scope.selectedTag.addItemAsRelationship(note);
$scope.selectedTag.setDirty(true);
}

View File

@@ -5,7 +5,6 @@ angular.module('app')
scope: {
addNew: "&",
selectionMade: "&",
willSelect: "&",
save: "&",
tags: "=",
allTag: "=",
@@ -66,13 +65,23 @@ angular.module('app')
return null;
}.bind(this), actionHandler: function(component, action, data){
if(action === "select-item") {
var tag = modelManager.findItem(data.item.uuid);
if(tag) {
if(data.item.content_type == "Tag") {
var tag = modelManager.findItem(data.item.uuid);
if(tag) {
this.selectTag(tag);
}
} else if(data.item.content_type == "SN|SmartTag") {
var params = data.item.content.predicate;
var predicate = new SFPredicate(params.keypath, params.operator, params.value);
var tag = new Tag(data.item);
Object.defineProperty(tag, "notes", {
get: () => {
return modelManager.notesMatchingPredicate(predicate);
}
});
this.selectTag(tag);
}
}
else if(action === "clear-selection") {
} else if(action === "clear-selection") {
this.selectTag(this.allTag);
}
}.bind(this)});
@@ -93,7 +102,6 @@ angular.module('app')
}
this.selectTag = function(tag) {
this.willSelect()(tag);
this.selectedTag = tag;
tag.conflict_of = null; // clear conflict
this.selectionMade()(tag);

View File

@@ -757,7 +757,7 @@ class ComponentManager {
component.active = true;
for(var handler of this.handlers) {
if(handler.areas.includes(component.area) || handler.areas.includes("*")) {
handler.activationHandler(component);
handler.activationHandler && handler.activationHandler(component);
}
}
@@ -782,7 +782,7 @@ class ComponentManager {
for(var handler of this.handlers) {
if(handler.areas.includes(component.area) || handler.areas.includes("*")) {
handler.activationHandler(component);
handler.activationHandler && handler.activationHandler(component);
}
}
@@ -814,7 +814,7 @@ class ComponentManager {
for(var handler of this.handlers) {
if(handler.areas.includes(component.area) || handler.areas.includes("*")) {
handler.activationHandler(component);
handler.activationHandler && handler.activationHandler(component);
}
}
@@ -838,7 +838,7 @@ class ComponentManager {
component.active = true;
for(var handler of this.handlers) {
if(handler.areas.includes(component.area) || handler.areas.includes("*")) {
handler.activationHandler(component);
handler.activationHandler && handler.activationHandler(component);
}
}

View File

@@ -104,6 +104,11 @@ class ModelManager extends SFModelManager {
}
}
notesMatchingPredicate(predicate) {
let contentTypePredicate = new SFPredicate("content_type", "=", "Note");
return this.itemsMatchingPredicates([contentTypePredicate, predicate]);
}
/*
Misc
*/

View File

@@ -1,7 +1,7 @@
.main-ui-view{"ng-class" => "platform"}
%lock-screen{"ng-if" => "needsUnlock", "on-success" => "onSuccessfulUnlock"}
.app#app{"ng-if" => "!needsUnlock"}
%tags-section{"save" => "tagsSave", "add-new" => "tagsAddNew", "will-select" => "tagsWillMakeSelection", "selection-made" => "tagsSelectionMade",
%tags-section{"save" => "tagsSave", "add-new" => "tagsAddNew", "selection-made" => "tagsSelectionMade",
"all-tag" => "allTag", "archive-tag" => "archiveTag", "tags" => "tags", "remove-tag" => "removeTag"}
%notes-section{"add-new" => "notesAddNew", "selection-made" => "notesSelectionMade", "tag" => "selectedTag"}