added new runOnNoteDeletion, runOnBranchCreation, runOnBranchDeletion, #2898

This commit is contained in:
zadam
2022-06-05 14:58:19 +02:00
parent b5214e6cea
commit f587e0dfd9
6 changed files with 40 additions and 7 deletions

View File

@@ -49,6 +49,7 @@ eventService.subscribe([ eventService.ENTITY_CHANGED, eventService.ENTITY_DELETE
}
}
else if (entityName === 'notes') {
// ENTITY_DELETED won't trigger anything since all branches/attributes are already deleted at this point
runAttachedRelations(entity, 'runOnNoteChange', entity);
}
});
@@ -94,6 +95,9 @@ eventService.subscribe(eventService.ENTITY_CREATED, ({ entityName, entity }) =>
handleSortedAttribute(entity);
}
}
else if (entityName === 'branches') {
runAttachedRelations(entity.getNote(), 'runOnBranchCreation', entity);
}
else if (entityName === 'notes') {
runAttachedRelations(entity, 'runOnNoteCreation', entity);
}
@@ -167,4 +171,12 @@ eventService.subscribe(eventService.ENTITY_DELETED, ({ entityName, entity }) =>
}
}
});
if (entityName === 'branches') {
runAttachedRelations(entity.getNote(), 'runOnBranchDeletion', entity);
}
});
module.exports = {
runAttachedRelations
};