Compare commits
4 Commits
c45bcc99f0
...
feature/li
| Author | SHA1 | Date | |
|---|---|---|---|
| 03f8e4de90 | |||
| c1b215d06f | |||
| 7525970ffc | |||
| bfc90f8581 |
30
gerbil-manager-web/e2e/juvenile-details.spec.ts
Normal file
30
gerbil-manager-web/e2e/juvenile-details.spec.ts
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
/** LITTER-JUVENILE-DETAILS: Jungtier-Felder (Farbschlag/Abgabe/Verstorben) im Wurf-Detail. */
|
||||||
|
import { de, expect, skipUnlessMock, test } from './fixtures'
|
||||||
|
|
||||||
|
const t = de.pages.litters
|
||||||
|
|
||||||
|
test('Jungtier-Liste zeigt Farbschlag, Abgabedatum, Abnehmer, Todesdatum und Todesursache', async ({
|
||||||
|
page,
|
||||||
|
}) => {
|
||||||
|
skipUnlessMock()
|
||||||
|
await page.goto('/wuerfe/w-kruemel')
|
||||||
|
await expect(page.getByRole('heading', { name: 'Wurf K' })).toBeVisible()
|
||||||
|
|
||||||
|
// Krümel: Active, colorVarietyId cv-agouti → Farbschlag 'Agouti'
|
||||||
|
const kruemelCard = page.getByRole('link', { name: /Krümel/ })
|
||||||
|
await expect(kruemelCard).toBeVisible()
|
||||||
|
await expect(kruemelCard).toContainText(`${t.detail.juvenileFields.colorVariety}: Agouti`)
|
||||||
|
|
||||||
|
// Pippa: GivenAway, Gold, goHomeDate 2025-05-01, Abnehmer Familie Huber
|
||||||
|
const pippaCard = page.getByRole('link', { name: /Pippa/ })
|
||||||
|
await expect(pippaCard).toBeVisible()
|
||||||
|
await expect(pippaCard).toContainText(`${t.detail.juvenileFields.colorVariety}: Gold`)
|
||||||
|
await expect(pippaCard).toContainText(t.detail.juvenileFields.goHomeDate)
|
||||||
|
await expect(pippaCard).toContainText(`${t.detail.juvenileFields.receiver}: Familie Huber`)
|
||||||
|
|
||||||
|
// Benny: Deceased, no colorVarietyId, dateOfDeath + causeOfDeath
|
||||||
|
const bennyCard = page.getByRole('link', { name: /Benny/ })
|
||||||
|
await expect(bennyCard).toBeVisible()
|
||||||
|
await expect(bennyCard).toContainText(t.detail.juvenileFields.dateOfDeath)
|
||||||
|
await expect(bennyCard).toContainText(`${t.detail.juvenileFields.causeOfDeath}: Altersschwäche`)
|
||||||
|
})
|
||||||
@@ -151,6 +151,19 @@ export function seedDb(): MockDb {
|
|||||||
enclosureId: 'enc-leer',
|
enclosureId: 'enc-leer',
|
||||||
notes: 'neugieriger Entdecker',
|
notes: 'neugieriger Entdecker',
|
||||||
},
|
},
|
||||||
|
// LITTER-JUVENILE-DETAILS: Jungtiere für Wurf K mit Zusatzinfos.
|
||||||
|
{
|
||||||
|
...gerbil('pup-abgabe', 'Pippa', 'female', '2025-03-12', 'w-kruemel', 'cv-gold'),
|
||||||
|
status: 'GivenAway' as const,
|
||||||
|
goHomeDate: '2025-05-01',
|
||||||
|
receiverContactId: 'con-huber',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
...gerbil('pup-verstorben', 'Benny', 'male', '2025-03-12', 'w-kruemel', null),
|
||||||
|
status: 'Deceased' as const,
|
||||||
|
dateOfDeath: '2025-04-15',
|
||||||
|
causeOfDeath: 'Altersschwäche',
|
||||||
|
},
|
||||||
// UI-POLISH-1: Import-Stub ohne Namen — testet den '(ohne Namen)'-Platzhalter in Liste + Detail.
|
// UI-POLISH-1: Import-Stub ohne Namen — testet den '(ohne Namen)'-Platzhalter in Liste + Detail.
|
||||||
gerbil('nameless-stub', '', 'male', '2023-01-01', null, null),
|
gerbil('nameless-stub', '', 'male', '2023-01-01', null, null),
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -137,3 +137,20 @@ test('Kein Würfe-Panel wenn Wurzeltier keine Würfe hat (STAMMBAUM-LITTERS)', a
|
|||||||
await expect(page.locator('.pedigree-card').first()).toBeVisible()
|
await expect(page.locator('.pedigree-card').first()).toBeVisible()
|
||||||
await expect(page.locator('.stammbaum-litters-panel')).not.toBeVisible()
|
await expect(page.locator('.stammbaum-litters-panel')).not.toBeVisible()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('Knoten-Karte zeigt volles Geburtsdatum (STAMMBAUM-FULLDATE)', async ({ page }) => {
|
||||||
|
skipUnlessMock()
|
||||||
|
// Krümel: dateOfBirth '2025-03-12' → formatDate → '12.03.2025'
|
||||||
|
await page.goto('/rennmaeuse/kruemel/stammbaum')
|
||||||
|
await expect(page.locator('.pedigree-card').first()).toBeVisible()
|
||||||
|
await expect(page.locator('.pedigree-card__year').first()).toContainText('12.03.2025')
|
||||||
|
})
|
||||||
|
|
||||||
|
test('Gencode-Chip zeigt Genotyp statt Farbname (STAMMBAUM-GENCODE)', async ({ page }) => {
|
||||||
|
skipUnlessMock()
|
||||||
|
// Fridolin ist Vater von Krümel — genotype 'aa CC DD EE GG PP spsp rere'
|
||||||
|
await page.goto('/rennmaeuse/kruemel/stammbaum')
|
||||||
|
await expect(page.locator('.pedigree-card').first()).toBeVisible()
|
||||||
|
const fridolinCard = page.locator('.pedigree-card').filter({ hasText: 'Fridolin' })
|
||||||
|
await expect(fridolinCard.locator('.pedigree-chip')).toContainText('aa CC')
|
||||||
|
})
|
||||||
|
|||||||
@@ -1,19 +1,21 @@
|
|||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
|
import type { ReactNode } from 'react'
|
||||||
import { NavLink, Outlet } from 'react-router-dom'
|
import { NavLink, Outlet } from 'react-router-dom'
|
||||||
import { de } from '../strings/de'
|
import { de } from '../strings/de'
|
||||||
|
import GerbilIcon from './GerbilIcon'
|
||||||
import './appShell.css'
|
import './appShell.css'
|
||||||
|
|
||||||
interface NavItem {
|
interface NavItem {
|
||||||
to: string
|
to: string
|
||||||
label: string
|
label: string
|
||||||
icon: string
|
icon: ReactNode
|
||||||
end?: boolean
|
end?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
// Primary items are always visible in the phone bottom bar; secondary items
|
// Primary items are always visible in the phone bottom bar; secondary items
|
||||||
// move into the "Mehr" sheet on phones and appear inline in the desktop sidebar.
|
// move into the "Mehr" sheet on phones and appear inline in the desktop sidebar.
|
||||||
const PRIMARY: NavItem[] = [
|
const PRIMARY: NavItem[] = [
|
||||||
{ to: '/rennmaeuse', label: de.nav.gerbils, icon: '🐭' },
|
{ to: '/rennmaeuse', label: de.nav.gerbils, icon: <GerbilIcon size="1.25em" /> },
|
||||||
{ to: '/wuerfe', label: de.nav.litters, icon: '🍼' },
|
{ to: '/wuerfe', label: de.nav.litters, icon: '🍼' },
|
||||||
{ to: '/genetik', label: de.nav.genetics, icon: '🧬' },
|
{ to: '/genetik', label: de.nav.genetics, icon: '🧬' },
|
||||||
]
|
]
|
||||||
@@ -46,7 +48,7 @@ export default function AppShell() {
|
|||||||
return (
|
return (
|
||||||
<div className="app-shell">
|
<div className="app-shell">
|
||||||
<header className="app-header">
|
<header className="app-header">
|
||||||
<span className="app-logo" aria-hidden="true">🐭</span>
|
<span className="app-logo" aria-hidden="true"><GerbilIcon size="1.5rem" /></span>
|
||||||
<h1 className="app-title">{de.app.title}</h1>
|
<h1 className="app-title">{de.app.title}</h1>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
|
|||||||
35
gerbil-manager-web/src/components/GerbilIcon.tsx
Normal file
35
gerbil-manager-web/src/components/GerbilIcon.tsx
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
import type { CSSProperties } from 'react'
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
size?: string | number
|
||||||
|
style?: CSSProperties
|
||||||
|
className?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Reusable gerbil silhouette icon — upright sitting pose, long tail with tuft. fill=currentColor. */
|
||||||
|
export default function GerbilIcon({ size = '1em', style, className }: Props) {
|
||||||
|
return (
|
||||||
|
<svg
|
||||||
|
viewBox="0 0 64 64"
|
||||||
|
fill="currentColor"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
width={size}
|
||||||
|
height={size}
|
||||||
|
style={{ display: 'inline-block', verticalAlign: '-0.125em', flexShrink: 0, ...style }}
|
||||||
|
className={className}
|
||||||
|
role="img"
|
||||||
|
aria-label="Rennmaus"
|
||||||
|
>
|
||||||
|
{/* body — sitting upright */}
|
||||||
|
<path d="M40 14c6 0 11 5 11 12 0 4-2 7-2 11 0 10-6 16-15 16-8 0-14-6-14-15 0-13 9-24 20-24z" />
|
||||||
|
{/* ear */}
|
||||||
|
<circle cx="46" cy="15" r="5" />
|
||||||
|
{/* hind paw */}
|
||||||
|
<ellipse cx="24" cy="52" rx="9" ry="3.5" />
|
||||||
|
{/* long curved tail with tuft */}
|
||||||
|
<path d="M16 51c-7 1-13-2-15-9-1-4 0-8 3-10 1 3 1 6 3 8 3 3 7 4 11 4z" />
|
||||||
|
{/* front paw */}
|
||||||
|
<path d="M30 45c3 0 5 1 5 4-3 1-6 1-7-2 0-1 1-2 2-2z" />
|
||||||
|
</svg>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -28,6 +28,7 @@ import { getInbreedingCoefficient } from '../api/pedigree'
|
|||||||
import type { Gender, Gerbil, Litter } from '../api/types'
|
import type { Gender, Gerbil, Litter } from '../api/types'
|
||||||
import { useApi } from '../hooks/useApi'
|
import { useApi } from '../hooks/useApi'
|
||||||
import { formatDate, genderLabel } from '../format/labels'
|
import { formatDate, genderLabel } from '../format/labels'
|
||||||
|
import GerbilIcon from '../components/GerbilIcon'
|
||||||
import { UNKNOWN_FARBSCHLAG, fromDisplayString, genotypeToFarbschlag, toDisplayString } from '../genetics'
|
import { UNKNOWN_FARBSCHLAG, fromDisplayString, genotypeToFarbschlag, toDisplayString } from '../genetics'
|
||||||
import {
|
import {
|
||||||
DEFAULT_GENERATIONS,
|
DEFAULT_GENERATIONS,
|
||||||
@@ -379,7 +380,7 @@ function PedigreeCard({
|
|||||||
const t = de.pages.stammbaum
|
const t = de.pages.stammbaum
|
||||||
const g = node.gerbil
|
const g = node.gerbil
|
||||||
const chip = farbschlag ? chipColorFor(farbschlag) : null
|
const chip = farbschlag ? chipColorFor(farbschlag) : null
|
||||||
const year = g.dateOfBirth ? g.dateOfBirth.slice(0, 4) : null
|
const dob = g.dateOfBirth ? formatDate(g.dateOfBirth) : null
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={isRoot ? 'pedigree-card pedigree-card--root' : 'pedigree-card'}
|
className={isRoot ? 'pedigree-card pedigree-card--root' : 'pedigree-card'}
|
||||||
@@ -389,7 +390,7 @@ function PedigreeCard({
|
|||||||
>
|
>
|
||||||
{/* Foto-Platzhalter — echte Fotos kommen mit FEAT-6. */}
|
{/* Foto-Platzhalter — echte Fotos kommen mit FEAT-6. */}
|
||||||
<div className="pedigree-card__photo" aria-hidden="true">
|
<div className="pedigree-card__photo" aria-hidden="true">
|
||||||
🐭
|
<GerbilIcon size="1.6rem" />
|
||||||
</div>
|
</div>
|
||||||
<div className="pedigree-card__body">
|
<div className="pedigree-card__body">
|
||||||
<div className="pedigree-card__name">
|
<div className="pedigree-card__name">
|
||||||
@@ -406,11 +407,12 @@ function PedigreeCard({
|
|||||||
<span
|
<span
|
||||||
className="pedigree-chip"
|
className="pedigree-chip"
|
||||||
style={chip ? { background: chip.bg, color: chip.fg } : undefined}
|
style={chip ? { background: chip.bg, color: chip.fg } : undefined}
|
||||||
|
title={farbschlag}
|
||||||
>
|
>
|
||||||
{farbschlag}
|
{g.genotype || farbschlag}
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
{year && <span className="pedigree-card__year">* {year}</span>}
|
{dob && <span className="pedigree-card__year">* {dob}</span>}
|
||||||
</div>
|
</div>
|
||||||
{node.expandable && (
|
{node.expandable && (
|
||||||
<button
|
<button
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
import { useMemo } from 'react'
|
import { useCallback, useMemo } from 'react'
|
||||||
import { Link, useParams } from 'react-router-dom'
|
import { Link, useParams } from 'react-router-dom'
|
||||||
import { de } from '../strings/de'
|
import { de } from '../strings/de'
|
||||||
import { getLitter } from '../api/litters'
|
import { getLitter } from '../api/litters'
|
||||||
import { getGerbil, listGerbils } from '../api/gerbils'
|
import { getGerbil, listGerbils } from '../api/gerbils'
|
||||||
|
import { listColorVarieties, listContacts } from '../api/lookups'
|
||||||
import { condition } from '../api/gridify'
|
import { condition } from '../api/gridify'
|
||||||
import { useApi } from '../hooks/useApi'
|
import { useApi } from '../hooks/useApi'
|
||||||
import { formatDate } from '../format/labels'
|
import { formatDate, genderLabel } from '../format/labels'
|
||||||
import { isValidGenotype } from '../format/genotypeText'
|
import { isValidGenotype } from '../format/genotypeText'
|
||||||
import { breed, fromDisplayString, type BreedingResult } from '../genetics'
|
import { breed, fromDisplayString, genotypeToFarbschlag, UNKNOWN_FARBSCHLAG, type BreedingResult } from '../genetics'
|
||||||
import BreedingResultView from '../components/BreedingResultView'
|
import BreedingResultView from '../components/BreedingResultView'
|
||||||
|
|
||||||
export default function WurfDetailPage() {
|
export default function WurfDetailPage() {
|
||||||
@@ -43,6 +44,38 @@ export default function WurfDetailPage() {
|
|||||||
return breed(fromDisplayString(fg), fromDisplayString(mg))
|
return breed(fromDisplayString(fg), fromDisplayString(mg))
|
||||||
}, [father.data, mother.data])
|
}, [father.data, mother.data])
|
||||||
|
|
||||||
|
// Farbschlag + Abnehmer lookups for the juvenile list.
|
||||||
|
const colorVarieties = useApi(() => listColorVarieties(), [])
|
||||||
|
const contacts = useApi(() => listContacts(), [])
|
||||||
|
|
||||||
|
const colorNameById = useMemo(
|
||||||
|
() => new Map((colorVarieties.data ?? []).map((c) => [c.id, c.name])),
|
||||||
|
[colorVarieties.data],
|
||||||
|
)
|
||||||
|
const contactNameById = useMemo(
|
||||||
|
() => new Map((contacts.data ?? []).map((c) => [c.id, c.name])),
|
||||||
|
[contacts.data],
|
||||||
|
)
|
||||||
|
|
||||||
|
const farbschlagOf = useCallback(
|
||||||
|
(g: { colorVarietyId: string | null; genotype: string | null }): string | null => {
|
||||||
|
if (g.colorVarietyId) {
|
||||||
|
const name = colorNameById.get(g.colorVarietyId)
|
||||||
|
if (name) return name
|
||||||
|
}
|
||||||
|
if (g.genotype?.trim()) {
|
||||||
|
try {
|
||||||
|
const name = genotypeToFarbschlag(fromDisplayString(g.genotype))
|
||||||
|
return name === UNKNOWN_FARBSCHLAG ? null : name
|
||||||
|
} catch {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
},
|
||||||
|
[colorNameById],
|
||||||
|
)
|
||||||
|
|
||||||
if (litter.loading) return <p className="muted">{de.common.loading}</p>
|
if (litter.loading) return <p className="muted">{de.common.loading}</p>
|
||||||
if (litter.error || !litter.data) {
|
if (litter.error || !litter.data) {
|
||||||
return (
|
return (
|
||||||
@@ -117,14 +150,24 @@ export default function WurfDetailPage() {
|
|||||||
{!juveniles.loading && registered === 0 && <p className="muted">{t.detail.noJuveniles}</p>}
|
{!juveniles.loading && registered === 0 && <p className="muted">{t.detail.noJuveniles}</p>}
|
||||||
{registered > 0 && (
|
{registered > 0 && (
|
||||||
<ul className="card-list">
|
<ul className="card-list">
|
||||||
{(juveniles.data?.items ?? []).map((g) => (
|
{(juveniles.data?.items ?? []).map((g) => {
|
||||||
|
const farbe = farbschlagOf(g)
|
||||||
|
const receiver = g.receiverContactId ? contactNameById.get(g.receiverContactId) : null
|
||||||
|
const tJf = t.detail.juvenileFields
|
||||||
|
return (
|
||||||
<li key={g.id}>
|
<li key={g.id}>
|
||||||
<Link to={`/rennmaeuse/${g.id}`} className="gerbil-card">
|
<Link to={`/rennmaeuse/${g.id}`} className="gerbil-card">
|
||||||
<span className="gerbil-card__name">{g.name}</span>
|
<span className="gerbil-card__name">{g.name}</span>
|
||||||
<span className="gerbil-card__meta">{de.pages.gerbils.genderLabels[g.gender]}</span>
|
<span className="gerbil-card__meta">{genderLabel(g.gender)}</span>
|
||||||
|
{farbe && <span className="gerbil-card__meta">{tJf.colorVariety}: {farbe}</span>}
|
||||||
|
{g.goHomeDate && <span className="gerbil-card__meta">{tJf.goHomeDate}: {formatDate(g.goHomeDate)}</span>}
|
||||||
|
{receiver && <span className="gerbil-card__meta">{tJf.receiver}: {receiver}</span>}
|
||||||
|
{g.dateOfDeath && <span className="gerbil-card__meta">{tJf.dateOfDeath}: {formatDate(g.dateOfDeath)}</span>}
|
||||||
|
{g.causeOfDeath && <span className="gerbil-card__meta">{tJf.causeOfDeath}: {g.causeOfDeath}</span>}
|
||||||
</Link>
|
</Link>
|
||||||
</li>
|
</li>
|
||||||
))}
|
)
|
||||||
|
})}
|
||||||
</ul>
|
</ul>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|||||||
@@ -285,14 +285,15 @@
|
|||||||
.pedigree-chip {
|
.pedigree-chip {
|
||||||
align-self: flex-start;
|
align-self: flex-start;
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
font-size: 0.68rem;
|
font-size: 0.62rem;
|
||||||
padding: 0.1rem 0.45rem;
|
padding: 0.1rem 0.45rem;
|
||||||
border-radius: 1rem;
|
border-radius: 1rem;
|
||||||
background: var(--color-accent-soft);
|
background: var(--color-accent-soft);
|
||||||
color: var(--color-accent);
|
color: var(--color-accent);
|
||||||
white-space: nowrap;
|
white-space: normal;
|
||||||
|
word-break: break-word;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
line-height: 1.3;
|
||||||
}
|
}
|
||||||
|
|
||||||
.pedigree-card__year {
|
.pedigree-card__year {
|
||||||
|
|||||||
@@ -189,6 +189,14 @@ export const de = {
|
|||||||
edit: 'Bearbeiten',
|
edit: 'Bearbeiten',
|
||||||
back: 'Zurück zur Liste',
|
back: 'Zurück zur Liste',
|
||||||
notFound: 'Dieser Wurf wurde nicht gefunden.',
|
notFound: 'Dieser Wurf wurde nicht gefunden.',
|
||||||
|
// LITTER-JUVENILE-DETAILS: pro-Jungtier-Felder
|
||||||
|
juvenileFields: {
|
||||||
|
colorVariety: 'Farbschlag',
|
||||||
|
goHomeDate: 'Abgegeben',
|
||||||
|
receiver: 'Abnehmer',
|
||||||
|
dateOfDeath: 'Verstorben',
|
||||||
|
causeOfDeath: 'Todesursache',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
// Formular
|
// Formular
|
||||||
form: {
|
form: {
|
||||||
|
|||||||
Reference in New Issue
Block a user