From de6080c3ade92c02a95e64bf5063adf23bc8c53a Mon Sep 17 00:00:00 2001 From: Joscha Date: Sat, 8 Feb 2025 22:47:30 +0100 Subject: [PATCH] Show other parents of a note --- gdn-app/src/components/CNavbar.vue | 2 +- gdn-app/src/components/CNote.vue | 18 +++++++++++++++++- gdn-app/src/stores/notes.ts | 21 +++++++++++++++++++-- 3 files changed, 37 insertions(+), 4 deletions(-) diff --git a/gdn-app/src/components/CNavbar.vue b/gdn-app/src/components/CNavbar.vue index ca2a528..0bb8cbc 100644 --- a/gdn-app/src/components/CNavbar.vue +++ b/gdn-app/src/components/CNavbar.vue @@ -26,7 +26,7 @@ function createSomeNotes() { const n1 = mkNote("n1"); const n2 = mkNote("n2", n2n1.id, n2n2.id, n2n3.id); - const n3 = mkNote("n3"); + const n3 = mkNote("n3", n2n1.id); const n4 = mkNote("n4"); const n5 = mkNote("n5", "NaN (not a note)"); diff --git a/gdn-app/src/components/CNote.vue b/gdn-app/src/components/CNote.vue index 0e0b582..e0a9918 100644 --- a/gdn-app/src/components/CNote.vue +++ b/gdn-app/src/components/CNote.vue @@ -6,6 +6,7 @@ import { RiAddLine, RiArrowDownSLine, RiArrowRightSLine, + RiCornerUpRightLine, RiEditLine, RiStickyNoteAddLine, } from "@remixicon/vue"; @@ -18,12 +19,19 @@ const ui = useUiStore(); const props = defineProps<{ noteId: string; + parentId?: string; path: string; // From root to here forceOpen?: boolean; }>(); const note = computed(() => notes.getNote(props.noteId)); +const parents = computed(() => { + let parents = notes.getParents(props.noteId); + if (props.parentId) parents = parents.difference(new Set([props.parentId])); + return [...parents].sort().map((id) => ({ id, text: notes.getNote(id)?.text })); +}); + // Our children and their locally unique keys. const children = computed(() => { if (!note.value) return []; @@ -117,6 +125,13 @@ function onCreateEditorFinish(text: string) {