mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
added runOnBranchChange event #4108
This commit is contained in:
parent
0efc42081d
commit
45ed436426
@ -20,7 +20,7 @@ UPDATE attributes SET name = 'name', value = 'value' WHERE type = 'label'
|
|||||||
'shareRaw', 'shareDisallowRobotIndexing', 'shareIndex', 'displayRelations', 'hideRelations', 'titleTemplate',
|
'shareRaw', 'shareDisallowRobotIndexing', 'shareIndex', 'displayRelations', 'hideRelations', 'titleTemplate',
|
||||||
'template', 'toc', 'color', 'keepCurrentHoisting', 'executeButton', 'executeDescription', 'newNotesOnTop',
|
'template', 'toc', 'color', 'keepCurrentHoisting', 'executeButton', 'executeDescription', 'newNotesOnTop',
|
||||||
'clipperInbox', 'internalLink', 'imageLink', 'relationMapLink', 'includeMapLink', 'runOnNoteCreation',
|
'clipperInbox', 'internalLink', 'imageLink', 'relationMapLink', 'includeMapLink', 'runOnNoteCreation',
|
||||||
'runOnNoteTitleChange', 'runOnNoteChange', 'runOnNoteContentChange', 'runOnNoteDeletion', 'runOnBranchCreation',
|
'runOnNoteTitleChange', 'runOnNoteChange', 'runOnNoteContentChange', 'runOnNoteDeletion', 'runOnBranchCreation', 'runOnBranchChange',
|
||||||
'runOnBranchDeletion', 'runOnChildNoteCreation', 'runOnAttributeCreation', 'runOnAttributeChange', 'template',
|
'runOnBranchDeletion', 'runOnChildNoteCreation', 'runOnAttributeCreation', 'runOnAttributeChange', 'template',
|
||||||
'inherit', 'widget', 'renderNote', 'shareCss', 'shareJs', 'shareTemplate', 'shareFavicon');
|
'inherit', 'widget', 'renderNote', 'shareCss', 'shareJs', 'shareTemplate', 'shareFavicon');
|
||||||
UPDATE attributes SET name = 'name' WHERE type = 'relation'
|
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',
|
'shareRaw', 'shareDisallowRobotIndexing', 'shareIndex', 'displayRelations', 'hideRelations', 'titleTemplate',
|
||||||
'template', 'toc', 'color', 'keepCurrentHoisting', 'executeButton', 'executeDescription', 'newNotesOnTop',
|
'template', 'toc', 'color', 'keepCurrentHoisting', 'executeButton', 'executeDescription', 'newNotesOnTop',
|
||||||
'clipperInbox', 'internalLink', 'imageLink', 'relationMapLink', 'includeMapLink', 'runOnNoteCreation',
|
'clipperInbox', 'internalLink', 'imageLink', 'relationMapLink', 'includeMapLink', 'runOnNoteCreation',
|
||||||
'runOnNoteTitleChange', 'runOnNoteChange', 'runOnNoteContentChange', 'runOnNoteDeletion', 'runOnBranchCreation',
|
'runOnNoteTitleChange', 'runOnNoteChange', 'runOnNoteContentChange', 'runOnNoteDeletion', 'runOnBranchCreation', 'runOnBranchChange',
|
||||||
'runOnBranchDeletion', 'runOnChildNoteCreation', 'runOnAttributeCreation', 'runOnAttributeChange', 'template',
|
'runOnBranchDeletion', 'runOnChildNoteCreation', 'runOnAttributeCreation', 'runOnAttributeChange', 'template',
|
||||||
'inherit', 'widget', 'renderNote', 'shareCss', 'shareJs', 'shareTemplate', 'shareFavicon');
|
'inherit', 'widget', 'renderNote', 'shareCss', 'shareJs', 'shareTemplate', 'shareFavicon');
|
||||||
UPDATE branches SET prefix = 'prefix' WHERE prefix IS NOT NULL AND prefix != 'recovered';
|
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",
|
"runOnNoteChange": "executes when note is changed (includes note creation as well). Does not include content changes",
|
||||||
"runOnNoteDeletion": "executes when note is being deleted",
|
"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.",
|
"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).",
|
"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",
|
"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",
|
"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 branchService = require("../../services/branches");
|
||||||
const log = require("../../services/log");
|
const log = require("../../services/log");
|
||||||
const ValidationError = require("../../errors/validation_error");
|
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
|
* 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) {
|
if (branch) {
|
||||||
branch.isExpanded = !!expanded;
|
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: 'runOnNoteContentChange', isDangerous: true },
|
||||||
{ type: 'relation', name: 'runOnNoteDeletion', isDangerous: true },
|
{ type: 'relation', name: 'runOnNoteDeletion', isDangerous: true },
|
||||||
{ type: 'relation', name: 'runOnBranchCreation', isDangerous: true },
|
{ type: 'relation', name: 'runOnBranchCreation', isDangerous: true },
|
||||||
|
{ type: 'relation', name: 'runOnBranchChange', isDangerous: true },
|
||||||
{ type: 'relation', name: 'runOnBranchDeletion', isDangerous: true },
|
{ type: 'relation', name: 'runOnBranchDeletion', isDangerous: true },
|
||||||
{ type: 'relation', name: 'runOnChildNoteCreation', isDangerous: true },
|
{ type: 'relation', name: 'runOnChildNoteCreation', isDangerous: true },
|
||||||
{ type: 'relation', name: 'runOnAttributeCreation', isDangerous: true },
|
{ type: 'relation', name: 'runOnAttributeCreation', isDangerous: true },
|
||||||
|
@ -65,6 +65,12 @@ eventService.subscribe(eventService.ENTITY_CHANGED, ({entityName, entity}) => {
|
|||||||
if (parentNote?.hasLabel("sorted")) {
|
if (parentNote?.hasLabel("sorted")) {
|
||||||
treeService.sortNotesIfNeeded(parentNote.noteId);
|
treeService.sortNotesIfNeeded(parentNote.noteId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const childNote = becca.getNote(entity.noteId);
|
||||||
|
|
||||||
|
if (childNote) {
|
||||||
|
runAttachedRelations(childNote, 'runOnBranchChange', entity);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user