From 290f7e21011776a809eccd3d07c203479f594007 Mon Sep 17 00:00:00 2001 From: zadam Date: Wed, 1 Feb 2023 22:58:40 +0100 Subject: [PATCH] fix sharing of templates, #3562 --- src/public/app/entities/note_short.js | 12 +++++++----- src/public/app/services/attributes.js | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/public/app/entities/note_short.js b/src/public/app/entities/note_short.js index dabdf396c..d817b321a 100644 --- a/src/public/app/entities/note_short.js +++ b/src/public/app/entities/note_short.js @@ -688,7 +688,7 @@ class NoteShort { return promotedAttrs; } - hasAncestor(ancestorNoteId, visitedNoteIds = null) { + hasAncestor(ancestorNoteId, followTemplates = false, visitedNoteIds = null) { if (this.noteId === ancestorNoteId) { return true; } @@ -702,14 +702,16 @@ class NoteShort { visitedNoteIds.add(this.noteId); - for (const templateNote of this.getTemplateNotes()) { - if (templateNote.hasAncestor(ancestorNoteId, visitedNoteIds)) { - return true; + if (followTemplates) { + for (const templateNote of this.getTemplateNotes()) { + 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; } } diff --git a/src/public/app/services/attributes.js b/src/public/app/services/attributes.js index 7c3f4df0c..78ac57a5a 100644 --- a/src/public/app/services/attributes.js +++ b/src/public/app/services/attributes.js @@ -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; } }