From 0b49ac4b48955ff9b7251bfc01053d29fef80ffa Mon Sep 17 00:00:00 2001 From: Aran Roig Date: Sat, 9 May 2026 20:40:27 +0200 Subject: [PATCH] kjdskjk --- .../components/partials/ContentSidebar.vue | 124 +++++++++--------- frontend/app/components/viewer/TopBar.vue | 30 ----- .../app/components/viewer/content/Note.vue | 12 +- .../viewer/content/NoteContainer.vue | 46 ++----- .../viewer/widgets/link/NoteLink.vue | 25 ++++ frontend/app/services/Content.js | 66 +++++++++- frontend/app/services/Marker.js | 10 +- frontend/app/services/StatusBar.js | 3 + 8 files changed, 175 insertions(+), 141 deletions(-) create mode 100644 frontend/app/components/viewer/widgets/link/NoteLink.vue create mode 100644 frontend/app/services/StatusBar.js diff --git a/frontend/app/components/partials/ContentSidebar.vue b/frontend/app/components/partials/ContentSidebar.vue index 30ca27c..649d4f4 100644 --- a/frontend/app/components/partials/ContentSidebar.vue +++ b/frontend/app/components/partials/ContentSidebar.vue @@ -2,63 +2,26 @@ import { computed, onMounted, onUnmounted, ref, watch } from 'vue'; import { useCampaignService } from '~/services/Campaign.js'; +import { FetchCampaignNotes, PushNote, TotalNotes } from '~/services/Content'; import { emitter } from '~/services/Emitter'; import Server from '~/services/Server'; const { Campaign } = useCampaignService(); -const notes = ref([]); const loadingNotes = ref(false); const notesError = ref(''); const sidebarCollapsed = ref(false); +const selectedTool = ref(''); + const campaignId = computed(() => { return Campaign.value?._id ?? Campaign.value?.id ?? null; }); const notesMeta = computed(() => { - const count = notes.value.length; + const count = TotalNotes.value.length; return `${count} ${count === 1 ? 'note' : 'notes'}`; }); -async function fetchCampaignNotes() { - if (!campaignId.value) { - notes.value = []; - notesError.value = ''; - return; - } - - loadingNotes.value = true; - notesError.value = ''; - - try { - const response = await Server().get('/note/list', { - params: { - campaign: campaignId.value - } - }); - - if (response.data.status !== 'ok') { - notes.value = []; - notesError.value = response.data.msg ?? 'Unable to load notes.'; - return; - } - - notes.value = response.data.notes.map((note) => { - return { - key: note._id, - title: note.title, - text: note.content ?? '', - date: note.date - }; - }); - } catch (error) { - notes.value = []; - notesError.value = 'Unable to load notes.'; - } finally { - loadingNotes.value = false; - } -} - function toggleSidebar() { sidebarCollapsed.value = !sidebarCollapsed.value; } @@ -89,7 +52,7 @@ async function createNote() { function openNote(note) { - emitter.emit('push-note', note); + PushNote(note); } function handleNoteCreated(note) { @@ -109,14 +72,16 @@ function handleNoteCreated(note) { date: note.date }; - notes.value = notes.value.filter((currentNote) => { + TotalNotes.value = TotalNotes.value.filter((currentNote) => { return currentNote.key !== createdNote.key; }); - notes.value.unshift(createdNote); + TotalNotes.value.unshift(createdNote); openNote(createdNote); } onMounted(() => { + selectedTool.value = 'notes'; + FetchCampaignNotes(); emitter.on('note-created', handleNoteCreated); }); @@ -125,13 +90,13 @@ onUnmounted(() => { }); watch(Campaign, () => { - fetchCampaignNotes(); + FetchCampaignNotes(); }, { immediate: true });