mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
server-ts: Convert routes/api/cloning
This commit is contained in:
parent
f98f84d419
commit
122ff3bb1d
@ -1,34 +1,35 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const cloningService = require('../../services/cloning');
|
import { Request } from 'express';
|
||||||
|
import cloningService = require('../../services/cloning');
|
||||||
|
|
||||||
function cloneNoteToBranch(req) {
|
function cloneNoteToBranch(req: Request) {
|
||||||
const {noteId, parentBranchId} = req.params;
|
const {noteId, parentBranchId} = req.params;
|
||||||
const {prefix} = req.body;
|
const {prefix} = req.body;
|
||||||
|
|
||||||
return cloningService.cloneNoteToBranch(noteId, parentBranchId, prefix);
|
return cloningService.cloneNoteToBranch(noteId, parentBranchId, prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
function cloneNoteToParentNote(req) {
|
function cloneNoteToParentNote(req: Request) {
|
||||||
const {noteId, parentNoteId} = req.params;
|
const {noteId, parentNoteId} = req.params;
|
||||||
const {prefix} = req.body;
|
const {prefix} = req.body;
|
||||||
|
|
||||||
return cloningService.cloneNoteToParentNote(noteId, parentNoteId, prefix);
|
return cloningService.cloneNoteToParentNote(noteId, parentNoteId, prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
function cloneNoteAfter(req) {
|
function cloneNoteAfter(req: Request) {
|
||||||
const {noteId, afterBranchId} = req.params;
|
const {noteId, afterBranchId} = req.params;
|
||||||
|
|
||||||
return cloningService.cloneNoteAfter(noteId, afterBranchId);
|
return cloningService.cloneNoteAfter(noteId, afterBranchId);
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleNoteInParent(req) {
|
function toggleNoteInParent(req: Request) {
|
||||||
const {noteId, parentNoteId, present} = req.params;
|
const {noteId, parentNoteId, present} = req.params;
|
||||||
|
|
||||||
return cloningService.toggleNoteInParent(present === 'true', noteId, parentNoteId);
|
return cloningService.toggleNoteInParent(present === 'true', noteId, parentNoteId);
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
export = {
|
||||||
cloneNoteToBranch,
|
cloneNoteToBranch,
|
||||||
cloneNoteToParentNote,
|
cloneNoteToParentNote,
|
||||||
cloneNoteAfter,
|
cloneNoteAfter,
|
@ -58,7 +58,7 @@ function cloneNoteToBranch(noteId: string, parentBranchId: string, prefix: strin
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
function ensureNoteIsPresentInParent(noteId: string, parentNoteId: string, prefix: string) {
|
function ensureNoteIsPresentInParent(noteId: string, parentNoteId: string, prefix?: string) {
|
||||||
if (!(noteId in becca.notes)) {
|
if (!(noteId in becca.notes)) {
|
||||||
return { branch: null, success: false, message: `Note '${noteId}' is deleted.` };
|
return { branch: null, success: false, message: `Note '${noteId}' is deleted.` };
|
||||||
} else if (!(parentNoteId in becca.notes)) {
|
} else if (!(parentNoteId in becca.notes)) {
|
||||||
@ -109,7 +109,7 @@ function ensureNoteIsAbsentFromParent(noteId: string, parentNoteId: string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleNoteInParent(present: boolean, noteId: string, parentNoteId: string, prefix: string) {
|
function toggleNoteInParent(present: boolean, noteId: string, parentNoteId: string, prefix?: string) {
|
||||||
if (present) {
|
if (present) {
|
||||||
return ensureNoteIsPresentInParent(noteId, parentNoteId, prefix);
|
return ensureNoteIsPresentInParent(noteId, parentNoteId, prefix);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user