fix sharing of templates, #3562

This commit is contained in:
zadam 2023-02-01 22:58:40 +01:00
parent 5e0fbea3b3
commit 290f7e2101
2 changed files with 8 additions and 6 deletions

View File

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

View File

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