labels.py: ETICHETE_ENV + eticheta_env(env)->(text,css). Productie afisata
"PRODUCȚIE" (majuscule+diacritice) cu badge fill de atentie (--err), Testare
outline discret muted — semnalizare risc L.142 (declaratie reala ireversibila).
Clase .env-badge-prod / .env-badge-test in base.html; eticheta_env expus ca
global Jinja.
Badge de mediu per rand in _submissions, _coada implicit prin view, _preview_rand,
_trimitere_detaliu, _jurnal. Statusbar (_status.html) aliniat la aceeasi conventie
(Productie = atentie, nu verde) — inlocuieste culorile ad-hoc din US-011, toggle
neatins.
rar_env in exportul de audit (AUDIT_COLUMNS + _audit_rows) si ecou in
GET /v1/prezentari(/{id}). _submission_row_view/_detaliu_ctx/fragment_submissions
duc rar_env pana in template.
tests/test_badge_rar_env.py: badge in lista, audit contine rar_env, GET ecou rar_env.
test_statusbar_env: asertie aliniata la eticheta PRODUCȚIE.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
117 lines
6.5 KiB
HTML
117 lines
6.5 KiB
HTML
{#
|
|
_preview_rand.html — un singur rand de preview import.
|
|
US-006 (PRD 5.12): editarea inline (tr.preview-edit + mutual-exclusion script)
|
|
a fost eliminata. Butonul Editeaza deschide MODALUL global (#detaliu-modal-body).
|
|
|
|
Parametri:
|
|
editing — ELIMINAT (ignorat, pastrat pentru compatibilitate apeluri vechi)
|
|
include_oob — True: randeaza OOB rezumat + contor + script recalc (swap dupa save)
|
|
oob_tr — True: adauga hx-swap-oob pe <tr> insusi (pentru raspunsul POST succes)
|
|
summary — dict cu contoarele per status
|
|
|
|
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 -%}
|
|
{%- set _sent_dup = status in ('already_sent', 'duplicate_in_file') -%}
|
|
<tr id="preview-row-{{ row.row_index }}" data-status="{{ status }}"
|
|
{% if _sent_dup %}class="preview-sent-row"{% endif %}
|
|
{% if oob_tr %}hx-swap-oob="outerHTML:#preview-row-{{ row.row_index }}"{% endif %}
|
|
style="{% if status == 'needs_review' %}background:rgba(230,179,74,.04);{% elif _sent_dup %}opacity:.6;{% endif %}">
|
|
{#- Motivul (validare / deja-trimis / duplicat) — fost coloana Note, acum tooltip pe pill.
|
|
KM final iese din tabel (se editeaza in modal). -#}
|
|
{%- if status == 'already_sent' and row.get('already_sent_info') -%}
|
|
{%- set ai = row.already_sent_info -%}
|
|
{%- set _nota = 'deja trimis ' ~ ((ai.get('created_at') or '')[:10]) ~ ((' (#' ~ ai.id_prezentare ~ ')') if ai.get('id_prezentare') else '') -%}
|
|
{%- elif status == 'duplicate_in_file' and row.get('duplicate_with') -%}
|
|
{%- set _dwith = [] -%}
|
|
{%- for idx in row.duplicate_with -%}{{ _dwith.append(idx + 1) or '' }}{%- endfor -%}
|
|
{%- set _nota = 'dubla cu randul ' ~ (_dwith | join(', ')) -%}
|
|
{%- else -%}
|
|
{%- set _nota = row.nota_umana or '' -%}
|
|
{%- endif -%}
|
|
<td class="col-stare" data-eticheta="Stare">
|
|
<span class="pill {{ row.stare_css }}" style="display:inline-flex; align-items:center; gap:5px;"
|
|
{% if _nota %}title="{{ _nota }}"{% endif %}>
|
|
<span aria-hidden="true" style="display:inline-block; width:7px; height:7px; border-radius:99px; background:currentColor; flex-shrink:0;"></span>{{ row.stare_eticheta }}</span>
|
|
{# Badge mediu RAR (US-010 PRD 5.20) — rar_env disponibil din contextul batch-ului. #}
|
|
{% if rar_env | default('') %}
|
|
{% set _eb = eticheta_env(rar_env) %}
|
|
<div style="margin-top:3px;"><span class="{{ _eb[1] }}">{{ _eb[0] }}</span></div>
|
|
{% endif %}
|
|
</td>
|
|
<td class="col-vehicul" data-eticheta="Vehicul">
|
|
{{ row.prez.vehicul_nr }}
|
|
{% if row.prez.vin_scurt and row.prez.vin_scurt != '—' %}
|
|
<div class="muted" style="font-size:12px; white-space:nowrap;">{{ row.prez.vin_scurt }}</div>
|
|
{% endif %}
|
|
</td>
|
|
<td class="col-operatie" data-eticheta="Operatie">
|
|
<div>{{ row.prez.operatie }}</div>
|
|
{% if row.prez.cod_rar and row.prez.cod_rar != '—' %}
|
|
<div class="cod-rar-sub"><span class="cod-rar-cod">{{ row.prez.cod_rar }}</span></div>
|
|
{% else %}
|
|
<div class="muted cod-rar-sub">nemapat</div>
|
|
{% endif %}
|
|
</td>
|
|
<td class="col-data" data-eticheta="Data prestatie">{{ row.prez.data_prestatie }}</td>
|
|
<td class="col-actiuni" data-eticheta="Actiuni" style="text-align:center;">
|
|
{% if status not in ('already_sent', 'duplicate_in_file') %}
|
|
<button type="button" class="btn-editeaza"
|
|
style="min-height:36px; padding:6px 14px; font-size:13px;
|
|
background:transparent; border-color:var(--line); color:var(--ink);"
|
|
hx-get="/_import/{{ import_id }}/rand/{{ row.row_index }}/editare-modal"
|
|
hx-target="#detaliu-modal-body" hx-swap="innerHTML"
|
|
aria-label="Editeaza randul {{ row.row_index + 1 }} (VIN: {{ res.get('vin', '') }})">
|
|
Editeaza
|
|
</button>
|
|
{% endif %}
|
|
</td>
|
|
</tr>
|
|
{% if include_oob %}
|
|
{# OOB: actualizeaza rezumatul, contorul, bannerul needs_review dupa save/confirma-review. #}
|
|
{% 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')] %}
|
|
<div id="preview-rezumat" hx-swap-oob="true"
|
|
style="display:flex; gap:8px; flex-wrap:wrap; margin-bottom:12px;">
|
|
{% for status_key, label in status_labels %}
|
|
{%- set cnt = summary.get(status_key, 0) -%}
|
|
{% if cnt > 0 %}<span class="pill s-{{ status_key }}" style="display:inline-flex; align-items:center; gap:5px; font-size:var(--fs-xs);"><span aria-hidden="true" style="display:inline-block; width:7px; height:7px; border-radius:99px; background:currentColor; flex-shrink:0;"></span>{{ cnt }} {{ label | lower }}</span>{% endif %}
|
|
{% endfor %}
|
|
</div>
|
|
<span id="preview-ok-count" hx-swap-oob="true" data-ok="{{ summary.get('ok', 0) }}" hidden></span>
|
|
{# Banner discoverability: OOB swap dupa confirmare/editare → dispare cand needs_review==0. #}
|
|
<div id="preview-needs-review-banner" hx-swap-oob="true">
|
|
{% if summary.get('needs_review', 0) %}
|
|
<div class="banner warn" role="note" aria-live="polite"
|
|
style="margin-bottom:12px; padding:8px 14px; border-radius:6px;
|
|
background:color-mix(in srgb, var(--warn, #e6b34a) 12%, var(--card));
|
|
border:1px solid var(--warn, #e6b34a); font-size:13px;">
|
|
Randurile cu <span class="pill s-needs_review" style="font-size:11px;">Verifica valori</span>
|
|
nu pleaca la RAR pana le deschizi in modal si confirmi in modal
|
|
cu butonul <strong>Confirma valorile</strong>.
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
<script>
|
|
(function() {
|
|
/* Editare incheiata: re-activeaza confirm + butoanele Editeaza, recalculeaza N.
|
|
Defer pe tick-ul urmator: la momentul rularii scriptului, swap-ul randului poate
|
|
sa nu se fi asezat inca, deci tr[data-editing] ar fi inca prezent si updateN ar
|
|
lasa confirm dezactivat (editing=true). Dupa setTimeout(0) randul e in mod display. */
|
|
setTimeout(function() {
|
|
document.querySelectorAll('.btn-editeaza').forEach(function(b) { b.disabled = false; });
|
|
var btn = document.getElementById('confirm-btn');
|
|
if (btn) btn.title = '';
|
|
if (window.updateN) window.updateN();
|
|
}, 0);
|
|
})();
|
|
</script>
|
|
{% endif %}
|