2018-03-26 01:41:29 +08:00
|
|
|
import treeService from './tree.js';
|
2018-03-31 01:20:36 +08:00
|
|
|
import server from './server.js';
|
2018-03-25 23:09:17 +08:00
|
|
|
|
|
|
|
async function cloneNoteTo(childNoteId, parentNoteId, prefix) {
|
|
|
|
const resp = await server.put('notes/' + childNoteId + '/clone-to/' + parentNoteId, {
|
|
|
|
prefix: prefix
|
|
|
|
});
|
|
|
|
|
|
|
|
if (!resp.success) {
|
|
|
|
alert(resp.message);
|
|
|
|
return;
|
2018-01-14 07:02:41 +08:00
|
|
|
}
|
|
|
|
|
2018-03-25 23:09:17 +08:00
|
|
|
await treeService.reload();
|
|
|
|
}
|
2018-01-14 07:02:41 +08:00
|
|
|
|
2018-03-25 23:09:17 +08:00
|
|
|
// beware that first arg is noteId and second is branchId!
|
|
|
|
async function cloneNoteAfter(noteId, afterBranchId) {
|
|
|
|
const resp = await server.put('notes/' + noteId + '/clone-after/' + afterBranchId);
|
2018-01-14 07:02:41 +08:00
|
|
|
|
2018-03-25 23:09:17 +08:00
|
|
|
if (!resp.success) {
|
|
|
|
alert(resp.message);
|
|
|
|
return;
|
2018-01-14 07:02:41 +08:00
|
|
|
}
|
|
|
|
|
2018-03-25 23:09:17 +08:00
|
|
|
await treeService.reload();
|
|
|
|
}
|
|
|
|
|
|
|
|
export default {
|
|
|
|
cloneNoteAfter,
|
|
|
|
cloneNoteTo
|
|
|
|
};
|