mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
server-ts: Port services/branches
This commit is contained in:
parent
0d4fb42731
commit
9ea4fcd667
@ -7,7 +7,7 @@ const treeService = require('../../services/tree');
|
||||
const eraseService = require('../../services/erase');
|
||||
const becca = require('../../becca/becca');
|
||||
const TaskContext = require('../../services/task_context');
|
||||
const branchService = require('../../services/branches.js');
|
||||
const branchService = require('../../services/branches');
|
||||
const log = require('../../services/log');
|
||||
const ValidationError = require('../../errors/validation_error');
|
||||
const eventService = require("../../services/events");
|
||||
|
@ -17,7 +17,7 @@ const becca = require('../becca/becca');
|
||||
const ws = require('./ws');
|
||||
const SpacedUpdate = require('./spaced_update.js');
|
||||
const specialNotesService = require('./special_notes.js');
|
||||
const branchService = require('./branches.js');
|
||||
const branchService = require('./branches');
|
||||
const exportService = require('./export/zip.js');
|
||||
const syncMutex = require('./sync_mutex');
|
||||
const backupService = require('./backup');
|
||||
|
@ -1,7 +1,8 @@
|
||||
const treeService = require('./tree');
|
||||
const sql = require('./sql');
|
||||
import treeService = require('./tree');
|
||||
import sql = require('./sql');
|
||||
import BBranch = require('../becca/entities/bbranch.js');
|
||||
|
||||
function moveBranchToNote(branchToMove, targetParentNoteId) {
|
||||
function moveBranchToNote(branchToMove: BBranch, targetParentNoteId: string) {
|
||||
if (branchToMove.parentNoteId === targetParentNoteId) {
|
||||
return {success: true}; // no-op
|
||||
}
|
||||
@ -12,8 +13,8 @@ function moveBranchToNote(branchToMove, targetParentNoteId) {
|
||||
return [200, validationResult];
|
||||
}
|
||||
|
||||
const maxNotePos = sql.getValue('SELECT MAX(notePosition) FROM branches WHERE parentNoteId = ? AND isDeleted = 0', [targetParentNoteId]);
|
||||
const newNotePos = maxNotePos === null ? 0 : maxNotePos + 10;
|
||||
const maxNotePos = sql.getValue<number | null>('SELECT MAX(notePosition) FROM branches WHERE parentNoteId = ? AND isDeleted = 0', [targetParentNoteId]);
|
||||
const newNotePos = !maxNotePos ? 0 : maxNotePos + 10;
|
||||
|
||||
const newBranch = branchToMove.createClone(targetParentNoteId, newNotePos);
|
||||
newBranch.save();
|
||||
@ -26,10 +27,10 @@ function moveBranchToNote(branchToMove, targetParentNoteId) {
|
||||
};
|
||||
}
|
||||
|
||||
function moveBranchToBranch(branchToMove, targetParentBranch) {
|
||||
function moveBranchToBranch(branchToMove: BBranch, targetParentBranch: BBranch) {
|
||||
const res = moveBranchToNote(branchToMove, targetParentBranch.noteId);
|
||||
|
||||
if (!res.success) {
|
||||
if (!("success" in res) || !res.success) {
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -42,7 +43,7 @@ function moveBranchToBranch(branchToMove, targetParentBranch) {
|
||||
return res;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
export = {
|
||||
moveBranchToBranch,
|
||||
moveBranchToNote
|
||||
};
|
@ -2,7 +2,7 @@ const log = require('./log');
|
||||
const revisionService = require('./revisions');
|
||||
const becca = require('../becca/becca');
|
||||
const cloningService = require('./cloning.js');
|
||||
const branchService = require('./branches.js');
|
||||
const branchService = require('./branches');
|
||||
const utils = require('./utils');
|
||||
const eraseService = require("./erase");
|
||||
|
||||
|
@ -261,7 +261,7 @@ function setNoteToParent(noteId: string, prefix: string, parentNoteId: string) {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
export = {
|
||||
validateParentChild,
|
||||
sortNotes,
|
||||
sortNotesIfNeeded,
|
||||
|
Loading…
x
Reference in New Issue
Block a user