{% from "_eroare.html" import card_erori %} {% import '_macros.html' as ui %} {# Detaliu editabil in-place. Fragmentul se swap-uieste in corpul modalului global (#detaliu-modal-body). Heading-ul poarta id-ul folosit de aria-labelledby al dialogului. Operatie + cod RAR rezolvat apar IMPREUNA, read-only, folosind `prez.cod_rar` (fallback „nemapat"), fara eticheta separata „Cod RAR". #} {% set cod_afis = prez.cod_rar if (prez.cod_rar and prez.cod_rar != '—') else 'nemapat' %}
{# === Header — #id + pill + motiv uman === #}

Detaliu trimitere #{{ id }}

{{ stare_text }}
{% if motiv %}

{{ motiv }}

{% elif stare_subtext %}

{{ stare_subtext }}

{% endif %} {# === Bloc eroare blocanta — DOAR in read-only. In editare, cardul 3-niveluri e inlocuit cu: erori per-camp in macro `camp` (text simplu .s-error) + rezumat top-of-form pentru erori fara camp (mai jos). === #} {% if not editabil and erori_3n %}
{{ card_erori(erori_3n) }}
{% endif %} {# === Mapare inline — alege cod RAR pentru operatiile nemapate. Cand nemapate_inline, linia „Operatie: X · nemapat" apare in formularul de mai jos (cod_afis = nemapat), iar aici e picker-ul; dupa mapare, re-render arata codul rezolvat. === #} {% if nemapate_inline %}

Mapeaza codul operatiei

Alege codul RAR pentru fiecare operatie. La salvare, randul se re-rezolva pe loc (si celelalte randuri cu aceeasi operatie).

{% for op in nemapate_inline %} {% set top = op.suggestions[0] if op.suggestions else None %} {% set preselect = top.cod_prestatie if (top and top.score >= 60) else '' %}
{{ op.cod_op_service }} {% if op.denumire and op.denumire != op.cod_op_service %} — {{ op.denumire }} {% endif %}
{% if op.suggestions %}
Sugestii: {% for s in op.suggestions[:3] %} {{ s.cod_prestatie }} ({{ s.score|round|int }}%){% if not loop.last %}, {% endif %} {% endfor %}
{% endif %}
{% endfor %}
{% endif %} {# === Formular editabil (needs_data/needs_mapping) SAU context read-only. Zero dublare: campurile vehiculului apar O SINGURA DATA — editabile cand randul e corectabil, altfel read-only. Operatie + cod RAR read-only deasupra campurilor. === #} {% if editabil %} {% set err_map = {} %} {% for e in corectie_errors %}{% if e.field %}{% set _ = err_map.update({e.field: e.message}) %}{% endif %}{% endfor %} {# fix_map gol pentru Trimiteri (fix-hints vin din preview, nu din corectii de trimitere). #} {% set fix_map = {} %} {# vin_context pentru aria-label cu context VIN (D#6). #} {%- set vin_context = form_vin -%} {# btn_label pentru butonul primar al partial-ului. #} {%- set btn_label = 'Salveaza si retrimite' -%} {% if corectie_msg %}
{{ corectie_msg }}
{% endif %} {# Erori fara camp (field None) nu dispar silentios in editare — cardul 3n e ascuns, deci adaugam un rezumat simplu top-of-form. Erori cu camp raman afisate per-camp de macro-ul `camp` din _form_editare.html. #} {% for e in erori_3n if not e.field %} {% endfor %}
{# Select cod RAR pe stari editabile (needs_data/needs_mapping), cu nomenclator. Read-only pe sent/sending/queued/error (nomenclator_rar gol → ramura else). RAMANE in _trimitere_detaliu.html (D#5 — logica specifica acestui modal). #} {% if nomenclator_rar %}
{% if prez.operatie and prez.operatie != '—' %}
{{ prez.operatie }}
{% endif %}
{% else %} {# Operatie + cod RAR read-only deasupra campurilor (fara eticheta „Cod RAR"). #}
Operatie
{{ prez.operatie }} · {{ cod_afis }}
{% endif %} {# Operatie service (cod intern + denumire venita prin API/import), distinct de operatia RAR mapata. op_service_cod="" cand lipseste → randul absent. RAMANE in _trimitere_detaliu.html (D#5). #} {% if prez.op_service_cod %}
Operatie service
{{ prez.op_service_cod }}{% if prez.op_service_denumire %} — {{ prez.op_service_denumire }}{% endif %}
{% endif %} {# === Campurile vehicul/data/odo + erori/fix + buton — partial DRY (US-005). === #} {% include "_form_editare.html" %}
{% else %} {# Context read-only pentru randuri ne-editabile (sent/sending/queued/error). #}
Numar inmatriculare
{{ prez.vehicul_nr }}
VIN (serie sasiu)
{{ prez.vin }}
Operatie
{{ prez.operatie }} · {{ cod_afis }}
{# Operatie service (cod intern + denumire), distinct de operatia RAR. op_service_cod="" cand lipseste → randul absent (fara "—"). #} {% if prez.op_service_cod %}
Operatie service
{{ prez.op_service_cod }}{% if prez.op_service_denumire %} — {{ prez.op_service_denumire }}{% endif %}
{% endif %}
Data prestatie
{{ prez.data_prestatie }}
Odometru final
{{ prez.odometru }}
{% endif %} {# === Actiuni de jos — primar Re-pune (doar error) + Sterge pe RAND SEPARAT === #} {% if status == 'error' or gestionabil %}
{# Error -> buton primar „Re-pune in coada" pe /repune (error nu e editabil pentru #} {# campuri vehicul, dar se poate schimba cod_prestatie prin acelasi formular). #} {% if status == 'error' %}
{# Select cod_prestatie optional in formularul /repune (doar pentru error). #} {% if nomenclator_rar %} {% endif %}
{% endif %} {# UN SINGUR Sterge, outline distructiv (var(--err)), pe rand separat, full-width pe mobil. #} {% if gestionabil %}
{% endif %}
{% endif %} {# === Detalii tehnice — colapsat implicit === #}
Detalii tehnice
Nr. prezentare RAR
{{ id_prezentare or '—' }}
Cod HTTP RAR
{{ rar_status_code or '—' }}
Reincercari
{{ retry_count }}
Creat
{{ created_at }}
Actualizat
{{ updated_at }}
Urmatoarea incercare
{{ next_attempt_at }}
{% if erori_3n and erori_3n[0].cod %}
Cod eroare (brut)
{{ erori_3n[0].cod }}
{% endif %}
{% if rar_error %}
Mesaj RAR (integral)
{{ rar_error }}
{% endif %}
{# Focus-ul post-swap (incl. re-render corectie/mapare) e gestionat de htmx:afterSettle pe #detaliu-modal-body din base.html. Inchiderea modalului pe succes (queued/sterge) vine din HX-Trigger `inchideModal` emis de rute. #}