Planboard: Wochenansicht ohne Karten (Tagesspalten, heute als Pille, Termine als Links)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
ClaudeandClaude Sonnet 5.5 committed 2026-10-06 06:03:14 +00:00
1 parent a0149137ea
commit e54a30b006
2 files changed
+78 -94

No files matched your search

+48 -90
View File
@@ -1,26 +1,19 @@
import { useState, useMemo } from 'react'
import { useNavigate } from 'react-router-dom'
import { format, addDays, startOfWeek, isSameDay } from 'date-fns'
import { de } from 'date-fns/locale'
import { FaChevronLeft, FaChevronRight } from 'react-icons/fa6'
import { PageHeader, Card, Button } from '../components/ui'
import { Link } from 'react-router-dom'
import { addDays, startOfWeek, isSameDay } from 'date-fns'
import { PageHeader, Button } from '../components/ui'
import { useWorkorders } from '../hooks/useWorkorders'
import { useEmployees } from '../hooks/useEmployees'
import { groupAppointmentsByDay, countInRange, dayKey } from '../lib/planboard'
import { ticketPath } from '../lib/ticketRoutes'
import { ticketPath, ticketRef } from '../lib/ticketRoutes'
import {
planboardSubtitle, dayLabels, appointmentClass, appointmentTimeLabel, appointmentOwnerLabel, appointmentTitle,
} from '../lib/planboardView'
/* Termine haengen an den Tickets (startDate/startTime/endTime/assignedTo);
die Aufbereitung steckt in src/lib/planboard.js. */
// Farben nur ueber Tokens (P3 baut die Seite um)
const TYPE_COLORS = {
akquise: { bg: 'var(--appt-akquise)', fg: 'var(--orange-fg)' },
webpage: { bg: 'var(--bg-hover)', fg: 'var(--text-2)' },
project: { bg: 'var(--bg-hover)', fg: 'var(--text-2)' },
}
die Aufbereitung steckt in src/lib/planboard.js, die Texte in src/lib/planboardView.js. */
export default function PlanboardPage() {
const navigate = useNavigate()
const [currentWeek, setCurrentWeek] = useState(startOfWeek(new Date(), { weekStartsOn: 1 }))
const { workorders, loading } = useWorkorders({ limit: 500 })
const { employees } = useEmployees()
@@ -36,87 +29,52 @@ export default function PlanboardPage() {
<div className="page">
<PageHeader
title="Planboard"
subtitle={loading ? 'Wochenplanung – lädt…' : `Wochenplanung – ${weekCount} ${weekCount === 1 ? 'Termin' : 'Termine'} diese Woche`}
subtitle={planboardSubtitle({ weekStart: currentWeek, count: weekCount, loading })}
actions={
<div className="flex gap-2 items-center">
<Button variant="ghost" onClick={() => navigateWeek(-1)}><FaChevronLeft /></Button>
<span className="muted" style={{ minWidth: 200, textAlign: 'center' }}>
{format(currentWeek, 'dd.MM.yyyy')} - {format(addDays(currentWeek, 6), 'dd.MM.yyyy')}
</span>
<Button variant="ghost" onClick={() => navigateWeek(1)}><FaChevronRight /></Button>
<Button variant="ghost" onClick={goToday}>Heute</Button>
</div>
<>
<Button variant="quiet" aria-label="Vorherige Woche" onClick={() => navigateWeek(-1)}>←</Button>
<Button onClick={goToday}>Heute</Button>
<Button variant="quiet" aria-label="Nächste Woche" onClick={() => navigateWeek(1)}>→</Button>
</>
}
/>
<div className="planboard-scroll">
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(7, 1fr)', gap: 12 }}>
{weekDays.map((day) => {
const entries = byDay[dayKey(day)] || []
const today = isSameDay(day, new Date())
return (
<Card key={day.toISOString()} pad={false}>
<div style={{
padding: '10px 12px',
borderBottom: '1px solid var(--border)',
display: 'flex',
flexDirection: 'column',
background: today ? 'var(--appt-akquise)' : undefined,
}}>
<strong style={{ fontSize: 13 }}>{format(day, 'EEEE', { locale: de })}</strong>
<span className="muted" style={{ fontSize: 12 }}>{format(day, 'dd.MM')}</span>
</div>
<div className="week">
{weekDays.map((day, index) => {
const entries = byDay[dayKey(day)] || []
const today = isSameDay(day, new Date())
const labels = dayLabels(day)
return (
<div
key={day.toISOString()}
className={`day${today ? ' today' : ''}${index >= 5 ? ' weekend' : ''}`}
role="group"
aria-label={labels.full}
aria-current={today ? 'date' : undefined}
>
<div className="day-head">
<span className="wd">{labels.weekday}</span>
<span className="dn">{labels.number}</span>
</div>
<div style={{ padding: 8, minHeight: 120, display: 'flex', flexDirection: 'column', gap: 6 }}>
{entries.length === 0 && (
<p className="faint" style={{ fontSize: 12, padding: '4px 4px 0' }}>Keine Termine</p>
)}
{entries.length === 0 && <div className="none">Keine Termine</div>}
{entries.map((entry) => {
const color = TYPE_COLORS[String(entry.type).toLowerCase()]
|| { bg: 'var(--bg-subtle)', fg: 'var(--line-strong)' }
return (
<button
key={entry.id}
type="button"
title={`Ticket #${entry.woid} öffnen`}
onClick={() => navigate(ticketPath(entry.woid || entry.id))}
style={{
textAlign: 'left',
border: '1px solid var(--border)',
borderLeft: `3px solid ${color.fg}`,
borderRadius: 8,
background: color.bg,
color: 'inherit',
padding: '8px 10px',
cursor: 'pointer',
font: 'inherit',
display: 'flex',
flexDirection: 'column',
gap: 2,
}}
>
<span style={{ fontSize: 12, fontWeight: 700 }}>
{entry.time ? `${entry.time}${entry.endTime ? `–${entry.endTime}` : ''}` : 'ohne Uhrzeit'}
</span>
<span style={{ fontSize: 12.5, fontWeight: 600, lineHeight: 1.25 }}>
{entry.customerName || entry.topic}
</span>
{entry.customerName && (
<span className="muted" style={{ fontSize: 11.5, lineHeight: 1.25 }}>{entry.topic}</span>
)}
<span className="muted" style={{ fontSize: 11 }}>
#{entry.woid}
{entry.employeeName ? ` · ${entry.employeeShort || entry.employeeName}` : ' · niemand zugewiesen'}
</span>
</button>
)
})}
</div>
</Card>
)
})}
</div>
{entries.map((entry) => (
<Link
key={entry.id}
className={appointmentClass(entry.type)}
to={ticketPath(ticketRef({ woid: entry.woid, $id: entry.id }))}
title={appointmentTitle(entry)}
>
<div className="tm">{appointmentTimeLabel(entry)}</div>
<div className="tt">{entry.customerName || entry.topic}</div>
{entry.customerName && <div className="cu">{entry.topic}</div>}
<div className="cu">{appointmentOwnerLabel(entry)}</div>
</Link>
))}
</div>
)
})}
</div>
</div>
)
+30 -4
View File
@@ -557,9 +557,6 @@ a.list-row:hover .cell-title { color: var(--accent-ink); }
.wrap { flex-wrap: wrap; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.text-ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Planboard (bis P3): die 7-Spalten-Woche scrollt waagerecht im Container, nicht die Seite */
.planboard-scroll { overflow-x: auto; }
/* Neues Ticket: Datum + Uhrzeit nebeneinander (heller Kalender, kein color-scheme: dark) */
.datetime-pair { display: flex; gap: 8px; }
.datetime-pair .form-control, .datetime-pair .input { flex: 1; min-width: 0; }
@@ -1012,6 +1009,35 @@ button.link { font-weight: 500; } /* font: inherit setzt sonst das Gewicht von .
}
/* ===== ENDE Tickets (P2) ===== */
/* ===== Planboard (P3) ===== */
/* Woche ohne Karten: sieben Tagesspalten mit feinen Trennlinien, Wochenende hell abgesetzt, heute als schwarze Datumspille */
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--line); min-height: 420px; }
.day { border-left: 1px solid var(--line); padding: 10px 8px 16px; min-width: 0; }
.day:first-child { border-left: 0; padding-left: 0; }
.day-head { display: flex; align-items: baseline; gap: 6px; margin-bottom: 12px; padding-left: 4px; flex-wrap: wrap; row-gap: 0; }
.day-head .wd { font-size: 12px; color: var(--text-2); font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; }
.day-head .dn { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.day.today .wd { color: var(--text); }
.day.today .dn { background: var(--accent); color: #fff; border-radius: 99px; padding: 0 8px; }
.day.weekend { background: var(--bg-subtle); }
.appt { display: block; padding: 8px 10px; border-radius: var(--radius); background: var(--bg-hover); margin-bottom: 6px; font-size: 13px; line-height: 18px; overflow-wrap: anywhere; }
.appt:hover { background: var(--appt-hover); }
.appt .tm { font-weight: 600; font-variant-numeric: tabular-nums; }
.appt .tt { color: var(--text); margin-top: 2px; }
.appt .cu { color: var(--text-2); margin-top: 2px; }
.appt.akquise { background: var(--appt-akquise); }
.appt.akquise:hover { background: var(--appt-akquise-hover); }
.day.weekend .appt:not(.akquise) { background: var(--bg); }
.day.weekend .appt:not(.akquise):hover { background: var(--appt-hover); }
.day .none { font-size: 12px; color: var(--text-3); padding-left: 4px; }
@media (max-width: 860px) {
.week { grid-template-columns: 1fr; border-top: 0; min-height: 0; }
.day { border-left: 0; padding: 12px 0; border-top: 1px solid var(--line); }
.day.weekend { background: none; }
.day.weekend .appt:not(.akquise) { background: var(--bg-hover); }
}
/* ===== ENDE Planboard (P3) ===== */
/* ===== KOMPAT (bis P10) ===== */
/* Uebergangsschicht: alte Klassen im neuen Look, damit Seiten und Dialoge, die noch nicht umgebaut sind, weiss, kastenlos */
/* und lesbar bleiben. Steht am Dateiende und gewinnt dort gegen die Altregeln und gegen die anderen Stylesheets (global.css */
@@ -1122,7 +1148,7 @@ div.row { display: flex; flex-wrap: wrap; margin: 0 -8px; }
.fin-link:hover, .legal-files a:hover, .credit-cols a:hover, .area-rows a:hover { text-decoration-color: currentColor; }
/* Abschnitte (Card = <section>) als Spalten nebeneinander: der Abstand .page section + section gilt nur fuer untereinander stehende Abschnitte */
.planboard-scroll section + section, .legal-grid > section + section, .fin-cols > section + section,
.legal-grid > section + section, .fin-cols > section + section,
.page div[style*="display: grid"] > section + section { margin-top: 0; }
/* Altformulare mit <Field> (Kunde, Projekt zuweisen, Neuer Lead): Zeilenabstand wie frueher; neue Container bestimmen ihren Abstand selbst */