mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
template can now contain also content
This commit is contained in:
parent
16be0c1014
commit
30c56cd8af
@ -49,9 +49,9 @@ class CalendarWidget extends StandardWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
init($el, activeDate) {
|
init($el, activeDate) {
|
||||||
this.date = new Date();
|
|
||||||
this.todaysDate = new Date();
|
|
||||||
this.activeDate = new Date(Date.parse(activeDate));
|
this.activeDate = new Date(Date.parse(activeDate));
|
||||||
|
this.todaysDate = new Date();
|
||||||
|
this.date = new Date(this.activeDate.getTime());
|
||||||
|
|
||||||
this.$month = $el.find('[data-calendar-area="month"]');
|
this.$month = $el.find('[data-calendar-area="month"]');
|
||||||
this.$next = $el.find('[data-calendar-toggle="next"]');
|
this.$next = $el.find('[data-calendar-toggle="next"]');
|
||||||
|
@ -2,6 +2,7 @@ const eventService = require('./events');
|
|||||||
const scriptService = require('./script');
|
const scriptService = require('./script');
|
||||||
const treeService = require('./tree');
|
const treeService = require('./tree');
|
||||||
const log = require('./log');
|
const log = require('./log');
|
||||||
|
const repository = require('./repository');
|
||||||
const Attribute = require('../entities/attribute');
|
const Attribute = require('../entities/attribute');
|
||||||
|
|
||||||
async function runAttachedRelations(note, relationName, originEntity) {
|
async function runAttachedRelations(note, relationName, originEntity) {
|
||||||
@ -45,6 +46,28 @@ eventService.subscribe([ eventService.ENTITY_CHANGED, eventService.ENTITY_DELETE
|
|||||||
eventService.subscribe(eventService.ENTITY_CREATED, async ({ entityName, entity }) => {
|
eventService.subscribe(eventService.ENTITY_CREATED, async ({ entityName, entity }) => {
|
||||||
if (entityName === 'attributes') {
|
if (entityName === 'attributes') {
|
||||||
await runAttachedRelations(await entity.getNote(), 'runOnAttributeCreation', entity);
|
await runAttachedRelations(await entity.getNote(), 'runOnAttributeCreation', entity);
|
||||||
|
|
||||||
|
if (entity.type === 'relation' && entity.name === 'template') {
|
||||||
|
const note = await repository.getNote(entity.noteId);
|
||||||
|
|
||||||
|
if (!note.isStringNote()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const content = await note.getContent();
|
||||||
|
|
||||||
|
if (content && content.trim().length > 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const targetNote = await repository.getNote(entity.value);
|
||||||
|
|
||||||
|
if (!targetNote || !targetNote.isStringNote()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await note.setContent(await targetNote.getContent());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (entityName === 'notes') {
|
else if (entityName === 'notes') {
|
||||||
await runAttachedRelations(entity, 'runOnNoteCreation', entity);
|
await runAttachedRelations(entity, 'runOnNoteCreation', entity);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user