<- sync tag ok

This commit is contained in:
life
2015-02-07 00:32:22 +08:00
parent 19eb994845
commit 68c668514b
7 changed files with 219 additions and 37 deletions

22
node_modules/tag.js generated vendored
View File

@@ -19,7 +19,7 @@ Count 笔记数
var Tag = {
// 添加或更新标签
addOrUpdateTag: function(title, callback) {
addOrUpdateTag: function(title, callback, isForce) {
var userId = User.getCurActiveUserId();
Tags.findOne({UserId: userId, Tag: title}, function(err, tag) {
// 存在, 则更新该tag下的笔记数量
@@ -38,7 +38,7 @@ var Tag = {
TagId: Common.objectId(),
UserId: userId,
Tag: title,
IsDirty: true, // 新添加的
IsDirty: !isForce, // 新添加的
Count: 1,
LocalIsDelete: false,
CreatedTime: date,
@@ -64,24 +64,34 @@ var Tag = {
},
// 删除标签, 更新为LocaleIsDelete = true
deleteTag: function(title, callback) {
deleteTag: function(title, callback, isForce) {
var me = this;
Tags.update({UserId: User.getCurActiveUserId(), Tag: title}, {$set: {LocalIsDelete: true, UpdatedTime: new Date()}}, function() {
Tags.update({UserId: User.getCurActiveUserId(), Tag: title}, {$set: {LocalIsDelete: true, IsDirty: !isForce, UpdatedTime: new Date()}}, function() {
});
// 笔记本
//
Note.updateNoteToDeleteTag(title, function(updates) {
callback(updates);
callback && callback(updates);
});
},
// 更新标签的数量, 在彻底删除笔记时调用
updateTagCount: function(title, count) {
userId = User.getCurActiveUserId();
// 更新Tag's Count
Tags.update({UserId: userId, Tag: title}, {$set: {Count: cnt}});
// 更新web
Web.updateTagCount({Tag: title, Count: cnt});
},
getTag: function(title, callback) {
userId = User.getCurActiveUserId();
Tags.findOne({UserId: userId, Tag: title}, function(err, tag) {
if(err || !tag) {
return callback && callback(false);
}
callback && callback(tag);
});
}
/*
// 添加多个标签
addTags: function(titles) {