fixed runOnAttributeChange event

This commit is contained in:
azivner
2018-08-10 14:31:57 +02:00
parent 965dbcbc9a
commit 9e96272eb3
8 changed files with 21 additions and 18 deletions

View File

@@ -19,7 +19,8 @@ const BUILTIN_ATTRIBUTES = [
// relation names
{ type: 'relation', name: 'runOnNoteView' },
{ type: 'relation', name: 'runOnNoteTitleChange' }
{ type: 'relation', name: 'runOnNoteTitleChange' },
{ type: 'relation', name: 'runOnAttributeChange' }
];
async function getNotesWithLabel(name, value) {

View File

@@ -11,7 +11,7 @@ async function runAttachedRelations(note, relationName, originEntity) {
for (const relation of runRelations) {
const scriptNote = await relation.getTargetNote();
await scriptService.executeNote(scriptNote, scriptNote, originEntity);
await scriptService.executeNote(scriptNote, originEntity);
}
}

View File

@@ -273,8 +273,6 @@ eventService.subscribe(eventService.ENTITY_CHANGED, async ({entityName, entityId
const hideLabel = await repository.getEntity(`SELECT * FROM attributes WHERE isDeleted = 0 AND type = 'label'
AND name = 'archived' AND noteId = ?`, [attribute.noteId]);
console.log(hideLabel);
if (hideLabel) {
archived[attribute.noteId] = hideLabel.isInheritable ? 1 : 0;
}

View File

@@ -10,9 +10,9 @@ async function setEntityConstructor(constructor) {
}
async function getEntityFromName(entityName, entityId) {
const entityConstructor = entityConstructor.getEntityFromTableName(entityName);
const constructor = entityConstructor.getEntityFromTableName(entityName);
return await getEntity(`SELECT * FROM ${entityConstructor.tableName()} WHERE ${entityConstructor.primaryKeyName()} = ?`, [entityId]);
return await getEntity(`SELECT * FROM ${constructor.tableName} WHERE ${constructor.primaryKeyName} = ?`, [entityId]);
}
async function getEntities(query, params = []) {

View File

@@ -17,7 +17,7 @@ async function runNotesWithLabel(runAttrValue) {
AND notes.isDeleted = 0`, [runAttrValue]);
for (const note of notes) {
scriptService.executeNote(note);
scriptService.executeNote(note, note);
}
}