mirror of
https://github.com/leanote/desktop-app.git
synced 2025-10-15 07:31:33 +00:00
批量公开, 取消公开为博客完成
This commit is contained in:
19
node_modules/note.js
generated
vendored
19
node_modules/note.js
generated
vendored
@@ -161,7 +161,22 @@ var Note = {
|
||||
},
|
||||
|
||||
// 公开/取消为博客
|
||||
setNote2Blog: function(noteId, isBlog, callback) {
|
||||
setNote2Blog: function(noteIds, isBlog, callback) {
|
||||
var me = this;
|
||||
var ok = false;
|
||||
async.eachSeries(noteIds, function(noteId, cb) {
|
||||
me._setNote2Blog(noteId, isBlog, function (ret) {
|
||||
if (ret) {
|
||||
ok = true;
|
||||
}
|
||||
cb();
|
||||
});
|
||||
}, function () {
|
||||
callback(ok);
|
||||
});
|
||||
},
|
||||
|
||||
_setNote2Blog: function(noteId, isBlog, callback) {
|
||||
var me = this;
|
||||
me.getNote(noteId, function(note) {
|
||||
if(note) {
|
||||
@@ -169,7 +184,7 @@ var Note = {
|
||||
return callback && callback(true);
|
||||
}
|
||||
// 更新, 设置isDirty
|
||||
db.notes.update({NoteId: noteId}, { $set: {IsBlog: isBlog, IsDirty: true} }, {}, function (err, numReplaced) {
|
||||
db.notes.update({_id: note._id}, { $set: {IsBlog: isBlog, IsDirty: true} }, {}, function (err, numReplaced) {
|
||||
return callback && callback(true);
|
||||
});
|
||||
} else {
|
||||
|
@@ -1619,45 +1619,33 @@ Note.searchNote = function() {
|
||||
// Note.lastSearch.abort();
|
||||
}
|
||||
|
||||
//----------
|
||||
//---------------
|
||||
//设为blog/unset
|
||||
Note.setNote2Blog = function(target) {
|
||||
var noteId = $(target).attr("noteId");
|
||||
var note = Note.cache[noteId];
|
||||
var isBlog = true;
|
||||
if(note.IsBlog != undefined) {
|
||||
isBlog = !note.IsBlog;
|
||||
|
||||
|
||||
Note.setNote2Blog = function(target, isBlog) {
|
||||
var me = Note;
|
||||
|
||||
var noteIds;
|
||||
if (me.inBatch) {
|
||||
noteIds = me.getBatchNoteIds();
|
||||
}
|
||||
else {
|
||||
noteIds = [$(target).attr('noteId')];
|
||||
}
|
||||
if (isEmpty(noteIds)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 标志添加/去掉
|
||||
function setBlog() {
|
||||
// alert(noteId + " => " + isBlog);
|
||||
NoteService.setNote2Blog(noteId, isBlog, function(ret) {
|
||||
// 是新笔记 或 当前笔记就是它的, 则先保存之
|
||||
Note.curChangedSaveIt(true, function() {
|
||||
NoteService.setNote2Blog(noteIds, isBlog, function(ret) {
|
||||
if(ret) {
|
||||
// 触发同步
|
||||
incrSync();
|
||||
|
||||
// Note.setNoteCache({NoteId: noteId, IsBlog: isBlog}, false); // 不清空NotesByNotebookId缓存
|
||||
|
||||
// 同步后会设置
|
||||
/*
|
||||
if(isBlog) {
|
||||
$(target).find(".item-blog").removeAttr('style');
|
||||
} else {
|
||||
$(target).find(".item-blog").hide();
|
||||
}
|
||||
*/
|
||||
}
|
||||
});
|
||||
}
|
||||
// 是新笔记 或 当前笔记就是它的, 则先保存之
|
||||
if(note.IsNew || note.curNoteId == noteId) {
|
||||
Note.curChangedSaveIt(true, function(note) {
|
||||
setBlog();
|
||||
});
|
||||
} else {
|
||||
setBlog();
|
||||
}
|
||||
};
|
||||
|
||||
// 设置notebook的blog状态
|
||||
@@ -1785,7 +1773,8 @@ Note.copyNote = function(target, data, isShared) {
|
||||
var note = me.getNote(noteId);
|
||||
if (note) {
|
||||
// trash不能复制, 不能复制给自己
|
||||
if (note.IsTrash || note.NotebookId == toNotebookId) {
|
||||
// 因为contexmenu不能disable有子menu的项, 所以允许复制trash
|
||||
if (/*note.IsTrash || */note.NotebookId == toNotebookId) {
|
||||
continue;
|
||||
}
|
||||
needNoteIds.push(noteId);
|
||||
@@ -2278,13 +2267,13 @@ Note.initContextmenu = function() {
|
||||
this.publicBlog = new gui.MenuItem({
|
||||
label: getMsg("Public as blog"),
|
||||
click: function(e) {
|
||||
Note.setNote2Blog(self.target);
|
||||
Note.setNote2Blog(self.target, true);
|
||||
}
|
||||
});
|
||||
this.unPublicBlog = new gui.MenuItem({
|
||||
label: getMsg("Cancel public"),
|
||||
click: function(e) {
|
||||
Note.setNote2Blog(self.target);
|
||||
Note.setNote2Blog(self.target, false);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -2305,6 +2294,7 @@ Note.initContextmenu = function() {
|
||||
}
|
||||
});
|
||||
|
||||
// 本地笔记不能公开为博客
|
||||
if (!UserInfo.IsLocal) {
|
||||
this.menu.append(this.publicBlog);
|
||||
this.menu.append(this.unPublicBlog);
|
||||
@@ -2322,8 +2312,10 @@ Note.initContextmenu = function() {
|
||||
var exportMenus = Api.getExportMenus() || [];
|
||||
for(var i = 0; i < exportMenus.length; ++i) {
|
||||
(function(j) {
|
||||
|
||||
var menu = exportMenus[j];
|
||||
var clickBac = menu.click;
|
||||
|
||||
var menuItem = new gui.MenuItem({
|
||||
label: menu.label,
|
||||
click: function(e) {
|
||||
@@ -2331,9 +2323,13 @@ Note.initContextmenu = function() {
|
||||
clickBac && clickBac(note);
|
||||
}
|
||||
});
|
||||
|
||||
exportMenus[i].menu = menuItem;
|
||||
|
||||
exportsSubMenus.append(menuItem);
|
||||
})(i);
|
||||
}
|
||||
|
||||
if(exportMenus.length > 0) {
|
||||
this.exports = new gui.MenuItem({
|
||||
label: getMsg('Export'),
|
||||
@@ -2346,24 +2342,45 @@ Note.initContextmenu = function() {
|
||||
this.menu.append(this.exports);
|
||||
}
|
||||
|
||||
T = this;
|
||||
|
||||
this.enable = function(name, ok) {
|
||||
this[name].enabled = ok;
|
||||
}
|
||||
// 控制disable
|
||||
this.popup = function(e, target) {
|
||||
self.target = target;
|
||||
var noteId = $(target).attr('noteId');
|
||||
var noteIds;
|
||||
if (Note.inBatch) {
|
||||
noteIds = Note.getBatchNoteIds();
|
||||
}
|
||||
else {
|
||||
noteIds = [$(target).attr("noteId")];
|
||||
}
|
||||
|
||||
var note = Note.getNote(noteId);
|
||||
// 导出的enabled
|
||||
for(var i = 0; i < exportMenus.length; ++i) {
|
||||
exportMenus[i].menu.enabled = exportMenus[i].enabled(noteIds);
|
||||
}
|
||||
|
||||
// 批量, 除了导出pdf都可以操作
|
||||
if (Note.inBatch) {
|
||||
this.copy.enabled = true;
|
||||
this.move.enabled = true;
|
||||
this.publicBlog.enabled = true;
|
||||
this.unPublicBlog.enabled = true;
|
||||
} else {
|
||||
var note = Note.getNote(noteIds[0]);
|
||||
if (!note) {
|
||||
return;
|
||||
}
|
||||
var notebookId = note.NotebookId;
|
||||
|
||||
if(note.IsTrash) {
|
||||
this.copy.enabled = false;
|
||||
if(note.IsTrash || Notebook.curNotebookIsTrash()) {
|
||||
this.copy.enabled = false; // 没用
|
||||
this.publicBlog.enabled = false;
|
||||
this.unPublicBlog.enabled = false;
|
||||
} else {
|
||||
this.copy.enabled = true;
|
||||
}
|
||||
|
||||
if(note.IsBlog) {
|
||||
this.publicBlog.enabled = false;
|
||||
@@ -2372,6 +2389,8 @@ Note.initContextmenu = function() {
|
||||
this.publicBlog.enabled = true;
|
||||
this.unPublicBlog.enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.menu.popup(gui.getCurrentWindow(), e.originalEvent.x, e.originalEvent.y);
|
||||
}
|
||||
|
@@ -203,6 +203,9 @@ define(function() {
|
||||
|
||||
var menu = {
|
||||
label: Api.getMsg('plugin.export_html.export'),
|
||||
enabled: function(noteIds) {
|
||||
return true;
|
||||
},
|
||||
click: (function() {
|
||||
return function(note) {
|
||||
me.exportHTML(note);
|
||||
|
@@ -116,6 +116,12 @@ define(function() {
|
||||
|
||||
var menu = {
|
||||
label: Api.getMsg('plugin.export_pdf.export'),
|
||||
enabled: function(noteIds) {
|
||||
if (noteIds && noteIds.length == 1) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
click: (function() {
|
||||
return function(note) {
|
||||
if (UserInfo.IsLocal) {
|
||||
|
Reference in New Issue
Block a user