mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-14 19:41:09 +02:00
feat(context): add inline document creation to workbench ListView
Adds a "Neues Dokument" button and an "Alle Dokumente" link in the toolbar. Document rows are now clickable <a> tags linking to the detail page instead of static divs. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
26914b14c8
commit
f1a7f35d66
1 changed files with 42 additions and 3 deletions
|
|
@ -3,12 +3,31 @@
|
|||
Spaces and recent documents.
|
||||
-->
|
||||
<script lang="ts">
|
||||
import { goto } from '$app/navigation';
|
||||
import { useLiveQueryWithDefault } from '@mana/local-store/svelte';
|
||||
import { db } from '$lib/data/database';
|
||||
import { decryptRecords } from '$lib/data/crypto';
|
||||
import { decryptRecords, encryptRecord } from '$lib/data/crypto';
|
||||
import { BaseListView } from '@mana/shared-ui';
|
||||
import { documentTable } from './collections';
|
||||
import type { LocalContextSpace, LocalDocument } from './types';
|
||||
|
||||
async function handleCreateDocument() {
|
||||
const id = crypto.randomUUID();
|
||||
const row: LocalDocument = {
|
||||
id,
|
||||
spaceId: null,
|
||||
title: 'Neues Dokument',
|
||||
content: '# Neues Dokument\n\n',
|
||||
type: 'text',
|
||||
shortId: null,
|
||||
pinned: false,
|
||||
metadata: null,
|
||||
};
|
||||
await encryptRecord('documents', row);
|
||||
await documentTable.add(row);
|
||||
goto(`/context/documents/${id}`);
|
||||
}
|
||||
|
||||
const spacesQuery = useLiveQueryWithDefault(async () => {
|
||||
const all = await db.table<LocalContextSpace>('contextSpaces').toArray();
|
||||
return all.filter((s) => !s.deletedAt);
|
||||
|
|
@ -37,6 +56,25 @@
|
|||
</script>
|
||||
|
||||
<BaseListView items={recentDocs} getKey={(d) => d.id} emptyTitle="Keine Dokumente">
|
||||
{#snippet toolbar()}
|
||||
<div class="flex items-center justify-between gap-2">
|
||||
<a
|
||||
href="/context/documents"
|
||||
class="text-xs text-white/50 transition-colors hover:text-white/80"
|
||||
>
|
||||
Alle Dokumente →
|
||||
</a>
|
||||
<button
|
||||
type="button"
|
||||
onclick={handleCreateDocument}
|
||||
class="flex items-center gap-1.5 rounded-md bg-indigo-600 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-indigo-700"
|
||||
>
|
||||
<span aria-hidden="true">+</span>
|
||||
Neues Dokument
|
||||
</button>
|
||||
</div>
|
||||
{/snippet}
|
||||
|
||||
{#snippet header()}
|
||||
<span>{spaces.length} Spaces</span>
|
||||
<span>{documents.length} Dokumente</span>
|
||||
|
|
@ -58,7 +96,8 @@
|
|||
{/snippet}
|
||||
|
||||
{#snippet item(doc)}
|
||||
<div
|
||||
<a
|
||||
href="/context/documents/{doc.id}"
|
||||
class="flex min-h-[44px] items-center gap-2 rounded-md px-2 py-1.5 transition-colors hover:bg-white/5"
|
||||
>
|
||||
<span class="text-sm">{@html typeIcons[doc.type] ?? '📄'}</span>
|
||||
|
|
@ -68,6 +107,6 @@
|
|||
{#if doc.pinned}
|
||||
<span class="text-xs text-white/30">📌</span>
|
||||
{/if}
|
||||
</div>
|
||||
</a>
|
||||
{/snippet}
|
||||
</BaseListView>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue