📚 The open-source, offline-first Notion, Obsidian & Confluence alternative. Advanced Markdown, multi-tenant teams, OIDC/SSO, and local S3 backups. Deploy in one command.
Vue dockergolangkanbanknowledge-baseknowledge-managementmarkdownnote-takingnotesnotes-appnotionnuxtnuxtjsoffline-firstoidcpwaselfhostedssovuevuejswiki
fixes
Smaug673931d54deaef94
diff --git a/dashboard/components/sidebar/Sidebar.vue b/dashboard/components/sidebar/Sidebar.vueindex bc63b226..aa40c9e2 100644--- a/dashboard/components/sidebar/Sidebar.vue+++ b/dashboard/components/sidebar/Sidebar.vue@@ -3,10 +3,9 @@<div class="sidebar-content"><section class="header"><IconApp />- <p style="font-size: 19px;font-weight: 600;">Dashboard</p>+ <NuxtLink style="font-size: 19px;font-weight: 600;" to="/">Dashboard</NuxtLink><IconClose class="btn" /></section>- <SidebarDropdown :categories="categoriesStore.getParents" v-model="category_dropdown_filter" /><CollapseItem v-for="(item, index) in items " :key="index" :item="item" :root="true" /></div></Resizable>@@ -22,7 +21,6 @@ import { ItemsManager, type Item } from './tree_builder';import { navigationItems } from "./helpers";const { isOpened, hasSidebar } = useSidebar();-const category_dropdown_filter = ref('');const categoriesStore = useCategoriesStore();const documentsStore = useDocumentsStore();@@ -46,33 +44,32 @@ const items = computed((): Item[] => {data: document}))- const itemsManager = new ItemsManager([...navigation, ...documents, ...categories]);- const tree = itemsManager.generateTree()- return tree;+ return new ItemsManager([...navigation, ...documents, ...categories]).generateTree()});const handleClickOutside = (e: MouseEvent) => {- if (isOpened.value && e.target && (!(e.target as Element).closest('.sidebar') && !(e.target as Element).closest('.open-sidebar')) && isMobile()) isOpened.value = false;+ if (isOpened.value && e.target && (!(e.target as Element).closest('.sidebar') && !(e.target as Element).closest('.open-sidebar'))) isOpened.value = false;};onMounted(() => {hasSidebar.value = true;- if (!process.client) return;- isMobile() ? isOpened.value = false : isOpened.value = true;- window.addEventListener('click', handleClickOutside);+ if (isMobile()) return window.addEventListener('click', handleClickOutside);+ isOpened.value = true;});onBeforeUnmount(() => {hasSidebar.value = false;- if (!process.client) return;window.removeEventListener('click', handleClickOutside);});// Watch isOpened-watch(isOpened, (val) => {- if (process.client && val && isMobile()) document.getElementById('backdrop')?.classList.add('backdrop');- if (process.client && !val && isMobile()) document.getElementById('backdrop')?.classList.remove('backdrop');-});+if (isMobile()) {+ watch(isOpened, (val) => {+ if (val) document.getElementById('backdrop')?.classList.add('backdrop');+ else document.getElementById('backdrop')?.classList.remove('backdrop');+ });+}+</script><style scoped lang="scss">diff --git a/dashboard/components/sidebar/SidebarDropdown.vue b/dashboard/components/sidebar/SidebarDropdown.vuedeleted file mode 100644index 232195ab..00000000--- a/dashboard/components/sidebar/SidebarDropdown.vue+++ /dev/null@@ -1,33 +0,0 @@-<template>- <div class="container">- <select name="category-filter" @change="v => selected = (v.target as HTMLSelectElement)?.value">- <option value="">All</option>- <option v-for="category in categories" :key="category.id" :value="category.id">- {{ category.name }}- </option>- </select>- </div>-</template>--<script setup lang="ts">-import type { Category } from '~/store';--defineProps<{ categories: Category[] }>();-const selected = defineModel();-</script>--<style scoped lang="scss">-.container {- padding: 5px 10px 0 0;-}--select {- border-radius: 5px;- padding: 5px 0;- border: 1px solid var(--border-color);- background: var(--bg-contrast-2);- color: var(--font-color);- cursor: pointer;- outline: none;-}-</style>diff --git a/dashboard/components/sidebar/SidebarItem.vue b/dashboard/components/sidebar/SidebarItem.vueindex 22c6cc45..becf2726 100644--- a/dashboard/components/sidebar/SidebarItem.vue+++ b/dashboard/components/sidebar/SidebarItem.vue@@ -72,7 +72,7 @@ const drop = async (event: DragEvent) => {);}if (draggedItem.type === "document" && props.item.data.type === "document") { // Move document to document- if (draggedItem.id === props.item.parent_id) return; // Prevent moving parent to child+ if (documentStore.getAllChildrensIds(draggedItem.id).includes(props.item.parent_id)) return; // Prevent moving parent to childif (draggedItem.id === props.item.id) return; // Prevent moving to the same documentdocumentStore.update({ ...draggedItem, parent_id: props.item.id }diff --git a/dashboard/components/sidebar/tree_builder.ts b/dashboard/components/sidebar/tree_builder.tsindex f6ef3ca1..f97a0f0d 100644--- a/dashboard/components/sidebar/tree_builder.ts+++ b/dashboard/components/sidebar/tree_builder.ts@@ -11,10 +11,22 @@ export interface Item {}export class ItemsManager {- constructor(public readonly items: Item[]) {}+ private itemMap: Record<string, Item>; // Utilisation d'un objet pour stocker les éléments par ID++ constructor(public readonly items: Item[]) {+ this.itemMap = this.createItemMap(items);+ }++ private createItemMap(items: Item[]): Record<string, Item> {+ const itemMap: Record<string, Item> = {};+ items.forEach(item => {+ itemMap[item.id] = item;+ });+ return itemMap;+ }public getItem(id: string): Item | undefined {- return this.items.find(item => item.id === id);+ return this.itemMap[id];}public generateTree(): Item[] {@@ -28,9 +40,13 @@ export class ItemsManager {}private getChildrens(parent: Item): Item[] {- const childrens = this.items.filter(item => item.parent_id === parent.id);- childrens.forEach(child => {- child.childrens = this.getChildrens(child);+ const childrens: Item[] = [];+ this.items.forEach(item => {+ if (item.parent_id === parent.id) {+ const child = { ...item };+ child.childrens = this.getChildrens(item); // Utilisation de la récursivité+ childrens.push(child);+ }});return childrens;}diff --git a/dashboard/composables/Sidebar.ts b/dashboard/composables/Sidebar.tsindex 1059d39d..92c835d7 100644--- a/dashboard/composables/Sidebar.ts+++ b/dashboard/composables/Sidebar.ts@@ -1,14 +1,10 @@-import { ref } from 'vue';-const isOpened = ref(false);const hasSidebar = ref(false);const paneWidth = ref(360); // initial width of pane 1const isResizing = ref(false);export function useSidebar() {- const toggleSidebar = () => {- isOpened.value = !isOpened.value;- };+ const toggleSidebar = () => (isOpened.value = !isOpened.value);return {toggleSidebar,diff --git a/dashboard/store/documents.store.ts b/dashboard/store/documents.store.tsindex ff6144a7..7321f7f6 100644--- a/dashboard/store/documents.store.ts+++ b/dashboard/store/documents.store.ts@@ -25,6 +25,20 @@ export const useDocumentsStore = defineStore('documents', {if (index == -1) return;return cdocs[index - 1];},+ getAllChildrensIds: state => (id: string) => {+ const childrens: string[] = [id];+ const getChildrens = (parent: Document) => {+ state.documents.forEach(doc => {+ if (doc.parent_id == parent.id) {+ childrens.push(doc.id);+ getChildrens(doc);+ }+ });+ };+ const parent = state.documents.find(d => d.id == id);+ if (parent) getChildrens(parent);+ return childrens;+ },},actions: {fetch: async function <T extends FetchOptions<Array<keyof Document>>>(opts?: T): Promise<'id' extends keyof T ? Document : Document[]> {