mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
refactorings of search actions to bulk actions
This commit is contained in:
parent
4211d0feda
commit
88fa51a34e
@ -1,27 +1,27 @@
|
||||
import server from "./server.js";
|
||||
import ws from "./ws.js";
|
||||
import MoveNoteSearchAction from "../widgets/search_actions/move_note.js";
|
||||
import DeleteNoteSearchAction from "../widgets/search_actions/delete_note.js";
|
||||
import DeleteNoteRevisionsSearchAction from "../widgets/search_actions/delete_note_revisions.js";
|
||||
import DeleteLabelSearchAction from "../widgets/search_actions/delete_label.js";
|
||||
import DeleteRelationSearchAction from "../widgets/search_actions/delete_relation.js";
|
||||
import RenameLabelSearchAction from "../widgets/search_actions/rename_label.js";
|
||||
import RenameRelationSearchAction from "../widgets/search_actions/rename_relation.js";
|
||||
import SetLabelValueSearchAction from "../widgets/search_actions/set_label_value.js";
|
||||
import SetRelationTargetSearchAction from "../widgets/search_actions/set_relation_target.js";
|
||||
import ExecuteScriptSearchAction from "../widgets/search_actions/execute_script.js";
|
||||
import MoveNoteBulkAction from "../widgets/bulk_actions/move_note.js";
|
||||
import DeleteNoteBulkAction from "../widgets/bulk_actions/delete_note.js";
|
||||
import DeleteNoteRevisionsBulkAction from "../widgets/bulk_actions/delete_note_revisions.js";
|
||||
import DeleteLabelBulkAction from "../widgets/bulk_actions/delete_label.js";
|
||||
import DeleteRelationBulkAction from "../widgets/bulk_actions/delete_relation.js";
|
||||
import RenameLabelBulkAction from "../widgets/bulk_actions/rename_label.js";
|
||||
import RenameRelationBulkAction from "../widgets/bulk_actions/rename_relation.js";
|
||||
import SetLabelValueBulkAction from "../widgets/bulk_actions/set_label_value.js";
|
||||
import SetRelationTargetSearchAction from "../widgets/bulk_actions/set_relation_target.js";
|
||||
import ExecuteScriptBulkAction from "../widgets/bulk_actions/execute_script.js";
|
||||
|
||||
const ACTION_CLASSES = [
|
||||
MoveNoteSearchAction,
|
||||
DeleteNoteSearchAction,
|
||||
DeleteNoteRevisionsSearchAction,
|
||||
DeleteLabelSearchAction,
|
||||
DeleteRelationSearchAction,
|
||||
RenameLabelSearchAction,
|
||||
RenameRelationSearchAction,
|
||||
SetLabelValueSearchAction,
|
||||
MoveNoteBulkAction,
|
||||
DeleteNoteBulkAction,
|
||||
DeleteNoteRevisionsBulkAction,
|
||||
DeleteLabelBulkAction,
|
||||
DeleteRelationBulkAction,
|
||||
RenameLabelBulkAction,
|
||||
RenameRelationBulkAction,
|
||||
SetLabelValueBulkAction,
|
||||
SetRelationTargetSearchAction,
|
||||
ExecuteScriptSearchAction
|
||||
ExecuteScriptBulkAction
|
||||
];
|
||||
|
||||
async function addAction(noteId, actionName) {
|
||||
|
@ -3,7 +3,7 @@ import ws from "../../services/ws.js";
|
||||
import Component from "../component.js";
|
||||
import utils from "../../services/utils.js";
|
||||
|
||||
export default class AbstractSearchAction {
|
||||
export default class AbstractBulkAction {
|
||||
constructor(attribute, actionDef) {
|
||||
this.attribute = attribute;
|
||||
this.actionDef = actionDef;
|
65
src/public/app/widgets/bulk_actions/add_label.js
Normal file
65
src/public/app/widgets/bulk_actions/add_label.js
Normal file
@ -0,0 +1,65 @@
|
||||
import SpacedUpdate from "../../services/spaced_update.js";
|
||||
import AbstractBulkAction from "./abstract_bulk_action.js";
|
||||
|
||||
const TPL = `
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<div style="display: flex; align-items: center">
|
||||
<div style="margin-right: 10px;" class="text-nowrap">Set label</div>
|
||||
|
||||
<input type="text"
|
||||
class="form-control label-name"
|
||||
placeholder="label name"
|
||||
pattern="[\\p{L}\\p{N}_:]+"
|
||||
title="Alphanumeric characters, underscore and colon are allowed characters."/>
|
||||
|
||||
<div style="margin-right: 10px; margin-left: 10px;" class="text-nowrap">to value</div>
|
||||
|
||||
<input type="text" class="form-control label-value" placeholder="new value"/>
|
||||
</div>
|
||||
</td>
|
||||
<td class="button-column">
|
||||
<div class="dropdown help-dropdown">
|
||||
<span class="bx bx-help-circle icon-action" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"></span>
|
||||
<div class="dropdown-menu dropdown-menu-right p-4">
|
||||
<p>On all matched notes:</p>
|
||||
|
||||
<ul>
|
||||
<li>create given label if note doesn't have one yet</li>
|
||||
<li>or change value of the existing label</li>
|
||||
</ul>
|
||||
|
||||
<p>You can also call this method without value, in such case label will be assigned to the note without value.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<span class="bx bx-x icon-action action-conf-del"></span>
|
||||
</td>
|
||||
</tr>`;
|
||||
|
||||
export default class AddLabelBulkAction extends AbstractBulkAction {
|
||||
static get actionName() { return "setLabelValue"; }
|
||||
static get actionTitle() { return "Set label value"; }
|
||||
|
||||
doRender() {
|
||||
const $action = $(TPL);
|
||||
|
||||
const $labelName = $action.find('.label-name');
|
||||
$labelName.val(this.actionDef.labelName || "");
|
||||
|
||||
const $labelValue = $action.find('.label-value');
|
||||
$labelValue.val(this.actionDef.labelValue || "");
|
||||
|
||||
const spacedUpdate = new SpacedUpdate(async () => {
|
||||
await this.saveAction({
|
||||
labelName: $labelName.val(),
|
||||
labelValue: $labelValue.val()
|
||||
});
|
||||
}, 1000)
|
||||
|
||||
$labelName.on('input', () => spacedUpdate.scheduleUpdate());
|
||||
$labelValue.on('input', () => spacedUpdate.scheduleUpdate());
|
||||
|
||||
return $action;
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
import SpacedUpdate from "../../services/spaced_update.js";
|
||||
import AbstractSearchAction from "./abstract_search_action.js";
|
||||
import AbstractBulkAction from "./abstract_bulk_action.js";
|
||||
|
||||
const TPL = `
|
||||
<tr>
|
||||
@ -18,7 +18,7 @@ const TPL = `
|
||||
</td>
|
||||
</tr>`;
|
||||
|
||||
export default class DeleteLabelSearchAction extends AbstractSearchAction {
|
||||
export default class DeleteLabelBulkAction extends AbstractBulkAction {
|
||||
static get actionName() { return "deleteLabel"; }
|
||||
static get actionTitle() { return "Delete label"; }
|
||||
|
@ -1,4 +1,4 @@
|
||||
import AbstractSearchAction from "./abstract_search_action.js";
|
||||
import AbstractBulkAction from "./abstract_bulk_action.js";
|
||||
|
||||
const TPL = `
|
||||
<tr>
|
||||
@ -12,7 +12,7 @@ const TPL = `
|
||||
</td>
|
||||
</tr>`;
|
||||
|
||||
export default class DeleteNoteSearchAction extends AbstractSearchAction {
|
||||
export default class DeleteNoteBulkAction extends AbstractBulkAction {
|
||||
static get actionName() { return "deleteNote"; }
|
||||
static get actionTitle() { return "Delete note"; }
|
||||
|
@ -1,4 +1,4 @@
|
||||
import AbstractSearchAction from "./abstract_search_action.js";
|
||||
import AbstractBulkAction from "./abstract_bulk_action.js";
|
||||
|
||||
const TPL = `
|
||||
<tr>
|
||||
@ -19,7 +19,7 @@ const TPL = `
|
||||
</td>
|
||||
</tr>`;
|
||||
|
||||
export default class DeleteNoteRevisionsSearchAction extends AbstractSearchAction {
|
||||
export default class DeleteNoteRevisionsBulkAction extends AbstractBulkAction {
|
||||
static get actionName() { return "deleteNoteRevisions"; }
|
||||
static get actionTitle() { return "Delete note revisions"; }
|
||||
|
@ -1,5 +1,5 @@
|
||||
import SpacedUpdate from "../../services/spaced_update.js";
|
||||
import AbstractSearchAction from "./abstract_search_action.js";
|
||||
import AbstractBulkAction from "./abstract_bulk_action.js";
|
||||
|
||||
const TPL = `
|
||||
<tr>
|
||||
@ -20,7 +20,7 @@ const TPL = `
|
||||
</td>
|
||||
</tr>`;
|
||||
|
||||
export default class DeleteRelationSearchAction extends AbstractSearchAction {
|
||||
export default class DeleteRelationBulkAction extends AbstractBulkAction {
|
||||
static get actionName() { return "deleteRelation"; }
|
||||
static get actionTitle() { return "Delete relation"; }
|
||||
|
@ -1,5 +1,5 @@
|
||||
import SpacedUpdate from "../../services/spaced_update.js";
|
||||
import AbstractSearchAction from "./abstract_search_action.js";
|
||||
import AbstractBulkAction from "./abstract_bulk_action.js";
|
||||
|
||||
const TPL = `
|
||||
<tr>
|
||||
@ -33,7 +33,7 @@ const TPL = `
|
||||
</td>
|
||||
</tr>`;
|
||||
|
||||
export default class ExecuteScriptSearchAction extends AbstractSearchAction {
|
||||
export default class ExecuteScriptBulkAction extends AbstractBulkAction {
|
||||
static get actionName() { return "executeScript"; }
|
||||
static get actionTitle() { return "Execute script"; }
|
||||
|
@ -1,5 +1,5 @@
|
||||
import SpacedUpdate from "../../services/spaced_update.js";
|
||||
import AbstractSearchAction from "./abstract_search_action.js";
|
||||
import AbstractBulkAction from "./abstract_bulk_action.js";
|
||||
import noteAutocompleteService from "../../services/note_autocomplete.js";
|
||||
|
||||
const TPL = `
|
||||
@ -33,7 +33,7 @@ const TPL = `
|
||||
</td>
|
||||
</tr>`;
|
||||
|
||||
export default class MoveNoteSearchAction extends AbstractSearchAction {
|
||||
export default class MoveNoteBulkAction extends AbstractBulkAction {
|
||||
static get actionName() { return "moveNote"; }
|
||||
static get actionTitle() { return "Move note"; }
|
||||
|
@ -1,5 +1,5 @@
|
||||
import SpacedUpdate from "../../services/spaced_update.js";
|
||||
import AbstractSearchAction from "./abstract_search_action.js";
|
||||
import AbstractBulkAction from "./abstract_bulk_action.js";
|
||||
|
||||
const TPL = `
|
||||
<tr>
|
||||
@ -27,7 +27,7 @@ const TPL = `
|
||||
</td>
|
||||
</tr>`;
|
||||
|
||||
export default class RenameLabelSearchAction extends AbstractSearchAction {
|
||||
export default class RenameLabelBulkAction extends AbstractBulkAction {
|
||||
static get actionName() { return "renameLabel"; }
|
||||
static get actionTitle() { return "Rename label"; }
|
||||
|
@ -1,5 +1,5 @@
|
||||
import SpacedUpdate from "../../services/spaced_update.js";
|
||||
import AbstractSearchAction from "./abstract_search_action.js";
|
||||
import AbstractBulkAction from "./abstract_bulk_action.js";
|
||||
|
||||
const TPL = `
|
||||
<tr>
|
||||
@ -27,7 +27,7 @@ const TPL = `
|
||||
</td>
|
||||
</tr>`;
|
||||
|
||||
export default class RenameRelationSearchAction extends AbstractSearchAction {
|
||||
export default class RenameRelationBulkAction extends AbstractBulkAction {
|
||||
static get actionName() { return "renameRelation"; }
|
||||
static get actionTitle() { return "Rename relation"; }
|
||||
|
@ -1,5 +1,5 @@
|
||||
import SpacedUpdate from "../../services/spaced_update.js";
|
||||
import AbstractSearchAction from "./abstract_search_action.js";
|
||||
import AbstractBulkAction from "./abstract_bulk_action.js";
|
||||
|
||||
const TPL = `
|
||||
<tr>
|
||||
@ -37,7 +37,7 @@ const TPL = `
|
||||
</td>
|
||||
</tr>`;
|
||||
|
||||
export default class SetLabelValueSearchAction extends AbstractSearchAction {
|
||||
export default class SetLabelValueBulkAction extends AbstractBulkAction {
|
||||
static get actionName() { return "setLabelValue"; }
|
||||
static get actionTitle() { return "Set label value"; }
|
||||
|
@ -1,5 +1,5 @@
|
||||
import SpacedUpdate from "../../services/spaced_update.js";
|
||||
import AbstractSearchAction from "./abstract_search_action.js";
|
||||
import AbstractBulkAction from "./abstract_bulk_action.js";
|
||||
import noteAutocompleteService from "../../services/note_autocomplete.js";
|
||||
|
||||
const TPL = `
|
||||
@ -39,7 +39,7 @@ const TPL = `
|
||||
</td>
|
||||
</tr>`;
|
||||
|
||||
export default class SetRelationTargetSearchAction extends AbstractSearchAction {
|
||||
export default class SetRelationTargetSearchAction extends AbstractBulkAction {
|
||||
static get actionName() { return "setRelationTarget"; }
|
||||
static get actionTitle() { return "Set relation target"; }
|
||||
|
@ -8,7 +8,7 @@ const {sleep} = utils;
|
||||
|
||||
const TPL = `
|
||||
<div class="canvas-widget note-detail-canvas note-detail-printable note-detail">
|
||||
<style type="text/css">
|
||||
<style>
|
||||
.excalidraw .App-menu_top .buttonList {
|
||||
display: flex;
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ document.addEventListener("DOMContentLoaded", function() {
|
||||
header += `<script src="../../node_modules/react/umd/react.production.min.js"></script>`;
|
||||
header += `<script src="../../node_modules/react-dom/umd/react-dom.production.min.js"></script>`;
|
||||
header += `<script src="../../node_modules/@excalidraw/excalidraw/dist/excalidraw.production.min.js"></script>`;
|
||||
header += `<style type="text/css">
|
||||
header += `<style>
|
||||
|
||||
.excalidraw-wrapper {
|
||||
height: 100%;
|
||||
|
@ -1,6 +1,5 @@
|
||||
<style>
|
||||
#bulk-available-action-list button {
|
||||
font-size: small;
|
||||
padding: 2px 7px;
|
||||
margin-right: 10px;
|
||||
margin-bottom: 5px;
|
||||
|
Loading…
x
Reference in New Issue
Block a user