cloning in context menu (copy & paste) and a lot of related refactoring and fixes

This commit is contained in:
azivner
2017-11-22 23:16:54 -05:00
parent c1fca4764b
commit acba72ec4c
12 changed files with 260 additions and 188 deletions

View File

@@ -25,6 +25,17 @@ const treeChanges = (function() {
noteTree.setCurrentNotePathToHash(node);
}
// beware that first arg is noteId and second is noteTreeId!
async function cloneNoteAfter(noteId, afterNoteTreeId) {
await $.ajax({
url: baseApiUrl + 'notes/' + noteId + '/cloneAfter/' + afterNoteTreeId,
type: 'PUT',
error: () => showError("Error cloning note.")
});
await noteTree.reload();
}
async function moveToNode(node, toNode) {
await $.ajax({
url: baseApiUrl + 'notes/' + node.data.note_tree_id + '/moveTo/' + toNode.data.note_id,
@@ -42,6 +53,16 @@ const treeChanges = (function() {
noteTree.setCurrentNotePathToHash(node);
}
async function cloneNoteTo(childNoteId, parentNoteId) {
await $.ajax({
url: baseApiUrl + 'notes/' + childNoteId + '/cloneTo/' + parentNoteId,
type: 'PUT',
error: () => showError("Error cloning note.")
});
await noteTree.reload();
}
async function deleteNode(node) {
if (!confirm('Are you sure you want to delete note "' + node.title + '"?')) {
return;
@@ -97,6 +118,8 @@ const treeChanges = (function() {
moveAfterNode,
moveToNode,
deleteNode,
moveNodeUp
moveNodeUp,
cloneNoteAfter,
cloneNoteTo
};
})();