mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
trigger execute bulk actions
This commit is contained in:
parent
041b4ea442
commit
63f0e441b9
@ -130,7 +130,17 @@ class TreeContextMenu {
|
|||||||
this.treeWidget.triggerCommand("openNewNoteSplit", {ntxId, notePath});
|
this.treeWidget.triggerCommand("openNewNoteSplit", {ntxId, notePath});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.treeWidget.triggerCommand(command, {node: this.node, notePath: notePath});
|
const selectedOrActiveBranchIds = this.treeWidget.getSelectedOrActiveBranchIds(this.node);
|
||||||
|
const selectedOrActiveNoteIds = selectedOrActiveBranchIds
|
||||||
|
.map(branchId => froca.getBranch(branchId).noteId)
|
||||||
|
.filter(noteId => !!noteId);
|
||||||
|
|
||||||
|
this.treeWidget.triggerCommand(command, {
|
||||||
|
node: this.node,
|
||||||
|
notePath: notePath,
|
||||||
|
selectedOrActiveBranchIds,
|
||||||
|
selectedOrActiveNoteIds
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ export default class AddLabelBulkAction extends AbstractBulkAction {
|
|||||||
labelName: $labelName.val(),
|
labelName: $labelName.val(),
|
||||||
labelValue: $labelValue.val()
|
labelValue: $labelValue.val()
|
||||||
});
|
});
|
||||||
}, 1000)
|
}, 1000);
|
||||||
|
|
||||||
$labelName.on('input', () => spacedUpdate.scheduleUpdate());
|
$labelName.on('input', () => spacedUpdate.scheduleUpdate());
|
||||||
$labelValue.on('input', () => spacedUpdate.scheduleUpdate());
|
$labelValue.on('input', () => spacedUpdate.scheduleUpdate());
|
||||||
|
@ -2,6 +2,8 @@ import BasicWidget from "../basic_widget.js";
|
|||||||
import froca from "../../services/froca.js";
|
import froca from "../../services/froca.js";
|
||||||
import bulkActionService from "../../services/bulk_action.js";
|
import bulkActionService from "../../services/bulk_action.js";
|
||||||
import utils from "../../services/utils.js";
|
import utils from "../../services/utils.js";
|
||||||
|
import server from "../../services/server.js";
|
||||||
|
import toastService from "../../services/toast.js";
|
||||||
|
|
||||||
const TPL = `
|
const TPL = `
|
||||||
<div class="bulk-assign-attributes-dialog modal mx-auto" tabindex="-1" role="dialog">
|
<div class="bulk-assign-attributes-dialog modal mx-auto" tabindex="-1" role="dialog">
|
||||||
@ -60,7 +62,7 @@ const TPL = `
|
|||||||
<table class="bulk-existing-action-list"></table>
|
<table class="bulk-existing-action-list"></table>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="submit" class="btn btn-primary">Execute bulk actions</button>
|
<button type="submit" class="execute-bulk-actions btn btn-primary">Execute bulk actions</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -79,6 +81,15 @@ export default class BulkActionsDialog extends BasicWidget {
|
|||||||
|
|
||||||
await this.refresh();
|
await this.refresh();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.$executeButton = this.$widget.find(".execute-bulk-actions");
|
||||||
|
this.$executeButton.on("click", async () => {
|
||||||
|
await server.post("bulk-action", { noteIds: this.selectedOrActiveNoteIds });
|
||||||
|
|
||||||
|
toastService.showMessage("Bulk actions have been executed successfully.", 3000);
|
||||||
|
|
||||||
|
utils.closeActiveDialog();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async refresh() {
|
async refresh() {
|
||||||
@ -119,12 +130,15 @@ export default class BulkActionsDialog extends BasicWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
entitiesReloadedEvent({loadResults}) {
|
entitiesReloadedEvent({loadResults}) {
|
||||||
if (loadResults.getAttributes().find(attr => attr.type === 'label' && attr.name === 'action')) {
|
// only refreshing deleted attrs, otherwise components update themselves
|
||||||
|
if (loadResults.getAttributes().find(attr => attr.type === 'label' && attr.name === 'action' && attr.isDeleted)) {
|
||||||
this.refresh();
|
this.refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async bulkActionsEvent({node}) {
|
async bulkActionsEvent({selectedOrActiveNoteIds}) {
|
||||||
|
this.selectedOrActiveNoteIds = selectedOrActiveNoteIds;
|
||||||
|
|
||||||
await this.refresh();
|
await this.refresh();
|
||||||
|
|
||||||
utils.openDialog(this.$widget);
|
utils.openDialog(this.$widget);
|
||||||
|
@ -307,7 +307,8 @@ export default class SearchDefinitionWidget extends NoteContextAwareWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
entitiesReloadedEvent({loadResults}) {
|
entitiesReloadedEvent({loadResults}) {
|
||||||
if (loadResults.getAttributes().find(attr => attr.type === 'label' && attr.name === 'action')) {
|
// only refreshing deleted attrs, otherwise components update themselves
|
||||||
|
if (loadResults.getAttributes().find(attr => attr.type === 'label' && attr.name === 'action' && attr.isDeleted)) {
|
||||||
this.refresh();
|
this.refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
14
src/routes/api/bulk_action.js
Normal file
14
src/routes/api/bulk_action.js
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
const becca = require("../../becca/becca");
|
||||||
|
const bulkActionService = require("../../services/bulk_actions");
|
||||||
|
|
||||||
|
function execute(req) {
|
||||||
|
const {noteIds} = req.body;
|
||||||
|
|
||||||
|
const bulkActionNote = becca.getNote('bulkaction');
|
||||||
|
|
||||||
|
bulkActionService.executeActions(bulkActionNote, noteIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
execute
|
||||||
|
};
|
@ -31,6 +31,7 @@ const scriptRoute = require('./api/script');
|
|||||||
const senderRoute = require('./api/sender');
|
const senderRoute = require('./api/sender');
|
||||||
const filesRoute = require('./api/files');
|
const filesRoute = require('./api/files');
|
||||||
const searchRoute = require('./api/search');
|
const searchRoute = require('./api/search');
|
||||||
|
const bulkActionRoute = require('./api/bulk_action');
|
||||||
const specialNotesRoute = require('./api/special_notes');
|
const specialNotesRoute = require('./api/special_notes');
|
||||||
const noteMapRoute = require('./api/note_map');
|
const noteMapRoute = require('./api/note_map');
|
||||||
const clipperRoute = require('./api/clipper');
|
const clipperRoute = require('./api/clipper');
|
||||||
@ -357,6 +358,8 @@ function register(app) {
|
|||||||
apiRoute(GET, '/api/search/:searchString', searchRoute.search);
|
apiRoute(GET, '/api/search/:searchString', searchRoute.search);
|
||||||
apiRoute(GET, '/api/search-templates', searchRoute.searchTemplates);
|
apiRoute(GET, '/api/search-templates', searchRoute.searchTemplates);
|
||||||
|
|
||||||
|
apiRoute(POST, '/api/bulk-action', bulkActionRoute.execute);
|
||||||
|
|
||||||
route(POST, '/api/login/sync', [], loginApiRoute.loginSync, apiResultHandler);
|
route(POST, '/api/login/sync', [], loginApiRoute.loginSync, apiResultHandler);
|
||||||
// this is for entering protected mode so user has to be already logged-in (that's the reason we don't require username)
|
// this is for entering protected mode so user has to be already logged-in (that's the reason we don't require username)
|
||||||
apiRoute(POST, '/api/login/protected', loginApiRoute.loginToProtectedSession);
|
apiRoute(POST, '/api/login/protected', loginApiRoute.loginToProtectedSession);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user