fix: correct vorlageId casing in startExecution, make checklist rows clickable with alternating backgrounds

This commit is contained in:
Matthias Hochmeister
2026-03-28 17:57:45 +01:00
parent a04de62634
commit b62fd55246
2 changed files with 16 additions and 21 deletions

View File

@@ -20,7 +20,7 @@ import {
IconButton, IconButton,
InputLabel, InputLabel,
List, List,
ListItem, ListItemButton,
ListItemText, ListItemText,
MenuItem, MenuItem,
Paper, Paper,
@@ -262,27 +262,21 @@ function OverviewTab({ overview, loading, canExecute, navigate }: OverviewTabPro
return <Alert severity="info" sx={{ mt: 1 }}>Keine Checklisten zugewiesen</Alert>; return <Alert severity="info" sx={{ mt: 1 }}>Keine Checklisten zugewiesen</Alert>;
} }
const renderChecklistRow = (cl: ChecklistOverviewChecklist, itemId: string, type: 'fahrzeug' | 'ausruestung') => { const renderChecklistRow = (cl: ChecklistOverviewChecklist, itemId: string, type: 'fahrzeug' | 'ausruestung', index: number) => {
const color = getDueColor(cl.next_due, cl.intervall); const color = getDueColor(cl.next_due, cl.intervall);
const label = getDueLabel(cl.next_due, cl.intervall); const label = getDueLabel(cl.next_due, cl.intervall);
const param = type === 'fahrzeug' ? `fahrzeug=${itemId}` : `ausruestung=${itemId}`; const param = type === 'fahrzeug' ? `fahrzeug=${itemId}` : `ausruestung=${itemId}`;
return ( return (
<ListItem <ListItemButton
key={cl.vorlage_id} key={cl.vorlage_id}
sx={{ py: 0.5, px: 1 }} onClick={() => canExecute && navigate(`/checklisten/ausfuehrung/new?${param}&vorlage=${cl.vorlage_id}`)}
secondaryAction={ sx={{
canExecute ? ( py: 0.75,
<Tooltip title="Checkliste starten"> px: 2,
<IconButton bgcolor: index % 2 === 0 ? 'action.hover' : 'transparent',
size="small" cursor: canExecute ? 'pointer' : 'default',
color="primary" '&:hover': canExecute ? undefined : { bgcolor: index % 2 === 0 ? 'action.hover' : 'transparent' },
onClick={() => navigate(`/checklisten/ausfuehrung/new?${param}&vorlage=${cl.vorlage_id}`)} }}
>
<PlayArrow fontSize="small" />
</IconButton>
</Tooltip>
) : undefined
}
> >
<ListItemText <ListItemText
primary={cl.vorlage_name} primary={cl.vorlage_name}
@@ -293,9 +287,10 @@ function OverviewTab({ overview, loading, canExecute, navigate }: OverviewTabPro
color={color} color={color}
size="small" size="small"
variant="outlined" variant="outlined"
sx={{ mr: canExecute ? 4 : 0, ml: 1 }} sx={{ ml: 1, pointerEvents: 'none' }}
/> />
</ListItem> {canExecute && <PlayArrow fontSize="small" color="action" sx={{ ml: 1, opacity: 0.5 }} />}
</ListItemButton>
); );
}; };
@@ -329,7 +324,7 @@ function OverviewTab({ overview, loading, canExecute, navigate }: OverviewTabPro
</AccordionSummary> </AccordionSummary>
<AccordionDetails sx={{ p: 0 }}> <AccordionDetails sx={{ p: 0 }}>
<List dense disablePadding> <List dense disablePadding>
{item.checklists.map((cl) => renderChecklistRow(cl, item.id, type))} {item.checklists.map((cl, idx) => renderChecklistRow(cl, item.id, type, idx))}
</List> </List>
</AccordionDetails> </AccordionDetails>
</Accordion> </Accordion>

View File

@@ -127,7 +127,7 @@ export const checklistenApi = {
// ── Executions ── // ── Executions ──
startExecution: async (vorlageId: number, opts: { fahrzeugId?: string; ausruestungId?: string }): Promise<ChecklistAusfuehrung> => { startExecution: async (vorlageId: number, opts: { fahrzeugId?: string; ausruestungId?: string }): Promise<ChecklistAusfuehrung> => {
const r = await api.post('/api/checklisten/ausfuehrungen', { const r = await api.post('/api/checklisten/ausfuehrungen', {
vorlage_id: vorlageId, vorlageId: vorlageId,
fahrzeugId: opts.fahrzeugId, fahrzeugId: opts.fahrzeugId,
ausruestungId: opts.ausruestungId, ausruestungId: opts.ausruestungId,
}); });