mirror of
https://github.com/zadam/trilium.git
synced 2025-11-11 07:45:51 +01:00
server-ts: Convert routes/api/bulk_action
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
import fs = require('fs');
|
||||
import dateUtils = require('../../services/date_utils');
|
||||
import dataDir = require('../../services/data_dir.js');
|
||||
import dataDir = require('../../services/data_dir');
|
||||
const { LOG_DIR } = dataDir;
|
||||
|
||||
function getBackendLog() {
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
const becca = require('../../becca/becca');
|
||||
const bulkActionService = require('../../services/bulk_actions');
|
||||
import { Request } from 'express';
|
||||
import becca = require('../../becca/becca');
|
||||
import bulkActionService = require('../../services/bulk_actions');
|
||||
|
||||
function execute(req) {
|
||||
function execute(req: Request) {
|
||||
const {noteIds, includeDescendants} = req.body;
|
||||
|
||||
const affectedNoteIds = getAffectedNoteIds(noteIds, includeDescendants);
|
||||
|
||||
const bulkActionNote = becca.getNote('_bulkAction');
|
||||
const bulkActionNote = becca.getNoteOrThrow('_bulkAction');
|
||||
|
||||
bulkActionService.executeActions(bulkActionNote, affectedNoteIds);
|
||||
}
|
||||
|
||||
function getAffectedNoteCount(req) {
|
||||
function getAffectedNoteCount(req: Request) {
|
||||
const {noteIds, includeDescendants} = req.body;
|
||||
|
||||
const affectedNoteIds = getAffectedNoteIds(noteIds, includeDescendants);
|
||||
@@ -21,8 +22,8 @@ function getAffectedNoteCount(req) {
|
||||
};
|
||||
}
|
||||
|
||||
function getAffectedNoteIds(noteIds, includeDescendants) {
|
||||
const affectedNoteIds = new Set();
|
||||
function getAffectedNoteIds(noteIds: string[], includeDescendants: boolean) {
|
||||
const affectedNoteIds = new Set<string>();
|
||||
|
||||
for (const noteId of noteIds) {
|
||||
const note = becca.getNote(noteId);
|
||||
@@ -42,7 +43,7 @@ function getAffectedNoteIds(noteIds, includeDescendants) {
|
||||
return affectedNoteIds;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
export = {
|
||||
execute,
|
||||
getAffectedNoteCount
|
||||
};
|
||||
Reference in New Issue
Block a user