{# _preview_rand.html — un singur rand de preview import. Doua moduri: - display (editing falsy): normal cu 9 coloane in format .tabel-trimiteri. - edit (editing truthy): (display:block) cu un singur ce contine un FORM PROPRIU (NU #confirm-form). Escapa grila table-layout:fixed. Swap pe RAND (hx-target pe #preview-row-N, outerHTML), NU pe #import-section. La save, optional OOB pe rezumat + contor "gata de trimis" (include_oob). Campuri pre-computate de _web_compute_preview (NOT din template raw): row.prez — prezentare_din_payload(resolved): vehicul_nr, vin_scurt, operatie, cod_rar, data_prestatie, odometru row.stare_eticheta — text uman (ex. "Gata de trimis"), din STARI_PREVIEW row.stare_css — clasa CSS (ex. "s-ok"), din STARI_PREVIEW row.nota_umana — mesaj uman formatat pentru coloana Note (fara repr Python) #} {%- set res = row.resolved -%} {%- set status = row.resolved_status -%} {% if editing %} {%- set err_map = {} -%} {%- set fix_map = {} -%} {%- for e in row.errors -%}{%- if e is mapping and e.get('field') -%}{%- set _ = err_map.update({e.field: (e.get('message') or e.get('msg'))}) -%}{%- if e.get('fix') -%}{%- set _ = fix_map.update({e.field: e.get('fix')}) -%}{%- endif -%}{%- endif -%}{%- endfor -%}
Editare rand {{ row.row_index + 1 }} {{ row.stare_eticheta }}
{% if message %} {% endif %} {% macro camp(nume, eticheta, valoare, tip='text') %}
{% if err_map.get(nume) %}
{{ err_map.get(nume) }}
{% endif %} {% if fix_map.get(nume) %} {{ fix_map.get(nume) }} {% endif %}
{% endmacro %}
{{ camp('nr_inmatriculare', 'Numar inmatriculare', res.get('nr_inmatriculare')) }} {{ camp('vin', 'VIN (serie sasiu)', res.get('vin')) }} {{ camp('data_prestatie', 'Data prestatie (YYYY-MM-DD)', res.get('data_prestatie')) }} {{ camp('odometru_final', 'Odometru final', res.get('odometru_final')) }} {{ camp('odometru_initial', 'Odometru initial (daca e cerut)', res.get('odometru_initial')) }}
se salveaza…
{% else %} {%- set disp_fix_map = {} -%} {%- for e in row.errors -%}{%- if e is mapping and e.get('field') and e.get('fix') -%}{%- set _ = disp_fix_map.update({e.field: e.get('fix')}) -%}{%- endif -%}{%- endfor -%} {{ row.row_index + 1 }} {{ row.stare_eticheta }} {{ row.prez.vehicul_nr }} {% if row.prez.vin_scurt and row.prez.vin_scurt != '—' %}
{{ row.prez.vin_scurt }}
{% endif %} {# Fix-uri de validare pe vehicul #} {% if disp_fix_map.get('vin') %}{{ disp_fix_map.get('vin') }}{% endif %} {% if disp_fix_map.get('nr_inmatriculare') %}{{ disp_fix_map.get('nr_inmatriculare') }}{% endif %}
{{ row.prez.operatie }}
{% if row.prez.cod_rar and row.prez.cod_rar != '—' %}
{{ row.prez.cod_rar }}
{% else %}
nemapat
{% endif %} {{ row.prez.data_prestatie }} {% if disp_fix_map.get('data_prestatie') %}{{ disp_fix_map.get('data_prestatie') }}{% endif %} {{ row.prez.odometru }} {% if disp_fix_map.get('odometru_final') %}{{ disp_fix_map.get('odometru_final') }}{% endif %} {% if status == 'already_sent' and row.get('already_sent_info') %} {% set ai = row.already_sent_info %} deja trimis {{ (ai.get('created_at') or '')[:10] }} {% if ai.get('id_prezentare') %}(#{{ ai.id_prezentare }}){% endif %} {% elif status == 'duplicate_in_file' and row.get('duplicate_with') %} dubla cu randul {% for idx in row.duplicate_with %}{{ idx + 1 }}{% if not loop.last %}, {% endif %}{% endfor %} {% else %} {{ row.nota_umana or '' }} {% endif %} {% if status == 'needs_review' %} {% endif %} {% if status not in ('already_sent', 'duplicate_in_file') %} {% endif %} {% if include_oob %} {# OOB: actualizeaza rezumatul si contorul "gata de trimis" dupa save, fara a re-randa sectiunea. #} {% set status_labels = [ ('ok','Gata de trimis'), ('needs_review','Verifica valori'), ('needs_mapping','Cod RAR lipsa'), ('needs_data','Date incomplete'), ('already_sent','Deja trimis'), ('duplicate_in_file','Duplicat in fisier')] %}
{% for status_key, label in status_labels %} {%- set cnt = summary.get(status_key, 0) -%} {% if cnt > 0 %}{{ cnt }} {{ label | lower }}{% endif %} {% endfor %}
{% endif %} {% endif %}