π 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
Add group by workspace for items
Smaug6739351bb83fa58e
diff --git a/frontend/app/composables/TreeStructure.ts b/frontend/app/composables/TreeStructure.tsindex b324090f..e4630909 100644--- a/frontend/app/composables/TreeStructure.ts+++ b/frontend/app/composables/TreeStructure.ts@@ -41,7 +41,9 @@ export class TreeStructure {}public generateTree(): Item[] {- return this.items.filter(item => item.parent_id === '' || !this.itemMap.has(item.parent_id || '') || (item.data.type === 'category' && item.data.role === 2)).map(root => this.buildTree(root, new Set()));+ return this.items+ .filter(item => item.parent_id === '' || !this.itemMap.has(item.parent_id || '') || (item.data.type === 'category' && item.data.role === 2))+ .map(root => this.buildTree(root, new Set()));}public getSubTreeById(id: string): Item | undefined {const root = this.getItem(id);@@ -67,11 +69,11 @@ export class TreeStructure {if (visited.has(item.id)) {return { ...item, childrens: [] };}-+visited.add(item.id);const children = this.childrenMap.get(item.id) || [];const newVisited = new Set(visited);-+return {...item,childrens: children.map(child => this.buildTree(child, newVisited)),diff --git a/frontend/app/composables/useSidebarTree.ts b/frontend/app/composables/useSidebarTree.tsindex 55d9c9a4..e1bb26b2 100644--- a/frontend/app/composables/useSidebarTree.ts+++ b/frontend/app/composables/useSidebarTree.ts@@ -1,4 +1,5 @@// useSidebarTree.ts+import type { DefaultItem } from '~/components/Sidebar/helpers';import type { Category, Document, Ressource } from '~/stores';export function useSidebarTree() {@@ -84,10 +85,38 @@ export function useSidebarTree() {return structure.value.treeToArray(structure.value.getSubTreeById(id)?.childrens || []);};+ const groupedByWorkspace = () => {+ const workspaces: Item<Category | Document | Ressource | DefaultItem>[] = [+ ...categoriesStore.getAll+ .filter(c => c.role === 2)+ .map(c => ({+ id: c.id,+ parent_id: c.parent_id || '',+ label: c.name,+ route: `/dashboard/categories/${c.id}`,+ icon: c.icon || 'folder',+ data: c,+ show: ref(getCollapseState(c.id)),+ })),+ ];++ tree.value.forEach(item => {+ const workspaceId = item.parent_id;+ const existing = workspaces.find(w => w.id === workspaceId);+ if (!existing) workspaces.push(item);+ else {+ if (existing.childrens) existing.childrens.push(item);+ else existing.childrens = [item];+ }+ });+ return workspaces;+ };+return {structure,collapseAll,getSubTreeById,+ groupedByWorkspace,categories,tree,filtered,