mirror of
https://github.com/leanote/desktop-app.git
synced 2026-01-14 07:04:21 +08:00
基本功能完成, 移动完成
This commit is contained in:
52
node_modules/note.js
generated
vendored
52
node_modules/note.js
generated
vendored
@@ -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);
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user