fix sharing of templates, #3562

This commit is contained in:
zadam 2023-02-01 22:55:31 +01:00
parent 88e09eb279
commit 460b5fb3a4
2 changed files with 8 additions and 6 deletions

View File

@ -707,7 +707,7 @@ class FNote {
return promotedAttrs;
}
hasAncestor(ancestorNoteId, visitedNoteIds = null) {
hasAncestor(ancestorNoteId, followTemplates = false, visitedNoteIds = null) {
if (this.noteId === ancestorNoteId) {
return true;
}
@ -721,14 +721,16 @@ class FNote {
visitedNoteIds.add(this.noteId);
for (const templateNote of this.getNotesToInheritAttributesFrom()) {
if (templateNote.hasAncestor(ancestorNoteId, visitedNoteIds)) {
return true;
if (followTemplates) {
for (const templateNote of this.getNotesToInheritAttributesFrom()) {
if (templateNote.hasAncestor(ancestorNoteId, followTemplates, visitedNoteIds)) {
return true;
}
}
}
for (const parentNote of this.getParentNotes()) {
if (parentNote.hasAncestor(ancestorNoteId, visitedNoteIds)) {
if (parentNote.hasAncestor(ancestorNoteId, followTemplates, visitedNoteIds)) {
return true;
}
}

View File

@ -50,7 +50,7 @@ function isAffecting(attrRow, affectedNote) {
if (this.isInheritable) {
for (const owningNote of owningNotes) {
if (owningNote.hasAncestor(attrNote.noteId)) {
if (owningNote.hasAncestor(attrNote.noteId, true)) {
return true;
}
}