added "inherit" relation, #3493

This commit is contained in:
zadam
2023-01-06 20:31:55 +01:00
parent a863da1dce
commit 8a641e1b4f
21 changed files with 49 additions and 41 deletions

View File

@@ -259,7 +259,7 @@ class FNote {
}
}
for (const templateAttr of attrArrs.flat().filter(attr => attr.type === 'relation' && attr.name === 'template')) {
for (const templateAttr of attrArrs.flat().filter(attr => attr.type === 'relation' && ['template', 'inherit'].includes(attr.name))) {
const templateNote = this.froca.notes[templateAttr.value];
if (templateNote && templateNote.noteId !== this.noteId) {
@@ -651,8 +651,11 @@ class FNote {
/**
* @returns {FNote[]}
*/
getTemplateNotes() {
const relations = this.getRelations('template');
getNotesToInheritAttributesFrom() {
const relations = [
...this.getRelations('template'),
...this.getRelations('inherit')
];
return relations.map(rel => this.froca.notes[rel.value]);
}
@@ -690,7 +693,7 @@ class FNote {
visitedNoteIds.add(this.noteId);
for (const templateNote of this.getTemplateNotes()) {
for (const templateNote of this.getNotesToInheritAttributesFrom()) {
if (templateNote.hasAncestor(ancestorNoteId, visitedNoteIds)) {
return true;
}