diff --git a/app/service/TagService.go b/app/service/TagService.go index 4cec1e2..2ca994a 100644 --- a/app/service/TagService.go +++ b/app/service/TagService.go @@ -3,7 +3,7 @@ package service import ( "github.com/leanote/leanote/app/db" "github.com/leanote/leanote/app/info" - // . "github.com/leanote/leanote/app/lea" + . "github.com/leanote/leanote/app/lea" "gopkg.in/mgo.v2/bson" "time" ) @@ -61,6 +61,14 @@ func (this *TagService) AddOrUpdateTag(userId string, tag string) info.NoteTag { noteTag.Count = count noteTag.UpdatedTime = time.Now() // noteTag.Usn = userService.IncrUsn(userId), 更新count而已 + + // 之前删除过的, 现在要添加回来了 + if noteTag.IsDeleted { + Log("之前删除过的, 现在要添加回来了: " + tag) + noteTag.Usn = userService.IncrUsn(userId) + noteTag.IsDeleted = false + } + db.UpdateByIdAndUserId(db.NoteTags, noteTag.TagId.Hex(), userId, noteTag) return noteTag } diff --git a/public/js/app/tag.js b/public/js/app/tag.js index 944a959..28d89c6 100644 --- a/public/js/app/tag.js +++ b/public/js/app/tag.js @@ -210,6 +210,8 @@ Tag.removeTag = function($target) { tag = Tag.mapCn2En[tag] || tag; } Note.curChangedSaveIt(true, function() { + return; + ajaxPost("/tag/updateTag", {tag: tag}, function(ret) { if(reIsOk(ret)) { Tag.addTagNav(ret.Item); @@ -239,6 +241,17 @@ Tag.renderTagNav = function(tags) { } }; +Tag.deleteTag = function(title) { + var me = this; + for(var i = 0; i < this.tags.length; ++i) { + var tag = this.tags[i]; + if (tag.Tag == title) { + this.tags.splice(i, 1); + break; + } + } +}; + // 添加的标签重新render到左边, 放在第一个位置 // 重新render Tag.addTagNav = function(newTag) { @@ -328,6 +341,9 @@ $(function() { var item = re.Item; // 被删除的 Note.deleteNoteTag(item, tag); $li.remove(); + + // 删除tags + Tag.deleteTag(tag); } }); };