mirror of
https://github.com/leanote/desktop-app.git
synced 2025-10-14 23:22:40 +00:00
批量复制完成
This commit is contained in:
22
node_modules/common.js
generated
vendored
22
node_modules/common.js
generated
vendored
@@ -26,6 +26,28 @@ var Common = {
|
||||
objectId: function() {
|
||||
return ObjectId()
|
||||
},
|
||||
|
||||
// 是否是数组
|
||||
isArray: function(obj) {
|
||||
return Object.prototype.toString.call(obj) === '[object Array]';
|
||||
},
|
||||
/**
|
||||
* 是否为空
|
||||
* 可判断任意类型,string array
|
||||
*/
|
||||
isEmpty: function(obj) {
|
||||
if(!obj) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(isArray(obj)) {
|
||||
if(obj.length == 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
_uuid: 1,
|
||||
uuid: function() {
|
||||
this._uuid++;
|
||||
|
30
node_modules/note.js
generated
vendored
30
node_modules/note.js
generated
vendored
@@ -10,7 +10,6 @@ var Notebook = require('notebook');
|
||||
var Server = require('server');
|
||||
var Common = require('common');
|
||||
var Web = require('web');
|
||||
var async = require('async');
|
||||
|
||||
// var Notes = db.notes;
|
||||
|
||||
@@ -372,7 +371,7 @@ var Note = {
|
||||
// 重新统计另一个notebookId的笔记数
|
||||
moveNote: function(noteIds, notebookId, callback) {
|
||||
var me = this;
|
||||
if (!noteIds) {
|
||||
if (Common.isEmpty(noteIds)) {
|
||||
callback(false);
|
||||
return;
|
||||
}
|
||||
@@ -1025,7 +1024,27 @@ var Note = {
|
||||
},
|
||||
|
||||
// 复制笔记到某笔记本下, 本地使用
|
||||
copyNote: function(noteId, notebookId, callback) {
|
||||
copyNote: function(noteIds, notebookId, callback) {
|
||||
var me = this;
|
||||
var newNotes = [];
|
||||
if (Common.isEmpty(noteIds)) {
|
||||
callback(false);
|
||||
return;
|
||||
}
|
||||
async.eachSeries(noteIds, function(noteId, cbTop) {
|
||||
me._copyNote(noteId, notebookId, function (newNote) {
|
||||
newNotes.push(newNote);
|
||||
cbTop();
|
||||
});
|
||||
}, function () {
|
||||
// 重新统计下
|
||||
Notebook.reCountNotebookNumberNotes(notebookId);
|
||||
callback(newNotes);
|
||||
});
|
||||
},
|
||||
|
||||
// 复制单个笔记
|
||||
_copyNote: function (noteId, notebookId, callback) {
|
||||
var me = this;
|
||||
me.getNote(noteId, function(note) {
|
||||
if(!note) {
|
||||
@@ -1073,15 +1092,14 @@ var Note = {
|
||||
*/
|
||||
}, function() {
|
||||
note.Attachs = newAttachs;
|
||||
console.log('conflict 复制后的');
|
||||
console.log(note.Attachs);
|
||||
// console.log('conflict 复制后的');
|
||||
// console.log(note.Attachs);
|
||||
db.notes.insert(note, function(err, newNote) {
|
||||
if(err) {
|
||||
callback(false);
|
||||
} else {
|
||||
callback(newNote);
|
||||
// 重新统计下
|
||||
Notebook.reCountNotebookNumberNotes(newNote.NotebookId);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user