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:
1 parent
a0149137ea
commit
e54a30b006
2 files changed
+78
-94
No files matched your search
+48
-90
@@ -1,26 +1,19 @@
|
|||||||
import { useState, useMemo } from 'react'
|
import { useState, useMemo } from 'react'
|
||||||
import { useNavigate } from 'react-router-dom'
|
import { Link } from 'react-router-dom'
|
||||||
import { format, addDays, startOfWeek, isSameDay } from 'date-fns'
|
import { addDays, startOfWeek, isSameDay } from 'date-fns'
|
||||||
import { de } from 'date-fns/locale'
|
import { PageHeader, Button } from '../components/ui'
|
||||||
import { FaChevronLeft, FaChevronRight } from 'react-icons/fa6'
|
|
||||||
import { PageHeader, Card, Button } from '../components/ui'
|
|
||||||
import { useWorkorders } from '../hooks/useWorkorders'
|
import { useWorkorders } from '../hooks/useWorkorders'
|
||||||
import { useEmployees } from '../hooks/useEmployees'
|
import { useEmployees } from '../hooks/useEmployees'
|
||||||
import { groupAppointmentsByDay, countInRange, dayKey } from '../lib/planboard'
|
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);
|
/* Termine haengen an den Tickets (startDate/startTime/endTime/assignedTo);
|
||||||
die Aufbereitung steckt in src/lib/planboard.js. */
|
die Aufbereitung steckt in src/lib/planboard.js, die Texte in src/lib/planboardView.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)' },
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function PlanboardPage() {
|
export default function PlanboardPage() {
|
||||||
const navigate = useNavigate()
|
|
||||||
const [currentWeek, setCurrentWeek] = useState(startOfWeek(new Date(), { weekStartsOn: 1 }))
|
const [currentWeek, setCurrentWeek] = useState(startOfWeek(new Date(), { weekStartsOn: 1 }))
|
||||||
const { workorders, loading } = useWorkorders({ limit: 500 })
|
const { workorders, loading } = useWorkorders({ limit: 500 })
|
||||||
const { employees } = useEmployees()
|
const { employees } = useEmployees()
|
||||||
@@ -36,87 +29,52 @@ export default function PlanboardPage() {
|
|||||||
<div className="page">
|
<div className="page">
|
||||||
<PageHeader
|
<PageHeader
|
||||||
title="Planboard"
|
title="Planboard"
|
||||||
subtitle={loading ? 'Wochenplanung – lädt…' : `Wochenplanung – ${weekCount} ${weekCount === 1 ? 'Termin' : 'Termine'} diese Woche`}
|
subtitle={planboardSubtitle({ weekStart: currentWeek, count: weekCount, loading })}
|
||||||
actions={
|
actions={
|
||||||
<div className="flex gap-2 items-center">
|
<>
|
||||||
<Button variant="ghost" onClick={() => navigateWeek(-1)}><FaChevronLeft /></Button>
|
<Button variant="quiet" aria-label="Vorherige Woche" onClick={() => navigateWeek(-1)}>←</Button>
|
||||||
<span className="muted" style={{ minWidth: 200, textAlign: 'center' }}>
|
<Button onClick={goToday}>Heute</Button>
|
||||||
{format(currentWeek, 'dd.MM.yyyy')} - {format(addDays(currentWeek, 6), 'dd.MM.yyyy')}
|
<Button variant="quiet" aria-label="Nächste Woche" onClick={() => navigateWeek(1)}>→</Button>
|
||||||
</span>
|
</>
|
||||||
<Button variant="ghost" onClick={() => navigateWeek(1)}><FaChevronRight /></Button>
|
|
||||||
<Button variant="ghost" onClick={goToday}>Heute</Button>
|
|
||||||
</div>
|
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div className="planboard-scroll">
|
<div className="week">
|
||||||
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(7, 1fr)', gap: 12 }}>
|
{weekDays.map((day, index) => {
|
||||||
{weekDays.map((day) => {
|
const entries = byDay[dayKey(day)] || []
|
||||||
const entries = byDay[dayKey(day)] || []
|
const today = isSameDay(day, new Date())
|
||||||
const today = isSameDay(day, new Date())
|
const labels = dayLabels(day)
|
||||||
return (
|
return (
|
||||||
<Card key={day.toISOString()} pad={false}>
|
<div
|
||||||
<div style={{
|
key={day.toISOString()}
|
||||||
padding: '10px 12px',
|
className={`day${today ? ' today' : ''}${index >= 5 ? ' weekend' : ''}`}
|
||||||
borderBottom: '1px solid var(--border)',
|
role="group"
|
||||||
display: 'flex',
|
aria-label={labels.full}
|
||||||
flexDirection: 'column',
|
aria-current={today ? 'date' : undefined}
|
||||||
background: today ? 'var(--appt-akquise)' : undefined,
|
>
|
||||||
}}>
|
<div className="day-head">
|
||||||
<strong style={{ fontSize: 13 }}>{format(day, 'EEEE', { locale: de })}</strong>
|
<span className="wd">{labels.weekday}</span>
|
||||||
<span className="muted" style={{ fontSize: 12 }}>{format(day, 'dd.MM')}</span>
|
<span className="dn">{labels.number}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div style={{ padding: 8, minHeight: 120, display: 'flex', flexDirection: 'column', gap: 6 }}>
|
{entries.length === 0 && <div className="none">Keine Termine</div>}
|
||||||
{entries.length === 0 && (
|
|
||||||
<p className="faint" style={{ fontSize: 12, padding: '4px 4px 0' }}>Keine Termine</p>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{entries.map((entry) => {
|
{entries.map((entry) => (
|
||||||
const color = TYPE_COLORS[String(entry.type).toLowerCase()]
|
<Link
|
||||||
|| { bg: 'var(--bg-subtle)', fg: 'var(--line-strong)' }
|
key={entry.id}
|
||||||
return (
|
className={appointmentClass(entry.type)}
|
||||||
<button
|
to={ticketPath(ticketRef({ woid: entry.woid, $id: entry.id }))}
|
||||||
key={entry.id}
|
title={appointmentTitle(entry)}
|
||||||
type="button"
|
>
|
||||||
title={`Ticket #${entry.woid} öffnen`}
|
<div className="tm">{appointmentTimeLabel(entry)}</div>
|
||||||
onClick={() => navigate(ticketPath(entry.woid || entry.id))}
|
<div className="tt">{entry.customerName || entry.topic}</div>
|
||||||
style={{
|
{entry.customerName && <div className="cu">{entry.topic}</div>}
|
||||||
textAlign: 'left',
|
<div className="cu">{appointmentOwnerLabel(entry)}</div>
|
||||||
border: '1px solid var(--border)',
|
</Link>
|
||||||
borderLeft: `3px solid ${color.fg}`,
|
))}
|
||||||
borderRadius: 8,
|
</div>
|
||||||
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>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
+30
-4
@@ -557,9 +557,6 @@ a.list-row:hover .cell-title { color: var(--accent-ink); }
|
|||||||
.wrap { flex-wrap: wrap; }
|
.wrap { flex-wrap: wrap; }
|
||||||
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
|
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
|
||||||
.text-ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
.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) */
|
/* Neues Ticket: Datum + Uhrzeit nebeneinander (heller Kalender, kein color-scheme: dark) */
|
||||||
.datetime-pair { display: flex; gap: 8px; }
|
.datetime-pair { display: flex; gap: 8px; }
|
||||||
.datetime-pair .form-control, .datetime-pair .input { flex: 1; min-width: 0; }
|
.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) ===== */
|
/* ===== 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) ===== */
|
/* ===== KOMPAT (bis P10) ===== */
|
||||||
/* Uebergangsschicht: alte Klassen im neuen Look, damit Seiten und Dialoge, die noch nicht umgebaut sind, weiss, kastenlos */
|
/* 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 */
|
/* 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; }
|
.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 */
|
/* 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; }
|
.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 */
|
/* Altformulare mit <Field> (Kunde, Projekt zuweisen, Neuer Lead): Zeilenabstand wie frueher; neue Container bestimmen ihren Abstand selbst */
|
||||||
|
|||||||
Reference in new issue
Block a user