mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
server-ts: Convert routes/api/bulk_action
This commit is contained in:
parent
fd77c5e8c4
commit
40ef533c5f
@ -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
|
||||
};
|
@ -24,7 +24,7 @@ const indexRoute = require('./index.js');
|
||||
// API routes
|
||||
const treeApiRoute = require('./api/tree.js');
|
||||
const notesApiRoute = require('./api/notes.js');
|
||||
const branchesApiRoute = require('./api/branches.js');
|
||||
const branchesApiRoute = require('./api/branches');
|
||||
const attachmentsApiRoute = require('./api/attachments');
|
||||
const autocompleteApiRoute = require('./api/autocomplete');
|
||||
const cloningApiRoute = require('./api/cloning');
|
||||
@ -47,7 +47,7 @@ const scriptRoute = require('./api/script.js');
|
||||
const senderRoute = require('./api/sender.js');
|
||||
const filesRoute = require('./api/files.js');
|
||||
const searchRoute = require('./api/search');
|
||||
const bulkActionRoute = require('./api/bulk_action.js');
|
||||
const bulkActionRoute = require('./api/bulk_action');
|
||||
const specialNotesRoute = require('./api/special_notes');
|
||||
const noteMapRoute = require('./api/note_map.js');
|
||||
const clipperRoute = require('./api/clipper.js');
|
||||
|
@ -150,7 +150,7 @@ function getActions(note: BNote) {
|
||||
.filter(a => !!a);
|
||||
}
|
||||
|
||||
function executeActions(note: BNote, searchResultNoteIds: string[]) {
|
||||
function executeActions(note: BNote, searchResultNoteIds: string[] | Set<string>) {
|
||||
const actions = getActions(note);
|
||||
|
||||
for (const resultNoteId of searchResultNoteIds) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user