Historie: Task-Notizen + Link sichtbar, Navigation zu Tagen mit Einträgen
- Notizfeld pro Task in der Reflexion (optional, jeder Status) — nutzt das bestehende dropReason-Feld (Limit 200->500). Wird in der Historie bei JEDEM Status angezeigt (bisher nur bei "verworfen"). - Optionaler Tages-Link wird in der Historie jetzt angezeigt. - Historie-Pfeile springen zum naechsten/vorherigen Tag MIT Eintraegen statt starr ueber Werktage — Wochenend-Arbeit (z. B. Sa 6.6.) ist nun erreichbar. Default-Tag = juengster Tag vor heute mit Eintrag. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
6e7a910ed3
commit
6acf9977ec
4 files changed
+78
-18
No files matched your search
@@ -1,12 +1,11 @@
|
|||||||
import { TRPCError } from '@trpc/server';
|
import { TRPCError } from '@trpc/server';
|
||||||
import { and, eq, gte, isNull, lt, lte, asc, desc, inArray } from 'drizzle-orm';
|
import { and, eq, gt, gte, isNull, lt, lte, asc, desc, inArray } from 'drizzle-orm';
|
||||||
import { dayEntry, todo, blocker, user, type Db, type DayEntry, type Todo } from '@cockpit/db';
|
import { dayEntry, todo, blocker, user, type Db, type DayEntry, type Todo } from '@cockpit/db';
|
||||||
import { DayEntrySchemas } from '@cockpit/shared';
|
import { DayEntrySchemas } from '@cockpit/shared';
|
||||||
import { router, protectedProcedure } from '../trpc.js';
|
import { router, protectedProcedure } from '../trpc.js';
|
||||||
import {
|
import {
|
||||||
todayIso,
|
todayIso,
|
||||||
previousWerktag,
|
previousWerktag,
|
||||||
nextWerktag,
|
|
||||||
addCalendarDays,
|
addCalendarDays,
|
||||||
workdayCutoffMs,
|
workdayCutoffMs,
|
||||||
isWorkdaySealed,
|
isWorkdaySealed,
|
||||||
@@ -618,7 +617,18 @@ export const dayEntryRouter = router({
|
|||||||
.input(DayEntrySchemas.historyForDateInput)
|
.input(DayEntrySchemas.historyForDateInput)
|
||||||
.query(async ({ ctx, input }) => {
|
.query(async ({ ctx, input }) => {
|
||||||
const today = todayIso();
|
const today = todayIso();
|
||||||
const date = input.date ?? previousWerktag(today);
|
// Default-Tag = der jüngste Tag VOR heute, an dem es überhaupt Einträge gibt
|
||||||
|
// (nicht starr der vorige Werktag — sonst sieht man Wochenend-Arbeit nicht).
|
||||||
|
const fallbackDate =
|
||||||
|
(
|
||||||
|
await ctx.db
|
||||||
|
.select({ d: dayEntry.date })
|
||||||
|
.from(dayEntry)
|
||||||
|
.where(lt(dayEntry.date, today))
|
||||||
|
.orderBy(desc(dayEntry.date))
|
||||||
|
.limit(1)
|
||||||
|
)[0]?.d ?? previousWerktag(today);
|
||||||
|
const date = input.date ?? fallbackDate;
|
||||||
const isToday = date === today;
|
const isToday = date === today;
|
||||||
|
|
||||||
const entries = await ctx.db.select().from(dayEntry).where(eq(dayEntry.date, date));
|
const entries = await ctx.db.select().from(dayEntry).where(eq(dayEntry.date, date));
|
||||||
@@ -669,11 +679,28 @@ export const dayEntryRouter = router({
|
|||||||
.map((u) => u.name)
|
.map((u) => u.name)
|
||||||
.sort((a, b) => a.localeCompare(b));
|
.sort((a, b) => a.localeCompare(b));
|
||||||
|
|
||||||
const nw = nextWerktag(date);
|
// Pfeil-Navigation springt zum nächsten/vorherigen Tag MIT Einträgen
|
||||||
|
// (überspringt leere Tage, erreicht aber Wochenend-Arbeit).
|
||||||
|
const prevRow = (
|
||||||
|
await ctx.db
|
||||||
|
.select({ d: dayEntry.date })
|
||||||
|
.from(dayEntry)
|
||||||
|
.where(lt(dayEntry.date, date))
|
||||||
|
.orderBy(desc(dayEntry.date))
|
||||||
|
.limit(1)
|
||||||
|
)[0];
|
||||||
|
const nextRow = (
|
||||||
|
await ctx.db
|
||||||
|
.select({ d: dayEntry.date })
|
||||||
|
.from(dayEntry)
|
||||||
|
.where(and(gt(dayEntry.date, date), lte(dayEntry.date, today)))
|
||||||
|
.orderBy(asc(dayEntry.date))
|
||||||
|
.limit(1)
|
||||||
|
)[0];
|
||||||
return {
|
return {
|
||||||
date,
|
date,
|
||||||
prevDate: previousWerktag(date),
|
prevDate: prevRow?.d ?? null,
|
||||||
nextDate: nw < today ? nw : null,
|
nextDate: nextRow?.d ?? null,
|
||||||
entries: list,
|
entries: list,
|
||||||
ohneEintrag,
|
ohneEintrag,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -68,9 +68,10 @@ export function HistorieRoute() {
|
|||||||
<div className="flex flex-wrap items-center gap-2">
|
<div className="flex flex-wrap items-center gap-2">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => setDate(prevDate)}
|
onClick={() => prevDate && setDate(prevDate)}
|
||||||
aria-label="Vorheriger Werktag"
|
disabled={!prevDate}
|
||||||
className="inline-flex h-9 w-9 items-center justify-center rounded-[var(--radius-md)] border border-[var(--color-border)] text-[var(--color-ink-muted)] hover:border-[var(--color-ink)] hover:text-[var(--color-ink)]"
|
aria-label="Vorheriger Tag mit Eintrag"
|
||||||
|
className="inline-flex h-9 w-9 items-center justify-center rounded-[var(--radius-md)] border border-[var(--color-border)] text-[var(--color-ink-muted)] hover:border-[var(--color-ink)] hover:text-[var(--color-ink)] disabled:opacity-40 disabled:hover:border-[var(--color-border)]"
|
||||||
>
|
>
|
||||||
<ChevronLeft size={16} />
|
<ChevronLeft size={16} />
|
||||||
</button>
|
</button>
|
||||||
@@ -79,7 +80,7 @@ export function HistorieRoute() {
|
|||||||
type="button"
|
type="button"
|
||||||
onClick={() => nextDate && setDate(nextDate)}
|
onClick={() => nextDate && setDate(nextDate)}
|
||||||
disabled={!nextDate}
|
disabled={!nextDate}
|
||||||
aria-label="Nächster Werktag"
|
aria-label="Nächster Tag mit Eintrag"
|
||||||
className="inline-flex h-9 w-9 items-center justify-center rounded-[var(--radius-md)] border border-[var(--color-border)] text-[var(--color-ink-muted)] hover:border-[var(--color-ink)] hover:text-[var(--color-ink)] disabled:opacity-40 disabled:hover:border-[var(--color-border)]"
|
className="inline-flex h-9 w-9 items-center justify-center rounded-[var(--radius-md)] border border-[var(--color-border)] text-[var(--color-ink-muted)] hover:border-[var(--color-ink)] hover:text-[var(--color-ink)] disabled:opacity-40 disabled:hover:border-[var(--color-border)]"
|
||||||
>
|
>
|
||||||
<ChevronRight size={16} />
|
<ChevronRight size={16} />
|
||||||
@@ -154,6 +155,7 @@ function PersonCard({ person: p }: { person: HistoryPerson }) {
|
|||||||
: 'bg-[var(--color-border-strong)]',
|
: 'bg-[var(--color-border-strong)]',
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
<div className="flex-1">
|
||||||
<span
|
<span
|
||||||
className={clsx(
|
className={clsx(
|
||||||
t.status === 'dropped' && 'text-[var(--color-ink-muted)] line-through',
|
t.status === 'dropped' && 'text-[var(--color-ink-muted)] line-through',
|
||||||
@@ -165,10 +167,13 @@ function PersonCard({ person: p }: { person: HistoryPerson }) {
|
|||||||
ungeplant
|
ungeplant
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
{t.status === 'dropped' && t.dropReason && (
|
|
||||||
<span className="text-xs text-[var(--color-ink-faint)]"> — {t.dropReason}</span>
|
|
||||||
)}
|
|
||||||
</span>
|
</span>
|
||||||
|
{t.dropReason && (
|
||||||
|
<span className="mt-0.5 block whitespace-pre-wrap text-xs text-[var(--color-ink-muted)]">
|
||||||
|
{t.dropReason}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
@@ -177,7 +182,17 @@ function PersonCard({ person: p }: { person: HistoryPerson }) {
|
|||||||
{p.reflectionText && (
|
{p.reflectionText && (
|
||||||
<p className="whitespace-pre-wrap text-sm text-[var(--color-ink)]">{p.reflectionText}</p>
|
<p className="whitespace-pre-wrap text-sm text-[var(--color-ink)]">{p.reflectionText}</p>
|
||||||
)}
|
)}
|
||||||
{p.todos.length === 0 && !p.reflectionText && (
|
{p.url && (
|
||||||
|
<a
|
||||||
|
href={p.url}
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
className="block truncate text-sm text-[var(--color-ink-muted)] underline hover:text-[var(--color-ink)]"
|
||||||
|
>
|
||||||
|
{p.url}
|
||||||
|
</a>
|
||||||
|
)}
|
||||||
|
{p.todos.length === 0 && !p.reflectionText && !p.url && (
|
||||||
<p className="text-xs text-[var(--color-ink-faint)]">Keine Details.</p>
|
<p className="text-xs text-[var(--color-ink-faint)]">Keine Details.</p>
|
||||||
)}
|
)}
|
||||||
</Card.Body>
|
</Card.Body>
|
||||||
|
|||||||
@@ -51,12 +51,13 @@ function ReflectForm({
|
|||||||
status: TodoStatus;
|
status: TodoStatus;
|
||||||
bezugKind: 'project' | 'deal' | 'campaign' | 'allgemein' | null;
|
bezugKind: 'project' | 'deal' | 'campaign' | 'allgemein' | null;
|
||||||
unplanned?: boolean;
|
unplanned?: boolean;
|
||||||
|
dropReason?: string | null;
|
||||||
}>;
|
}>;
|
||||||
onDone: () => void;
|
onDone: () => void;
|
||||||
}) {
|
}) {
|
||||||
const [todoStates, setTodoStates] = useState<
|
const [todoStates, setTodoStates] = useState<
|
||||||
Record<string, { status: TodoStatus; reason?: string }>
|
Record<string, { status: TodoStatus; reason?: string }>
|
||||||
>(Object.fromEntries(todos.map((t) => [t.id, { status: t.status }])));
|
>(Object.fromEntries(todos.map((t) => [t.id, { status: t.status, reason: t.dropReason ?? '' }])));
|
||||||
const [reflectionText, setReflectionText] = useState('');
|
const [reflectionText, setReflectionText] = useState('');
|
||||||
const [ampel, setAmpel] = useState<Ampel | null>(null);
|
const [ampel, setAmpel] = useState<Ampel | null>(null);
|
||||||
const [trend, setTrend] = useState<Trend | null>(null);
|
const [trend, setTrend] = useState<Trend | null>(null);
|
||||||
@@ -86,6 +87,10 @@ function ReflectForm({
|
|||||||
setTodoStates((prev) => ({ ...prev, [id]: { ...prev[id], status } }));
|
setTodoStates((prev) => ({ ...prev, [id]: { ...prev[id], status } }));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setTodoReason(id: string, reason: string) {
|
||||||
|
setTodoStates((prev) => ({ ...prev, [id]: { status: prev[id]?.status ?? 'open', reason } }));
|
||||||
|
}
|
||||||
|
|
||||||
function handleSubmit(e: React.FormEvent) {
|
function handleSubmit(e: React.FormEvent) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (!ampel) {
|
if (!ampel) {
|
||||||
@@ -107,7 +112,7 @@ function ReflectForm({
|
|||||||
todos: todos.map((t) => ({
|
todos: todos.map((t) => ({
|
||||||
id: t.id,
|
id: t.id,
|
||||||
status: todoStates[t.id]?.status ?? t.status,
|
status: todoStates[t.id]?.status ?? t.status,
|
||||||
dropReason: todoStates[t.id]?.reason,
|
dropReason: todoStates[t.id]?.reason?.trim() || undefined,
|
||||||
})),
|
})),
|
||||||
reflectionText,
|
reflectionText,
|
||||||
ampel,
|
ampel,
|
||||||
@@ -138,7 +143,8 @@ function ReflectForm({
|
|||||||
{todos.map((t) => {
|
{todos.map((t) => {
|
||||||
const status = todoStates[t.id]?.status ?? t.status;
|
const status = todoStates[t.id]?.status ?? t.status;
|
||||||
return (
|
return (
|
||||||
<li key={t.id} className="flex items-center gap-2">
|
<li key={t.id} className="space-y-1">
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
<EditableTodoTitle id={t.id} title={t.title} />
|
<EditableTodoTitle id={t.id} title={t.title} />
|
||||||
{t.unplanned && (
|
{t.unplanned && (
|
||||||
<span className="rounded-full bg-black/5 px-1.5 py-0.5 text-[10px] text-[var(--color-ink-muted)]">
|
<span className="rounded-full bg-black/5 px-1.5 py-0.5 text-[10px] text-[var(--color-ink-muted)]">
|
||||||
@@ -168,6 +174,16 @@ function ReflectForm({
|
|||||||
<X size={14} />
|
<X size={14} />
|
||||||
</StatusBtn>
|
</StatusBtn>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
value={todoStates[t.id]?.reason ?? ''}
|
||||||
|
onChange={(e) => setTodoReason(t.id, e.target.value)}
|
||||||
|
placeholder="Notiz (optional) — Ergebnis, Kontext, Link …"
|
||||||
|
maxLength={500}
|
||||||
|
aria-label={`Notiz zu ${t.title}`}
|
||||||
|
className="w-full rounded-[var(--radius-md)] border border-[var(--color-border)] bg-white px-2 py-1 text-xs focus:border-[var(--color-ink)] focus:outline-none"
|
||||||
|
/>
|
||||||
</li>
|
</li>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|||||||
@@ -28,7 +28,9 @@ export const submitReflectionInput = z.object({
|
|||||||
z.object({
|
z.object({
|
||||||
id: z.string().uuid(),
|
id: z.string().uuid(),
|
||||||
status: todoStatusSchema,
|
status: todoStatusSchema,
|
||||||
dropReason: z.string().max(200).optional(),
|
// Optionale Notiz pro Task (frühere „Verworfen-Grund"-Spalte, jetzt für
|
||||||
|
// jeden Status als freie Beschreibung nutzbar).
|
||||||
|
dropReason: z.string().max(500).optional(),
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.default([]),
|
.default([]),
|
||||||
|
|||||||
Reference in new issue
Block a user