基本功能完成, 移动完成

This commit is contained in:
life
2015-10-24 11:03:23 +08:00
parent b49a48b354
commit 72315e35fe
6 changed files with 809 additions and 92 deletions

52
node_modules/note.js generated vendored
View File

@@ -10,6 +10,8 @@ var Notebook = require('notebook');
var Server = require('server');
var Common = require('common');
var Web = require('web');
var async = require('async');
// var Notes = db.notes;
var Api = null; // require('api')
@@ -368,22 +370,44 @@ var Note = {
// 移动note
// 重新统计另一个notebookId的笔记数
moveNote: function(noteId, notebookId, callback) {
moveNote: function(noteIds, notebookId, callback) {
var me = this;
me.getNote(noteId, function(note) {
if(note) {
var to = !note.Star;
var preNotebookId = note.NotebookId;
note.NotebookId = notebookId;
db.notes.update({_id: note._id}, {$set: {IsDirty: true, NotebookId: notebookId, IsTrash: false, LocalIsDelete: false, UpdatedTime: new Date()}}, function(err, n) {
// 重新统计
Notebook.reCountNotebookNumberNotes(preNotebookId);
Notebook.reCountNotebookNumberNotes(notebookId);
callback(note);
});
} else {
callback(false);
if (!noteIds) {
callback(false);
return;
}
var preNotebookIds = {};
async.eachSeries(noteIds, function(noteId, cb) {
me.getNote(noteId, function(note) {
if(note) {
// var to = !note.Star;
// 是原笔记本
var preNotebookId = note.NotebookId;
if (preNotebookId == notebookId && !note.IsTrash) {
cb();
return;
}
preNotebookIds[preNotebookId] = true;
note.NotebookId = notebookId;
db.notes.update({_id: note._id}, {$set: {IsDirty: true, NotebookId: notebookId, IsTrash: false, LocalIsDelete: false, UpdatedTime: new Date()}}, function(err, n) {
cb();
});
} else {
cb();
}
});
}, function () {
// 重新统计
for (var i in preNotebookIds) {
Notebook.reCountNotebookNumberNotes(i);
}
if (!preNotebookIds[notebookId]) {
Notebook.reCountNotebookNumberNotes(notebookId);
}
callback(true);
});
},