mirror of
https://github.com/leanote/desktop-app.git
synced 2025-10-16 08:01:53 +00:00
conflict fixed
This commit is contained in:
5
node_modules/note.js
generated
vendored
5
node_modules/note.js
generated
vendored
@@ -242,6 +242,11 @@ var Note = {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
conflictIsFixed: function(noteId) {
|
||||||
|
var me = this;
|
||||||
|
Notes.update({NoteId: noteId}, {$set: {ConflictNoteId: ""}});
|
||||||
|
},
|
||||||
|
|
||||||
// 笔记本下是否有笔记
|
// 笔记本下是否有笔记
|
||||||
hasNotes: function(notebookId, callback) {
|
hasNotes: function(notebookId, callback) {
|
||||||
Notes.count({NotebookId: notebookId, IsTrash: false, LocalIsDelete: false}, function(err, n) {
|
Notes.count({NotebookId: notebookId, IsTrash: false, LocalIsDelete: false}, function(err, n) {
|
||||||
|
@@ -753,8 +753,7 @@ function log(o) {
|
|||||||
This note is conflicted with:
|
This note is conflicted with:
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<a class="conflict-note-title">
|
<a class="conflict-title">
|
||||||
这是一个错误
|
|
||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
Maker as resolved: <input type="checkbox" class="conflict-resolved"/>
|
Maker as resolved: <input type="checkbox" class="conflict-resolved"/>
|
||||||
|
@@ -1507,3 +1507,8 @@ top: 4px;
|
|||||||
width: 230px;
|
width: 230px;
|
||||||
height: 80px;
|
height: 80px;
|
||||||
}
|
}
|
||||||
|
.conflict-title {
|
||||||
|
display: block;
|
||||||
|
text-decoration: underline;
|
||||||
|
white-space: nowrap;text-overflow:ellipsis; overflow:hidden;
|
||||||
|
}
|
||||||
|
@@ -1647,8 +1647,85 @@ Note.star = function(noteId) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 显示
|
// 显示
|
||||||
Note.showConflictInfo = function(noteId, e) {
|
Note._curFixNoteId = ''; // 当前要处理的
|
||||||
ContextTips.show('#conflictTips', e);
|
Note._curFixNoteTarget = '';
|
||||||
|
Note._conflictTipsElem = $('#conflictTips');
|
||||||
|
Note._showConflictInfoInited = false;
|
||||||
|
// 初始化事件
|
||||||
|
Note._initshowConflictInfo = function() {
|
||||||
|
var me = this;
|
||||||
|
|
||||||
|
// 点击与之冲突的笔记, 则将该笔记显示到它前面, 并选中
|
||||||
|
Note._conflictTipsElem.find('.conflict-title').click(function() {
|
||||||
|
var conflictNoteId = $(this).data('id');
|
||||||
|
var conflictNote = me.getNote(conflictNoteId);
|
||||||
|
if(!conflictNote) {
|
||||||
|
alert('The note is not exists');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 是否在该列表中?
|
||||||
|
var target = $(tt('[noteId="?"]', conflictNoteId)); //
|
||||||
|
// 如果当前笔记在笔记列表中, 那么生成一个新笔记放在这个笔记上面
|
||||||
|
if(target.length > 0) {
|
||||||
|
} else {
|
||||||
|
target = me._getNoteHtmlObjct(conflictNote);
|
||||||
|
}
|
||||||
|
// console.log(">....>");
|
||||||
|
// console.log(me._curFixNoteTarget);
|
||||||
|
// console.log(target);
|
||||||
|
|
||||||
|
// target.insertBefore(me._curFixNoteTarget);
|
||||||
|
me._curFixNoteTarget.insertBefore(target);
|
||||||
|
// 选中与之冲突的笔记
|
||||||
|
me.changeNote(conflictNoteId);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
Note.showConflictInfo = function(target, e) {
|
||||||
|
var me = this;
|
||||||
|
|
||||||
|
var $li = $(target).closest('li');
|
||||||
|
var noteId = $li.attr('noteId');
|
||||||
|
|
||||||
|
var note = me.getNote(noteId);
|
||||||
|
if(!note) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var conflictNoteId = note.ConflictNoteId;
|
||||||
|
function conflictIsFixed() {
|
||||||
|
// 去掉item-confict class
|
||||||
|
// 并且改变
|
||||||
|
$li.removeClass('item-conflict');
|
||||||
|
note.ConflictNoteId = "";
|
||||||
|
NoteService.conflictIsFixed(noteId);
|
||||||
|
}
|
||||||
|
if(!conflictNoteId) {
|
||||||
|
return conflictIsFixed();
|
||||||
|
}
|
||||||
|
|
||||||
|
var conflictNote = me.getNote(conflictNoteId);
|
||||||
|
if(!conflictNote) {
|
||||||
|
return conflictIsFixed();
|
||||||
|
}
|
||||||
|
|
||||||
|
me._curFixNoteId = noteId;
|
||||||
|
me._curFixNoteTarget = $li;
|
||||||
|
|
||||||
|
if(!me._showConflictInfoInited) {
|
||||||
|
me._showConflictInfoInited = true;
|
||||||
|
me._initshowConflictInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 初始化数据
|
||||||
|
var titleElem = Note._conflictTipsElem.find('.conflict-title');
|
||||||
|
titleElem.text(conflictNote.Title);
|
||||||
|
titleElem.data('id', conflictNoteId);
|
||||||
|
Note._conflictTipsElem.find('.conflict-resolved').prop('checked', false);
|
||||||
|
|
||||||
|
ContextTips.show('#conflictTips', e, function() {
|
||||||
|
if(Note._conflictTipsElem.find('.conflict-resolved').prop('checked')) {
|
||||||
|
conflictIsFixed();
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// 内容已同步成功
|
// 内容已同步成功
|
||||||
@@ -2238,9 +2315,7 @@ $(function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$("#noteItemList").on("click", ".item-my .item-conflict-info", function(e) {
|
$("#noteItemList").on("click", ".item-my .item-conflict-info", function(e) {
|
||||||
var $li = $(this).closest('li');
|
Note.showConflictInfo(this, e);
|
||||||
var noteId = $li.attr('noteId');
|
|
||||||
Note.showConflictInfo(noteId, e);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// sync
|
// sync
|
||||||
|
@@ -15,7 +15,7 @@ Notebook.setCache = function(notebook) {
|
|||||||
Notebook.cache[notebookId] = {};
|
Notebook.cache[notebookId] = {};
|
||||||
}
|
}
|
||||||
$.extend(Notebook.cache[notebookId], notebook);
|
$.extend(Notebook.cache[notebookId], notebook);
|
||||||
}
|
};
|
||||||
|
|
||||||
Notebook.getCurNotebookId = function() {
|
Notebook.getCurNotebookId = function() {
|
||||||
return Notebook.curNotebookId;
|
return Notebook.curNotebookId;
|
||||||
|
@@ -1304,6 +1304,7 @@ function setHash(key, value) {
|
|||||||
var ContextTips = {
|
var ContextTips = {
|
||||||
curShowId: '', // 当前显示的id
|
curShowId: '', // 当前显示的id
|
||||||
curShowIdObj: '',
|
curShowIdObj: '',
|
||||||
|
hideCallback: null,
|
||||||
init: function() {
|
init: function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
$(function() {
|
$(function() {
|
||||||
@@ -1314,6 +1315,9 @@ var ContextTips = {
|
|||||||
if($(e.target).closest(me.curShowId).length == 0) {
|
if($(e.target).closest(me.curShowId).length == 0) {
|
||||||
me.curShowIdObj.hide();
|
me.curShowIdObj.hide();
|
||||||
me.curShowId = '';
|
me.curShowId = '';
|
||||||
|
if(me.hideCallback) {
|
||||||
|
me.hideCallback();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1324,10 +1328,11 @@ var ContextTips = {
|
|||||||
var me = this;
|
var me = this;
|
||||||
$(id).hide();
|
$(id).hide();
|
||||||
},
|
},
|
||||||
show: function(id, e) {
|
show: function(id, e, hideCallback) {
|
||||||
var me = this;
|
var me = this;
|
||||||
me.curShowId = id;
|
me.curShowId = id;
|
||||||
me.curShowIdObj = $(id);
|
me.curShowIdObj = $(id);
|
||||||
|
me.hideCallback = hideCallback;
|
||||||
// 位置
|
// 位置
|
||||||
me.curShowIdObj.show();
|
me.curShowIdObj.show();
|
||||||
var mwidth = me.curShowIdObj.width();
|
var mwidth = me.curShowIdObj.width();
|
||||||
|
Reference in New Issue
Block a user