fix journal & persons
This commit is contained in:
parent
66be6a09ea
commit
512c17a78c
|
|
@ -1,14 +1,18 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { liveQuery } from 'dexie';
|
import { liveQuery } from 'dexie';
|
||||||
import { db } from '$lib/db/schema';
|
import { db } from '$lib/db/schema';
|
||||||
import { extractAssignments } from '$lib/utils/extractors';
|
import { extractAssignments, extractMentions } from '$lib/utils/extractors';
|
||||||
|
import { today } from '$lib/db/helpers';
|
||||||
import RenderedMarkdown from './RenderedMarkdown.svelte';
|
import RenderedMarkdown from './RenderedMarkdown.svelte';
|
||||||
|
import DateNavigator from './DateNavigator.svelte';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
contextId: string;
|
contextId: string;
|
||||||
}
|
}
|
||||||
let { contextId }: Props = $props();
|
let { contextId }: Props = $props();
|
||||||
|
|
||||||
|
let selectedDate = $state(today());
|
||||||
|
|
||||||
const personData = liveQuery(async () => {
|
const personData = liveQuery(async () => {
|
||||||
const topics = await db.topics
|
const topics = await db.topics
|
||||||
.where('contextId').equals(contextId)
|
.where('contextId').equals(contextId)
|
||||||
|
|
@ -22,8 +26,8 @@
|
||||||
const byPerson = new Map<string, { title: string; date: string; text: string }[]>();
|
const byPerson = new Map<string, { title: string; date: string; text: string }[]>();
|
||||||
for (const h of history) {
|
for (const h of history) {
|
||||||
const topic = topics.find(t => t.id === h.topicId);
|
const topic = topics.find(t => t.id === h.topicId);
|
||||||
const assignments = extractAssignments(h.text);
|
const names = new Set([...extractAssignments(h.text), ...extractMentions(h.text)]);
|
||||||
for (const name of assignments) {
|
for (const name of names) {
|
||||||
const list = byPerson.get(name) ?? [];
|
const list = byPerson.get(name) ?? [];
|
||||||
list.push({ title: topic?.title ?? '', date: h.date, text: h.text });
|
list.push({ title: topic?.title ?? '', date: h.date, text: h.text });
|
||||||
byPerson.set(name, list);
|
byPerson.set(name, list);
|
||||||
|
|
@ -31,18 +35,26 @@
|
||||||
}
|
}
|
||||||
return [...byPerson.entries()].sort((a, b) => a[0].localeCompare(b[0]));
|
return [...byPerson.entries()].sort((a, b) => a[0].localeCompare(b[0]));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const filteredData = $derived(
|
||||||
|
($personData ?? [])
|
||||||
|
.map(([person, tasks]) => [person, tasks.filter(t => t.date === selectedDate)] as const)
|
||||||
|
.filter(([, tasks]) => tasks.length > 0)
|
||||||
|
);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#each $personData ?? [] as [person, tasks]}
|
<DateNavigator {selectedDate} onchange={(d) => selectedDate = d} />
|
||||||
|
|
||||||
|
{#each filteredData as [person, tasks]}
|
||||||
<div class="mb-5 rounded-lg border-l-[5px] border-l-info bg-card-bg p-4">
|
<div class="mb-5 rounded-lg border-l-[5px] border-l-info bg-card-bg p-4">
|
||||||
<div class="mb-2.5 border-b border-[#444] pb-1 text-xl font-bold text-info">{person}</div>
|
<div class="mb-2.5 border-b border-[#444] pb-1 text-xl font-bold text-info">{person}</div>
|
||||||
{#each tasks as task}
|
{#each tasks as task}
|
||||||
<div class="mb-2.5 border-l-2 border-[#444] pl-2.5">
|
<div class="mb-2.5 border-l-2 border-[#444] pl-2.5">
|
||||||
<div class="mb-0.5 text-xs text-[#aaa]">{task.date} - {task.title}</div>
|
<div class="mb-0.5 text-xs text-[#aaa]">{task.title}</div>
|
||||||
<RenderedMarkdown text={task.text} />
|
<RenderedMarkdown text={task.text} />
|
||||||
</div>
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
{:else}
|
{:else}
|
||||||
<div class="text-center text-muted">Keine Aufgaben.</div>
|
<div class="text-center text-muted">Keine Personen-Referenzen für {selectedDate}.</div>
|
||||||
{/each}
|
{/each}
|
||||||
|
|
|
||||||
|
|
@ -30,10 +30,10 @@ export async function seedIfEmpty(): Promise<void> {
|
||||||
const t1 = newId(), t2 = newId(), t101 = newId();
|
const t1 = newId(), t2 = newId(), t101 = newId();
|
||||||
|
|
||||||
const topics: Topic[] = [
|
const topics: Topic[] = [
|
||||||
{ id: t201, contextId: 'daily-log', title: 'Anruf: Lizenzprobleme Vendor X', status: 'active', snoozeUntil: null, sortOrder: 0, isNew: false, updatedAt: ts, deletedAt: null, version: 1 },
|
{ id: t201, contextId: 'jf-sysadmins', title: 'Anruf: Lizenzprobleme Vendor X', status: 'active', snoozeUntil: null, sortOrder: 2, isNew: false, updatedAt: ts, deletedAt: null, version: 1 },
|
||||||
{ id: t202, contextId: 'daily-log', title: 'Idee: Cloud-Backup Optimierung', status: 'active', snoozeUntil: null, sortOrder: 1, isNew: false, updatedAt: ts, deletedAt: null, version: 1 },
|
{ id: t202, contextId: 'jf-devs', title: 'Idee: Cloud-Backup Optimierung', status: 'active', snoozeUntil: null, sortOrder: 1, isNew: false, updatedAt: ts, deletedAt: null, version: 1 },
|
||||||
{ id: t203, contextId: 'daily-log', title: 'Quick-Fix: Drucker Buchhaltung', status: 'active', snoozeUntil: null, sortOrder: 2, isNew: false, updatedAt: ts, deletedAt: null, version: 1 },
|
{ id: t203, contextId: 'jf-sysadmins', title: 'Quick-Fix: Drucker Buchhaltung', status: 'active', snoozeUntil: null, sortOrder: 3, isNew: false, updatedAt: ts, deletedAt: null, version: 1 },
|
||||||
{ id: t204, contextId: 'daily-log', title: 'Personalgespräch Vorbereitung', status: 'active', snoozeUntil: null, sortOrder: 3, isNew: false, updatedAt: ts, deletedAt: null, version: 1 },
|
{ id: t204, contextId: 'jf-sysadmins', title: 'Personalgespräch Vorbereitung', status: 'active', snoozeUntil: null, sortOrder: 4, isNew: false, updatedAt: ts, deletedAt: null, version: 1 },
|
||||||
{ id: t1, contextId: 'jf-sysadmins', title: 'TISAX: Sperren Produktionsrechner', status: 'active', snoozeUntil: null, sortOrder: 0, isNew: false, updatedAt: ts, deletedAt: null, version: 1 },
|
{ id: t1, contextId: 'jf-sysadmins', title: 'TISAX: Sperren Produktionsrechner', status: 'active', snoozeUntil: null, sortOrder: 0, isNew: false, updatedAt: ts, deletedAt: null, version: 1 },
|
||||||
{ id: t2, contextId: 'jf-sysadmins', title: 'Greenbone-Prozess', status: 'active', snoozeUntil: null, sortOrder: 1, isNew: false, updatedAt: ts, deletedAt: null, version: 1 },
|
{ id: t2, contextId: 'jf-sysadmins', title: 'Greenbone-Prozess', status: 'active', snoozeUntil: null, sortOrder: 1, isNew: false, updatedAt: ts, deletedAt: null, version: 1 },
|
||||||
{ id: t101, contextId: 'jf-devs', title: 'API Refactoring', status: 'active', snoozeUntil: null, sortOrder: 0, isNew: false, updatedAt: ts, deletedAt: null, version: 1 }
|
{ id: t101, contextId: 'jf-devs', title: 'API Refactoring', status: 'active', snoozeUntil: null, sortOrder: 0, isNew: false, updatedAt: ts, deletedAt: null, version: 1 }
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue