tags input in editor, #41

This commit is contained in:
Mo Bitar
2017-01-21 18:51:56 -06:00
parent 80f784e47a
commit 8e6a00b8d9
11 changed files with 77 additions and 148 deletions

View File

@@ -17,6 +17,23 @@ angular.module('app.frontend')
$scope.tags = modelManager.tags;
$scope.allTag.notes = modelManager.notes;
/*
Editor Callbacks
*/
$scope.updateTagsForNote = function(note, stringTags) {
note.removeAllRelationships();
var tags = [];
for(var tagString of stringTags) {
tags.push(modelManager.findOrCreateTagByTitle(tagString));
}
for(var tag of tags) {
modelManager.createRelationshipBetweenItems(note, tag);
}
console.log("updating tags for note", note, tags);
apiController.sync();
}
/*
Tags Ctrl Callbacks
*/
@@ -43,20 +60,6 @@ angular.module('app.frontend')
apiController.sync(callback);
}
/*
Called to update the tag of a note after drag and drop change
The note object is a copy of the original
*/
$scope.tagsUpdateNoteTag = function(noteCopy, newTag, oldTag) {
var originalNote = _.find(modelManager.notes, {uuid: noteCopy.uuid});
if(!newTag.all) {
modelManager.createRelationshipBetweenItems(newTag, originalNote);
}
apiController.sync(function(){});
}
/*
Notes Ctrl Callbacks
*/