gwoe-antragspruefer/app/templates/v2/components/matrix_mini.html
Dotty Dotter c87b99f778 feat(#177 Phase 13): Matrix-Coloring + Programm-Treue mit Begründung
- **Matrix-Coloring konsistent**: Symbol wird jetzt aus rating
  abgeleitet (rating_symbol-Macro) statt vom LLM übernommen. Bisher
  wurde z.B. rating=4 + symbol="+" geliefert → Template zeigte "+"
  aber mit m-pp-Klasse (kräftiges Grün) → "++/+ wirkten gleichfarbig".
  Stichprobe: 7/30 Assessments hatten rating/symbol-Mismatch.
- **„Antragsteller:in" / „Regierungsfraktion"** als Pill ausgeschrieben
  statt 1-Buchstabe-Badges A/R.
- **Programm-Treue mit Begründung sichtbar**: Wahlprogramm- und
  Parteiprogramm-Begründung als Block direkt unter den Score-Chips.
  Vorher nur Tooltip — auf Mobil schwer zugänglich.
- **„Redline" → „Verbesserungsvorschläge"** in beiden Heading-Pfaden.

Layout-Umstellung (Matrix↔Vote oben, Programm-Treue↔Verbesserung unten)
in #177 als Follow-up — braucht gerichtete Session mit Browser-Vorschau.

Refs: #177

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-06 23:38:01 +02:00

113 lines
4.7 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{#
matrix_mini.html — GWÖ-Matrix 5×5 Minidarstellung
Props:
matrix : Dict mit Schlüsseln A1E5, je Wert ein Dict:
{ "rating": int (-5 bis +5), "symbol": str ("++"|"+"|"○"|""|"") }
Fehlende Felder werden als neutral (○) dargestellt.
Mapping rating → Symbol → Farbklasse (vgl. models.py:MatrixEntry.to_symbol):
rating ≥ 4 → "++" → m-pp (ECG-Grün)
rating 1..3 → "+" → m-p (Grün-Tint)
rating 0 → "○" → m-0 (Weiß)
rating -1..-3→ "" → m-n (Rot-Tint)
rating ≤ -4 → "" → m-nn (Dunkelrot)
Vorher (Bug): Macro mappte nur rating ∈ {-2,-1,0,1,2}, was bei
rating ∈ {3,4,-3,-4,-5} zu inkonsistenter Faerbung fuehrte —
z.B. "+" mit rating=3 → m-0 neutral statt m-p gruen.
Jetzt: Mapping deckt die volle Skala 5..+5 ab.
Verwendung:
{% from "v2/components/matrix_mini.html" import matrix_mini %}
{{ matrix_mini(assessment.matrix) }}
#}
{% macro matrix_mini(matrix) %}
{% set rows = ["A", "B", "C", "D", "E"] %}
{% set cols = ["1", "2", "3", "4", "5"] %}
{% set row_labels = {
"A": "A · Lieferant:innen",
"B": "B · Finanzen",
"C": "C · Verwaltung",
"D": "D · Bürger:innen",
"E": "E · Gesellschaft & Natur"
} %}
{% set row_titles = {
"A": "Berührungsgruppe A — Lieferant:innen, ausgelagerte Betriebe, Dienstleister:innen. Externe Beschaffung und Lieferketten der Kommune.",
"B": "Berührungsgruppe B — Finanzpartner:innen, Geldgeber:innen, Steuerzahler:innen. Umgang mit öffentlichen Mitteln und Haushalt.",
"C": "Berührungsgruppe C — Politische Führung, Verwaltung, Ehrenamtliche. Mandatsträger:innen und Mitarbeitende der Kommune.",
"D": "Berührungsgruppe D — Bürger:innen und Wirtschaft. Wirkung innerhalb der Gemeindegrenzen, Daseinsvorsorge.",
"E": "Berührungsgruppe E — Staat, Gesellschaft und Natur. Wirkung über die Gemeindegrenzen hinaus, Zukunft."
} %}
{% set col_labels = {
"1": "Menschenwürde",
"2": "Solidarität",
"3": "Ökol. Nachhaltigkeit",
"4": "Soz. Gerechtigkeit",
"5": "Transparenz"
} %}
{% set col_titles = {
"1": "Wert 1 — Menschenwürde (Rechtsstaatsprinzip): Werden Grundrechte geschützt? Rechtliche Gleichstellung, Schutz vor Diskriminierung.",
"2": "Wert 2 — Solidarität (Gemeinnutz): Wird das Gemeinwohl gefördert? Mehrwert für die Gemeinschaft, Kooperation statt Konkurrenz.",
"3": "Wert 3 — Ökologische Nachhaltigkeit (Umwelt-Verantwortung): Klimaschutz, Ressourcenschonung, Biodiversität, Kreislaufwirtschaft.",
"4": "Wert 4 — Soziale Gerechtigkeit (Sozialstaatsprinzip): Gerechte Verteilung, Daseinsvorsorge, soziale Absicherung, Chancengleichheit.",
"5": "Wert 5 — Transparenz & Mitbestimmung (Demokratie): Bürgerbeteiligung, Offenlegung, demokratische Prozesse, Rechenschaftspflicht."
} %}
{% macro rating_class(r) %}
{% if r is none or r == 0 %}m-0
{% elif r >= 4 %}m-pp
{% elif r >= 1 %}m-p
{% elif r <= -4 %}m-nn
{% else %}m-n{% endif %}
{% endmacro %}
{# Symbol IMMER aus Rating ableiten — LLM-Outputs sind manchmal
inkonsistent (rating=4 + symbol="+"), was zu „++/+ gleichfarbig"
wirkt. Diese Funktion ist die kanonische Quelle. #}
{% macro rating_symbol(r) -%}
{%- if r is none or r == 0 -%}○
{%- elif r >= 4 -%}++
{%- elif r >= 1 -%}+
{%- elif r <= -4 -%}
{%- else -%}
{%- endif -%}
{%- endmacro %}
<div class="v2-matrix-mini" role="table" aria-label="GWÖ-Matrix 5×5">
{# Header-Zeile #}
<div class="hdr" role="columnheader"></div>
{% for c in cols %}
<div class="hdr" role="columnheader" title="{{ col_titles[c] }}">{{ col_labels[c] }}</div>
{% endfor %}
{# Daten-Zeilen #}
{% for r in rows %}
<div class="rhdr" role="rowheader" title="{{ row_titles[r] }}">{{ row_labels[r] }}</div>
{% for c in cols %}
{% set key = r ~ c %}
{% set cell = matrix[key] if matrix is defined and key in matrix else {} %}
{% set rating = cell.rating | default(0) | int %}
{% set symbol = rating_symbol(rating) | trim %}
<div class="{{ rating_class(rating) | trim }}"
role="cell"
title="{{ key }}: {{ symbol }}"
aria-label="{{ key }}, {{ symbol }}, {% if rating == 2 %}stark fördernd{% elif rating == 1 %}fördernd{% elif rating == 0 %}neutral{% elif rating == -1 %}widersprechend{% else %}stark widersprechend{% endif %}"
onclick="if(typeof v2ShowMatrixFieldInfo==='function')v2ShowMatrixFieldInfo('{{ key }}')"
style="cursor:pointer;">
{{ symbol }}
</div>
{% endfor %}
{% endfor %}
</div>
<div class="v2-matrix-legend" aria-hidden="true">
<span>++ stark fördernd</span>
<span>+ fördernd</span>
<span>○ neutral</span>
<span> widersprechend</span>
<span> stark widerspr.</span>
</div>
{% endmacro %}