mirror of
https://github.com/zadam/trilium.git
synced 2024-11-10 09:02:48 +08:00
added runOnBranchChange event #4108
This commit is contained in:
parent
0efc42081d
commit
45ed436426
5 changed files with 16 additions and 2 deletions
|
@ -20,7 +20,7 @@ UPDATE attributes SET name = 'name', value = 'value' WHERE type = 'label'
|
|||
'shareRaw', 'shareDisallowRobotIndexing', 'shareIndex', 'displayRelations', 'hideRelations', 'titleTemplate',
|
||||
'template', 'toc', 'color', 'keepCurrentHoisting', 'executeButton', 'executeDescription', 'newNotesOnTop',
|
||||
'clipperInbox', 'internalLink', 'imageLink', 'relationMapLink', 'includeMapLink', 'runOnNoteCreation',
|
||||
'runOnNoteTitleChange', 'runOnNoteChange', 'runOnNoteContentChange', 'runOnNoteDeletion', 'runOnBranchCreation',
|
||||
'runOnNoteTitleChange', 'runOnNoteChange', 'runOnNoteContentChange', 'runOnNoteDeletion', 'runOnBranchCreation', 'runOnBranchChange',
|
||||
'runOnBranchDeletion', 'runOnChildNoteCreation', 'runOnAttributeCreation', 'runOnAttributeChange', 'template',
|
||||
'inherit', 'widget', 'renderNote', 'shareCss', 'shareJs', 'shareTemplate', 'shareFavicon');
|
||||
UPDATE attributes SET name = 'name' WHERE type = 'relation'
|
||||
|
@ -37,7 +37,7 @@ UPDATE attributes SET name = 'name' WHERE type = 'relation'
|
|||
'shareRaw', 'shareDisallowRobotIndexing', 'shareIndex', 'displayRelations', 'hideRelations', 'titleTemplate',
|
||||
'template', 'toc', 'color', 'keepCurrentHoisting', 'executeButton', 'executeDescription', 'newNotesOnTop',
|
||||
'clipperInbox', 'internalLink', 'imageLink', 'relationMapLink', 'includeMapLink', 'runOnNoteCreation',
|
||||
'runOnNoteTitleChange', 'runOnNoteChange', 'runOnNoteContentChange', 'runOnNoteDeletion', 'runOnBranchCreation',
|
||||
'runOnNoteTitleChange', 'runOnNoteChange', 'runOnNoteContentChange', 'runOnNoteDeletion', 'runOnBranchCreation', 'runOnBranchChange',
|
||||
'runOnBranchDeletion', 'runOnChildNoteCreation', 'runOnAttributeCreation', 'runOnAttributeChange', 'template',
|
||||
'inherit', 'widget', 'renderNote', 'shareCss', 'shareJs', 'shareTemplate', 'shareFavicon');
|
||||
UPDATE branches SET prefix = 'prefix' WHERE prefix IS NOT NULL AND prefix != 'recovered';
|
||||
|
|
|
@ -263,6 +263,7 @@ const ATTR_HELP = {
|
|||
"runOnNoteChange": "executes when note is changed (includes note creation as well). Does not include content changes",
|
||||
"runOnNoteDeletion": "executes when note is being deleted",
|
||||
"runOnBranchCreation": "executes when a branch is created. Branch is a link between parent note and child note and is created e.g. when cloning or moving note.",
|
||||
"runOnBranchChange": "executes when a branch is updated.",
|
||||
"runOnBranchDeletion": "executes when a branch is deleted. Branch is a link between parent note and child note and is deleted e.g. when moving note (old branch/link is deleted).",
|
||||
"runOnAttributeCreation": "executes when new attribute is created for the note which defines this relation",
|
||||
"runOnAttributeChange": " executes when the attribute is changed of a note which defines this relation. This is triggered also when the attribute is deleted",
|
||||
|
|
|
@ -10,6 +10,7 @@ const TaskContext = require('../../services/task_context');
|
|||
const branchService = require("../../services/branches");
|
||||
const log = require("../../services/log");
|
||||
const ValidationError = require("../../errors/validation_error");
|
||||
const eventService = require("../../services/events.js");
|
||||
|
||||
/**
|
||||
* Code in this file deals with moving and cloning branches. The relationship between note and parent note is unique
|
||||
|
@ -144,6 +145,11 @@ function setExpanded(req) {
|
|||
if (branch) {
|
||||
branch.isExpanded = !!expanded;
|
||||
}
|
||||
|
||||
eventService.emit(eventService.ENTITY_CHANGED, {
|
||||
entityName: 'branches',
|
||||
entity: branch
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -81,6 +81,7 @@ module.exports = [
|
|||
{ type: 'relation', name: 'runOnNoteContentChange', isDangerous: true },
|
||||
{ type: 'relation', name: 'runOnNoteDeletion', isDangerous: true },
|
||||
{ type: 'relation', name: 'runOnBranchCreation', isDangerous: true },
|
||||
{ type: 'relation', name: 'runOnBranchChange', isDangerous: true },
|
||||
{ type: 'relation', name: 'runOnBranchDeletion', isDangerous: true },
|
||||
{ type: 'relation', name: 'runOnChildNoteCreation', isDangerous: true },
|
||||
{ type: 'relation', name: 'runOnAttributeCreation', isDangerous: true },
|
||||
|
|
|
@ -65,6 +65,12 @@ eventService.subscribe(eventService.ENTITY_CHANGED, ({entityName, entity}) => {
|
|||
if (parentNote?.hasLabel("sorted")) {
|
||||
treeService.sortNotesIfNeeded(parentNote.noteId);
|
||||
}
|
||||
|
||||
const childNote = becca.getNote(entity.noteId);
|
||||
|
||||
if (childNote) {
|
||||
runAttachedRelations(childNote, 'runOnBranchChange', entity);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue