mirror of
https://github.com/zadam/trilium.git
synced 2024-12-29 11:24:45 +08:00
refactorings of search actions to bulk actions
This commit is contained in:
parent
88fa51a34e
commit
773cefe21d
14 changed files with 114 additions and 48 deletions
2
db/migrations/0196__rename_bulk_actions.sql
Normal file
2
db/migrations/0196__rename_bulk_actions.sql
Normal file
|
@ -0,0 +1,2 @@
|
|||
UPDATE attributes SET name = 'updateLabelValue' WHERE name = 'setLabelValue' AND type = 'label';
|
||||
UPDATE attributes SET name = 'updateRelationTarget' WHERE name = 'setRelationTarget' AND type = 'label';
|
|
@ -1,15 +1,17 @@
|
|||
import server from "./server.js";
|
||||
import ws from "./ws.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 MoveNoteBulkAction from "../widgets/bulk_actions/note/move_note.js";
|
||||
import DeleteNoteBulkAction from "../widgets/bulk_actions/note/delete_note.js";
|
||||
import DeleteNoteRevisionsBulkAction from "../widgets/bulk_actions/note/delete_note_revisions.js";
|
||||
import DeleteLabelBulkAction from "../widgets/bulk_actions/label/delete_label.js";
|
||||
import DeleteRelationBulkAction from "../widgets/bulk_actions/relation/delete_relation.js";
|
||||
import RenameLabelBulkAction from "../widgets/bulk_actions/label/rename_label.js";
|
||||
import RenameRelationBulkAction from "../widgets/bulk_actions/relation/rename_relation.js";
|
||||
import UpdateLabelValueBulkAction from "../widgets/bulk_actions/label/update_label_value.js";
|
||||
import UpdateRelationTargetBulkAction from "../widgets/bulk_actions/relation/update_relation_target.js";
|
||||
import ExecuteScriptBulkAction from "../widgets/bulk_actions/execute_script.js";
|
||||
import AddLabelBulkAction from "../widgets/bulk_actions/label/add_label.js";
|
||||
import AddRelationBulkAction from "../widgets/bulk_actions/relation/add_relation.js";
|
||||
|
||||
const ACTION_CLASSES = [
|
||||
MoveNoteBulkAction,
|
||||
|
@ -19,8 +21,10 @@ const ACTION_CLASSES = [
|
|||
DeleteRelationBulkAction,
|
||||
RenameLabelBulkAction,
|
||||
RenameRelationBulkAction,
|
||||
SetLabelValueBulkAction,
|
||||
SetRelationTargetSearchAction,
|
||||
AddLabelBulkAction,
|
||||
AddRelationBulkAction,
|
||||
UpdateLabelValueBulkAction,
|
||||
UpdateRelationTargetBulkAction,
|
||||
ExecuteScriptBulkAction
|
||||
];
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import SpacedUpdate from "../../services/spaced_update.js";
|
||||
import AbstractBulkAction from "./abstract_bulk_action.js";
|
||||
import SpacedUpdate from "../../../services/spaced_update.js";
|
||||
import AbstractBulkAction from "../abstract_bulk_action.js";
|
||||
|
||||
const TPL = `
|
||||
<tr>
|
||||
|
@ -38,8 +38,8 @@ const TPL = `
|
|||
</tr>`;
|
||||
|
||||
export default class AddLabelBulkAction extends AbstractBulkAction {
|
||||
static get actionName() { return "setLabelValue"; }
|
||||
static get actionTitle() { return "Set label value"; }
|
||||
static get actionName() { return "addLabel"; }
|
||||
static get actionTitle() { return "Add label"; }
|
||||
|
||||
doRender() {
|
||||
const $action = $(TPL);
|
|
@ -1,5 +1,5 @@
|
|||
import SpacedUpdate from "../../services/spaced_update.js";
|
||||
import AbstractBulkAction from "./abstract_bulk_action.js";
|
||||
import SpacedUpdate from "../../../services/spaced_update.js";
|
||||
import AbstractBulkAction from "../abstract_bulk_action.js";
|
||||
|
||||
const TPL = `
|
||||
<tr>
|
|
@ -1,5 +1,5 @@
|
|||
import SpacedUpdate from "../../services/spaced_update.js";
|
||||
import AbstractBulkAction from "./abstract_bulk_action.js";
|
||||
import SpacedUpdate from "../../../services/spaced_update.js";
|
||||
import AbstractBulkAction from "../abstract_bulk_action.js";
|
||||
|
||||
const TPL = `
|
||||
<tr>
|
|
@ -1,11 +1,11 @@
|
|||
import SpacedUpdate from "../../services/spaced_update.js";
|
||||
import AbstractBulkAction from "./abstract_bulk_action.js";
|
||||
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>
|
||||
<div style="margin-right: 10px;" class="text-nowrap">Update label value</div>
|
||||
|
||||
<input type="text"
|
||||
class="form-control label-name"
|
||||
|
@ -22,12 +22,7 @@ const TPL = `
|
|||
<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>On all matched notes, change value of the existing label.</p>
|
||||
|
||||
<p>You can also call this method without value, in such case label will be assigned to the note without value.</p>
|
||||
</div>
|
||||
|
@ -37,9 +32,9 @@ const TPL = `
|
|||
</td>
|
||||
</tr>`;
|
||||
|
||||
export default class SetLabelValueBulkAction extends AbstractBulkAction {
|
||||
static get actionName() { return "setLabelValue"; }
|
||||
static get actionTitle() { return "Set label value"; }
|
||||
export default class UpdateLabelValueBulkAction extends AbstractBulkAction {
|
||||
static get actionName() { return "updateLabelValue"; }
|
||||
static get actionTitle() { return "Update label value"; }
|
||||
|
||||
doRender() {
|
||||
const $action = $(TPL);
|
|
@ -1,4 +1,4 @@
|
|||
import AbstractBulkAction from "./abstract_bulk_action.js";
|
||||
import AbstractBulkAction from "../abstract_bulk_action.js";
|
||||
|
||||
const TPL = `
|
||||
<tr>
|
|
@ -1,4 +1,4 @@
|
|||
import AbstractBulkAction from "./abstract_bulk_action.js";
|
||||
import AbstractBulkAction from "../abstract_bulk_action.js";
|
||||
|
||||
const TPL = `
|
||||
<tr>
|
|
@ -1,6 +1,6 @@
|
|||
import SpacedUpdate from "../../services/spaced_update.js";
|
||||
import AbstractBulkAction from "./abstract_bulk_action.js";
|
||||
import noteAutocompleteService from "../../services/note_autocomplete.js";
|
||||
import SpacedUpdate from "../../../services/spaced_update.js";
|
||||
import AbstractBulkAction from "../abstract_bulk_action.js";
|
||||
import noteAutocompleteService from "../../../services/note_autocomplete.js";
|
||||
|
||||
const TPL = `
|
||||
<tr>
|
65
src/public/app/widgets/bulk_actions/relation/add_relation.js
Normal file
65
src/public/app/widgets/bulk_actions/relation/add_relation.js
Normal file
|
@ -0,0 +1,65 @@
|
|||
import SpacedUpdate from "../../../services/spaced_update.js";
|
||||
import AbstractBulkAction from "../abstract_bulk_action.js";
|
||||
import noteAutocompleteService from "../../../services/note_autocomplete.js";
|
||||
|
||||
const TPL = `
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<div style="display: flex; align-items: center">
|
||||
<div style="margin-right: 10px;" class="text-nowrap">Set relation</div>
|
||||
|
||||
<input type="text"
|
||||
class="form-control relation-name"
|
||||
placeholder="relation name"
|
||||
pattern="[\\p{L}\\p{N}_:]+"
|
||||
style="flex-shrink: 3"
|
||||
title="Alphanumeric characters, underscore and colon are allowed characters."/>
|
||||
|
||||
<div style="margin-right: 10px; margin-left: 10px;" class="text-nowrap">to</div>
|
||||
|
||||
<div class="input-group" style="flex-shrink: 2">
|
||||
<input type="text" class="form-control target-note" placeholder="target note"/>
|
||||
</div>
|
||||
</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 create given relation.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<span class="bx bx-x icon-action action-conf-del"></span>
|
||||
</td>
|
||||
</tr>`;
|
||||
|
||||
export default class AddRelationBulkAction extends AbstractBulkAction {
|
||||
static get actionName() { return "addRelation"; }
|
||||
static get actionTitle() { return "Add relation"; }
|
||||
|
||||
doRender() {
|
||||
const $action = $(TPL);
|
||||
|
||||
const $relationName = $action.find('.relation-name');
|
||||
$relationName.val(this.actionDef.relationName || "");
|
||||
|
||||
const $targetNote = $action.find('.target-note');
|
||||
noteAutocompleteService.initNoteAutocomplete($targetNote);
|
||||
$targetNote.setNote(this.actionDef.targetNoteId);
|
||||
|
||||
$targetNote.on('autocomplete:closed', () => spacedUpdate.scheduleUpdate());
|
||||
|
||||
const spacedUpdate = new SpacedUpdate(async () => {
|
||||
await this.saveAction({
|
||||
relationName: $relationName.val(),
|
||||
targetNoteId: $targetNote.getSelectedNoteId()
|
||||
});
|
||||
}, 1000)
|
||||
|
||||
$relationName.on('input', () => spacedUpdate.scheduleUpdate());
|
||||
$targetNote.on('input', () => spacedUpdate.scheduleUpdate());
|
||||
|
||||
return $action;
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
import SpacedUpdate from "../../services/spaced_update.js";
|
||||
import AbstractBulkAction from "./abstract_bulk_action.js";
|
||||
import SpacedUpdate from "../../../services/spaced_update.js";
|
||||
import AbstractBulkAction from "../abstract_bulk_action.js";
|
||||
|
||||
const TPL = `
|
||||
<tr>
|
|
@ -1,5 +1,5 @@
|
|||
import SpacedUpdate from "../../services/spaced_update.js";
|
||||
import AbstractBulkAction from "./abstract_bulk_action.js";
|
||||
import SpacedUpdate from "../../../services/spaced_update.js";
|
||||
import AbstractBulkAction from "../abstract_bulk_action.js";
|
||||
|
||||
const TPL = `
|
||||
<tr>
|
|
@ -1,12 +1,12 @@
|
|||
import SpacedUpdate from "../../services/spaced_update.js";
|
||||
import AbstractBulkAction from "./abstract_bulk_action.js";
|
||||
import noteAutocompleteService from "../../services/note_autocomplete.js";
|
||||
import SpacedUpdate from "../../../services/spaced_update.js";
|
||||
import AbstractBulkAction from "../abstract_bulk_action.js";
|
||||
import noteAutocompleteService from "../../../services/note_autocomplete.js";
|
||||
|
||||
const TPL = `
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<div style="display: flex; align-items: center">
|
||||
<div style="margin-right: 10px;" class="text-nowrap">Set relation</div>
|
||||
<div style="margin-right: 10px;" class="text-nowrap">Update relation</div>
|
||||
|
||||
<input type="text"
|
||||
class="form-control relation-name"
|
||||
|
@ -39,9 +39,9 @@ const TPL = `
|
|||
</td>
|
||||
</tr>`;
|
||||
|
||||
export default class SetRelationTargetSearchAction extends AbstractBulkAction {
|
||||
static get actionName() { return "setRelationTarget"; }
|
||||
static get actionTitle() { return "Set relation target"; }
|
||||
export default class UpdateRelationTargetBulkAction extends AbstractBulkAction {
|
||||
static get actionName() { return "updateRelationTarget"; }
|
||||
static get actionTitle() { return "Update relation target"; }
|
||||
|
||||
doRender() {
|
||||
const $action = $(TPL);
|
|
@ -4,7 +4,7 @@ const build = require('./build');
|
|||
const packageJson = require('../../package');
|
||||
const {TRILIUM_DATA_DIR} = require('./data_dir');
|
||||
|
||||
const APP_DB_VERSION = 195;
|
||||
const APP_DB_VERSION = 196;
|
||||
const SYNC_VERSION = 25;
|
||||
const CLIPPER_PROTOCOL_VERSION = "1.0";
|
||||
|
||||
|
|
Loading…
Reference in a new issue