delete undefined tag
This commit is contained in:
@@ -56,6 +56,11 @@ angular.module('app.frontend')
|
|||||||
}
|
}
|
||||||
|
|
||||||
$scope.tagsSave = function(tag, callback) {
|
$scope.tagsSave = function(tag, callback) {
|
||||||
|
console.log("saving tag", tag);
|
||||||
|
if(!tag.title || tag.title.length == 0) {
|
||||||
|
$scope.notesRemoveTag(tag);
|
||||||
|
return;
|
||||||
|
}
|
||||||
tag.setDirty(true);
|
tag.setDirty(true);
|
||||||
syncManager.sync(callback);
|
syncManager.sync(callback);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,19 +79,20 @@ angular.module('app.frontend')
|
|||||||
|
|
||||||
this.saveTag = function($event, tag) {
|
this.saveTag = function($event, tag) {
|
||||||
this.editingTag = null;
|
this.editingTag = null;
|
||||||
if(tag.title.length == 0) {
|
$event.target.blur();
|
||||||
tag.title = originalTagName;
|
|
||||||
originalTagName = "";
|
if(!tag.title || tag.title.length == 0) {
|
||||||
|
if(originalTagName) {
|
||||||
|
tag.title = originalTagName;
|
||||||
|
originalTagName = null;
|
||||||
|
} else {
|
||||||
|
// newly created tag without content
|
||||||
|
modelManager.removeItemLocally(tag);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$event.target.blur();
|
|
||||||
if(!tag.title || tag.title.length == 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.save()(tag, function(savedTag){
|
this.save()(tag, function(savedTag){
|
||||||
// _.merge(tag, savedTag);
|
|
||||||
this.selectTag(tag);
|
this.selectTag(tag);
|
||||||
this.newTag = null;
|
this.newTag = null;
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|||||||
@@ -13,5 +13,5 @@
|
|||||||
|
|
||||||
%input.title{"ng-disabled" => "tag != ctrl.selectedTag", "ng-model" => "tag.title",
|
%input.title{"ng-disabled" => "tag != ctrl.selectedTag", "ng-model" => "tag.title",
|
||||||
"ng-keyup" => "$event.keyCode == 13 && ctrl.saveTag($event, tag)", "mb-autofocus" => "true", "should-focus" => "ctrl.newTag",
|
"ng-keyup" => "$event.keyCode == 13 && ctrl.saveTag($event, tag)", "mb-autofocus" => "true", "should-focus" => "ctrl.newTag",
|
||||||
"ng-change" => "ctrl.tagTitleDidChange(tag)", "ng-focus" => "ctrl.onTagTitleFocus(tag)"}
|
"ng-change" => "ctrl.tagTitleDidChange(tag)", "ng-focus" => "ctrl.onTagTitleFocus(tag)", "ng-blur" => "ctrl.saveTag($event, tag)"}
|
||||||
.count {{ctrl.noteCount(tag)}}
|
.count {{ctrl.noteCount(tag)}}
|
||||||
|
|||||||
Reference in New Issue
Block a user