refactoring and check for existing clone in a parent

This commit is contained in:
azivner
2017-11-23 20:49:24 -05:00
parent 45a293e25a
commit 5b2c18dab7
2 changed files with 76 additions and 47 deletions

View File

@@ -27,12 +27,17 @@ const treeChanges = (function() {
// beware that first arg is noteId and second is noteTreeId!
async function cloneNoteAfter(noteId, afterNoteTreeId) {
await $.ajax({
const resp = await $.ajax({
url: baseApiUrl + 'notes/' + noteId + '/cloneAfter/' + afterNoteTreeId,
type: 'PUT',
error: () => showError("Error cloning note.")
});
if (!resp.success) {
alert(resp.message);
return;
}
await noteTree.reload();
}
@@ -54,12 +59,17 @@ const treeChanges = (function() {
}
async function cloneNoteTo(childNoteId, parentNoteId) {
await $.ajax({
const resp = await $.ajax({
url: baseApiUrl + 'notes/' + childNoteId + '/cloneTo/' + parentNoteId,
type: 'PUT',
error: () => showError("Error cloning note.")
});
if (!resp.success) {
alert(resp.message);
return;
}
await noteTree.reload();
}