Merge remote-tracking branch 'origin/stable'

# Conflicts:
#	libraries/ckeditor/ckeditor.js
#	libraries/ckeditor/ckeditor.js.map
#	package-lock.json
#	package.json
#	src/public/app/widgets/type_widgets/editable_text.js
This commit is contained in:
zadam
2020-06-03 16:25:45 +02:00
24 changed files with 295 additions and 225 deletions

View File

@@ -1,11 +0,0 @@
"use strict";
const anonymization = require('../../services/anonymization');
async function anonymize() {
await anonymization.anonymize();
}
module.exports = {
anonymize
};

View File

@@ -14,25 +14,33 @@ const TaskContext = require('../../services/task_context');
*/
async function moveBranchToParent(req) {
const {branchId, parentNoteId} = req.params;
const {branchId, parentBranchId} = req.params;
const parentBranch = await repository.getBranch(parentBranchId);
const branchToMove = await repository.getBranch(branchId);
if (branchToMove.parentNoteId === parentNoteId) {
if (!parentBranch || !branchToMove) {
return [400, `One or both branches ${branchId}, ${parentBranchId} have not been found`];
}
if (branchToMove.parentNoteId === parentBranch.noteId) {
return { success: true }; // no-op
}
const validationResult = await treeService.validateParentChild(parentNoteId, branchToMove.noteId, branchId);
const validationResult = await treeService.validateParentChild(parentBranch.noteId, branchToMove.noteId, branchId);
if (!validationResult.success) {
return [200, validationResult];
}
const maxNotePos = await sql.getValue('SELECT MAX(notePosition) FROM branches WHERE parentNoteId = ? AND isDeleted = 0', [parentNoteId]);
const maxNotePos = await sql.getValue('SELECT MAX(notePosition) FROM branches WHERE parentNoteId = ? AND isDeleted = 0', [parentBranch.noteId]);
const newNotePos = maxNotePos === null ? 0 : maxNotePos + 10;
const newBranch = branchToMove.createClone(parentNoteId, newNotePos);
newBranch.isExpanded = true;
// expanding so that the new placement of the branch is immediately visible
parentBranch.isExpanded = true;
await parentBranch.save();
const newBranch = branchToMove.createClone(parentBranch.noteId, newNotePos);
await newBranch.save();
branchToMove.isDeleted = true;
@@ -117,6 +125,7 @@ async function setExpanded(req) {
if (branchId !== 'root') {
await sql.execute("UPDATE branches SET isExpanded = ? WHERE branchId = ?", [expanded, branchId]);
// we don't sync expanded label
// also this does not trigger updates to the frontend, this would trigger too many reloads
}
}
@@ -178,4 +187,4 @@ module.exports = {
setExpandedForSubtree,
deleteBranch,
setPrefix
};
};

View File

@@ -3,10 +3,10 @@
const cloningService = require('../../services/cloning');
async function cloneNoteToParent(req) {
const {noteId, parentNoteId} = req.params;
const {noteId, parentBranchId} = req.params;
const {prefix} = req.body;
return await cloningService.cloneNoteToParent(noteId, parentNoteId, prefix);
return await cloningService.cloneNoteToParent(noteId, parentBranchId, prefix);
}
async function cloneNoteAfter(req) {
@@ -18,4 +18,4 @@ async function cloneNoteAfter(req) {
module.exports = {
cloneNoteToParent,
cloneNoteAfter
};
};

View File

@@ -5,6 +5,10 @@ const log = require('../../services/log');
const backupService = require('../../services/backup');
const consistencyChecksService = require('../../services/consistency_checks');
async function anonymize() {
return await backupService.anonymize();
}
async function backupDatabase() {
return {
backupFile: await backupService.backupNow("now")
@@ -24,5 +28,6 @@ async function findAndFixConsistencyIssues() {
module.exports = {
backupDatabase,
vacuumDatabase,
findAndFixConsistencyIssues
findAndFixConsistencyIssues,
anonymize
};