diff --git a/frontend/src/lib/api.ts b/frontend/src/lib/api.ts index ccedd5c..d117cb5 100644 --- a/frontend/src/lib/api.ts +++ b/frontend/src/lib/api.ts @@ -68,6 +68,34 @@ export interface VorlageDetail extends VorlageKurz { kette_id: number | null; } +export interface AmpelSchritt { + id: string; + label: string; + aktiv: boolean; + erreicht: boolean; + farbe: string; +} + +export interface AmpelAbzweigung { + id: string; + label: string; + farbe: string; +} + +export interface AmpelData { + strang: string; + strang_label: string; + kontrollfrage: string | null; + schritte: AmpelSchritt[]; + abzweigung: AmpelAbzweigung | null; +} + +export interface AmpelKompakt { + schritt: string; + farbe: string; + ist_abzweigung: boolean; +} + export interface KetteKurz { id: number; ursprung: VorlageKurz | null; @@ -78,6 +106,8 @@ export interface KetteKurz { letzte_aktivitaet: string | null; vertagungen_count: number; glieder_count: number; + strang: string | null; + ampel: AmpelKompakt | null; } export interface KettenGliedOut { @@ -102,6 +132,8 @@ export interface KetteDetail { nodes: GraphNode[]; edges: GraphEdge[]; } | null; + strang: string | null; + ampel: AmpelData | null; } export interface GraphNode { @@ -216,6 +248,17 @@ export const fetchSuchvorschlaege = (q: string) => get<{ items: SuchVorschlag[] }>(`/vorlagen/suggest?q=${encodeURIComponent(q)}`); export const fetchFraktionen = () => get<{ id: number; kuerzel: string; name: string; farbe: string | null; anzahl: number }[]>('/fraktionen'); +export interface AmpelDefinition { + straenge: Record; + abzweigungen: Record; +} + +export const fetchAmpelDefinition = () => get('/ampel/definition'); + export const fetchFraktionDashboard = (kuerzel: string, jahr?: string, periode?: string) => { const p = new URLSearchParams(); if (jahr) p.set('jahr', jahr); diff --git a/frontend/src/lib/components/Ampel.svelte b/frontend/src/lib/components/Ampel.svelte new file mode 100644 index 0000000..08a1c49 --- /dev/null +++ b/frontend/src/lib/components/Ampel.svelte @@ -0,0 +1,177 @@ + + +{#if ampel} + {#if compact} + +
+ {#each ampel.schritte as schritt, i} + {#if i > 0} +
+ {/if} +
+ {/each} + {#if ampel.abzweigung} +
+
+ {/if} +
+ + {:else if vertical} + +
+ {#each ampel.schritte as schritt, i} + {#if i > 0} +
+ {/if} +
+
+ + {schritt.label} + +
+ + {#if ampel.abzweigung && i === abzweigungIndex()} +
+
+
+
+
+ + {ampel.abzweigung.label} + +
+ {/if} + {/each} + {#if ampel.kontrollfrage} +

{ampel.kontrollfrage}

+ {/if} +
+ + {:else} + +
+
+ {#each ampel.schritte as schritt, i} + {#if i > 0} +
+ {/if} +
+
+ + {schritt.label} + +
+ {/each} +
+ + {#if ampel.abzweigung} + {@const idx = abzweigungIndex()} + {#if idx >= 0} + +
+
+
+
+ + {ampel.abzweigung.label} + +
+
+ {/if} + {/if} + {#if ampel.kontrollfrage} +

{ampel.kontrollfrage}

+ {/if} +
+ {/if} +{/if} diff --git a/frontend/src/routes/+layout.svelte b/frontend/src/routes/+layout.svelte index c5d44f1..68ce05e 100644 --- a/frontend/src/routes/+layout.svelte +++ b/frontend/src/routes/+layout.svelte @@ -37,6 +37,7 @@