fix: repair checklist create (intervall constraint) and start execution (stuck spinner), add equipment items display
This commit is contained in:
@@ -0,0 +1,10 @@
|
|||||||
|
-- Migration 072: Fix checklist_vorlagen intervall CHECK constraint
|
||||||
|
-- The original constraint in 068 was missing 'quarterly' and 'halfyearly'.
|
||||||
|
-- These values are used in the frontend and service but were rejected by the DB.
|
||||||
|
|
||||||
|
ALTER TABLE checklist_vorlagen
|
||||||
|
DROP CONSTRAINT IF EXISTS checklist_vorlagen_intervall_check;
|
||||||
|
|
||||||
|
ALTER TABLE checklist_vorlagen
|
||||||
|
ADD CONSTRAINT checklist_vorlagen_intervall_check
|
||||||
|
CHECK (intervall IN ('weekly', 'monthly', 'quarterly', 'halfyearly', 'yearly', 'custom'));
|
||||||
@@ -126,7 +126,7 @@ export default function ChecklistAusfuehrung() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// ── Loading states ──
|
// ── Loading states ──
|
||||||
if (isNew || startingExecution) {
|
if (isNew) {
|
||||||
return (
|
return (
|
||||||
<DashboardLayout>
|
<DashboardLayout>
|
||||||
<Box sx={{ display: 'flex', justifyContent: 'center', py: 8 }}><CircularProgress /></Box>
|
<Box sx={{ display: 'flex', justifyContent: 'center', py: 8 }}><CircularProgress /></Box>
|
||||||
@@ -155,6 +155,7 @@ export default function ChecklistAusfuehrung() {
|
|||||||
const items = execution.items ?? [];
|
const items = execution.items ?? [];
|
||||||
const vorlageItems = items.filter((i) => i.vorlage_item_id != null);
|
const vorlageItems = items.filter((i) => i.vorlage_item_id != null);
|
||||||
const vehicleItems = items.filter((i) => i.fahrzeug_item_id != null);
|
const vehicleItems = items.filter((i) => i.fahrzeug_item_id != null);
|
||||||
|
const equipmentItems = items.filter((i) => i.ausruestung_item_id != null);
|
||||||
|
|
||||||
const renderItemGroup = (groupItems: ChecklistAusfuehrungItem[], title: string) => {
|
const renderItemGroup = (groupItems: ChecklistAusfuehrungItem[], title: string) => {
|
||||||
if (groupItems.length === 0) return null;
|
if (groupItems.length === 0) return null;
|
||||||
@@ -223,7 +224,7 @@ export default function ChecklistAusfuehrung() {
|
|||||||
{execution.vorlage_name ?? 'Checkliste'}
|
{execution.vorlage_name ?? 'Checkliste'}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography variant="subtitle1" color="text.secondary">
|
<Typography variant="subtitle1" color="text.secondary">
|
||||||
{execution.fahrzeug_name ?? '–'} · {formatDate(execution.ausgefuehrt_am ?? execution.created_at)}
|
{execution.fahrzeug_name ?? execution.ausruestung_name ?? '–'} · {formatDate(execution.ausgefuehrt_am ?? execution.created_at)}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
<Chip
|
<Chip
|
||||||
@@ -243,6 +244,8 @@ export default function ChecklistAusfuehrung() {
|
|||||||
{renderItemGroup(vorlageItems, 'Vorlage-Items')}
|
{renderItemGroup(vorlageItems, 'Vorlage-Items')}
|
||||||
{vorlageItems.length > 0 && vehicleItems.length > 0 && <Divider sx={{ my: 2 }} />}
|
{vorlageItems.length > 0 && vehicleItems.length > 0 && <Divider sx={{ my: 2 }} />}
|
||||||
{renderItemGroup(vehicleItems, 'Fahrzeugspezifische Items')}
|
{renderItemGroup(vehicleItems, 'Fahrzeugspezifische Items')}
|
||||||
|
{(vorlageItems.length > 0 || vehicleItems.length > 0) && equipmentItems.length > 0 && <Divider sx={{ my: 2 }} />}
|
||||||
|
{renderItemGroup(equipmentItems, 'Ausrüstungsspezifische Items')}
|
||||||
|
|
||||||
{items.length === 0 && (
|
{items.length === 0 && (
|
||||||
<Typography color="text.secondary">Keine Items in dieser Checkliste.</Typography>
|
<Typography color="text.secondary">Keine Items in dieser Checkliste.</Typography>
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ export interface ChecklistAusfuehrungItem {
|
|||||||
ausfuehrung_id: string;
|
ausfuehrung_id: string;
|
||||||
vorlage_item_id?: number;
|
vorlage_item_id?: number;
|
||||||
fahrzeug_item_id?: number;
|
fahrzeug_item_id?: number;
|
||||||
|
ausruestung_item_id?: number;
|
||||||
bezeichnung: string;
|
bezeichnung: string;
|
||||||
ergebnis?: 'ok' | 'nok' | 'na';
|
ergebnis?: 'ok' | 'nok' | 'na';
|
||||||
kommentar?: string;
|
kommentar?: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user