feat(web): editare celule in preview + Acasa unificata (PRD 3.6)
Implementeaza PRD 3.6 (US-001..007), pe canalul de import + stratul web;
worker / masina stari / idempotenta / mapare raman neatinse.
- US-003/004: tab-ul "Trimiteri" eliminat; Trimiterile devin sectiune
permanenta sub upload pe Acasa ("Trimiterile tale"); upload comprimat la
bara slim (hero pastrat la first-run); ?tab=coada si /_fragments/coada
servesc Acasa (fara fragment orfan); poll gated pe visibilityState.
- US-001: coloana noua import_rows.override_json (nullable, Fernet, Approach B)
+ _migrate defensiv; ruta v1 + alias web .../rand/{i}/editeaza aplica patch
canonic ULTIMUL in _resolve_row_for_preview si commit_import (mutatie pura,
status rederivat, fara drift). Scoping JOIN -> 404, guard committed -> 409,
semantica empty=clear, decrypt fail -> no-op.
- US-002: buton "Editeaza" pe rand; swap pe <tr> + OOB contoare (nu pe sectiune);
form propriu (confirm dezactivat la editare); refoloseste grila responsiva +
error-map din _trimitere_detaliu.html; mutual-exclusion intre randuri.
- US-005/006: "De rezolvat", "Operatii salvate" si "Formate de coloane" ca
tabele (.tablewrap); H4: comutatorul reflecta auto_send STOCAT.
- US-007: bifa "auto-send" devine comutator etichetat pe COADA ("Pune automat
in coada" / "Tine pentru verificare"), scoped pe operatie; name="auto_send"
pastrat (semantica de prezenta -> bool corect cu ambele parsere, zero backend).
Fix-uri gasite la verificarea E2E in browser (htmx 1.9.12, JS — invizibile la
TestClient): useTemplateFragments=true (raspuns <tr>+OOB era parsat in context
de tabel -> swapError + contoare pierdute); re-activarea confirm-btn dupa salvare
deferita pe tick (evita editing=true tranzitoriu); n-hint actualizat de updateN.
Teste: 523 passed. E2E browser: Acasa unificata, upload slim, editare rand
(needs_data -> ok, swap pe rand, contoare OOB), Mapari tabelar + comutator.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
{% import '_macros.html' as ui %}
|
||||
<div id="import-section">
|
||||
{% set pas = 3 %}{% include '_stepper.html' %}
|
||||
<div class="card">
|
||||
@@ -16,16 +17,16 @@
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<!-- Rezumat stari -->
|
||||
<div style="display:flex; gap:8px; flex-wrap:wrap; margin-bottom:12px;">
|
||||
{% set status_labels = [
|
||||
('ok', 'gata de trimis'),
|
||||
('needs_review', 'verifica valori'),
|
||||
('needs_mapping', 'fara cod RAR'),
|
||||
('needs_data', 'date lipsa'),
|
||||
('already_sent', 'deja trimis'),
|
||||
('duplicate_in_file','dublicat in fisier'),
|
||||
] %}
|
||||
<!-- Rezumat stari (id stabil pentru OOB swap dupa editarea unui rand — US-002) -->
|
||||
{% set status_labels = [
|
||||
('ok', 'gata de trimis'),
|
||||
('needs_review', 'verifica valori'),
|
||||
('needs_mapping', 'fara cod RAR'),
|
||||
('needs_data', 'date lipsa'),
|
||||
('already_sent', 'deja trimis'),
|
||||
('duplicate_in_file','dublicat in fisier'),
|
||||
] %}
|
||||
<div id="preview-rezumat" 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 %}
|
||||
@@ -96,7 +97,7 @@
|
||||
</select>
|
||||
</div>
|
||||
<div class="mapcol">
|
||||
<label class="chk"><input type="checkbox" name="auto_send" value="true" checked> auto-send</label>
|
||||
{{ ui.autosend_toggle(checked=True) }}
|
||||
</div>
|
||||
<div class="mapcol">
|
||||
<button type="submit" style="min-height:44px;">Salveaza</button>
|
||||
@@ -106,85 +107,39 @@
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<!-- Tabel preview + bara confirmare (un singur form) -->
|
||||
<!-- Tabel preview. Randurile au FORM PROPRIU pentru editare (NU sunt in #confirm-form,
|
||||
altfel Enter intr-un camp ar declansa trimiterea ireversibila — D-3.3). Bifele
|
||||
needs_review se asociaza la #confirm-form prin atributul form=. -->
|
||||
<div class="tablewrap">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>VIN</th>
|
||||
<th>Nr. Inm.</th>
|
||||
<th>Data</th>
|
||||
<th>KM final</th>
|
||||
<th>Operatie</th>
|
||||
<th>Stare</th>
|
||||
<th>Note</th>
|
||||
<th>Verificat?</th>
|
||||
<th>Actiuni</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for row in rows %}
|
||||
{% include '_preview_rand.html' %}
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- Bara confirmare (sticky jos) — singurul formular care trimite la RAR -->
|
||||
<form id="confirm-form"
|
||||
hx-post="/_import/{{ import_id }}/confirma"
|
||||
hx-target="#import-section"
|
||||
hx-swap="outerHTML">
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token or '' }}">
|
||||
|
||||
<div class="tablewrap">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>VIN</th>
|
||||
<th>Nr. Inm.</th>
|
||||
<th>Data</th>
|
||||
<th>KM final</th>
|
||||
<th>Operatie</th>
|
||||
<th>Stare</th>
|
||||
<th>Note</th>
|
||||
<th>Verificat?</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for row in rows %}
|
||||
{%- set res = row.resolved -%}
|
||||
{%- set status = row.resolved_status -%}
|
||||
{%- set prestatii = res.get('prestatii') or [] -%}
|
||||
{%- set op = (prestatii[0].get('cod_prestatie') or prestatii[0].get('cod_op_service', '')) if prestatii else '' -%}
|
||||
<tr data-status="{{ status }}"
|
||||
style="{% if status == 'needs_review' %}background:rgba(230,179,74,.04);{% elif status in ('already_sent', 'duplicate_in_file') %}opacity:.65;{% endif %}">
|
||||
<td class="muted">{{ row.row_index + 1 }}</td>
|
||||
<td>{{ res.get('vin') or '<span class="muted">—</span>' | safe }}</td>
|
||||
<td>{{ res.get('nr_inmatriculare') or '' }}</td>
|
||||
<td>{{ res.get('data_prestatie') or '' }}</td>
|
||||
<td>{{ res.get('odometru_final') or '' }}</td>
|
||||
<td>{{ op or '<span class="muted">—</span>' | safe }}</td>
|
||||
<td>
|
||||
<span class="pill s-{{ status }}">{{ status }}</span>
|
||||
</td>
|
||||
<td class="muted" style="font-size:12px; white-space:normal; max-width:220px;">
|
||||
{% 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 %}
|
||||
{% elif row.flags %}
|
||||
{{ row.flags[0] }}
|
||||
{% elif row.errors %}
|
||||
{# US-008: arata MOTIVUL (mesajul de validare), nu numele campului #}
|
||||
{%- for e in row.errors -%}
|
||||
{%- if e is mapping -%}
|
||||
{{ e.get('message') or e.get('msg') or (e.values() | list | first) }}
|
||||
{%- else -%}
|
||||
{{ e }}
|
||||
{%- endif -%}
|
||||
{%- if not loop.last %}; {% endif -%}
|
||||
{%- endfor -%}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td style="text-align:center;">
|
||||
{% if status == 'needs_review' %}
|
||||
<label class="chk" style="min-height:44px; justify-content:center; cursor:pointer;"
|
||||
title="Bifat inseamna ca ai verificat valorile si le incluzi in trimitere">
|
||||
<input type="checkbox" name="reviewed_rows" value="{{ row.row_index }}"
|
||||
onchange="updateN()"
|
||||
aria-label="Verificat — randul {{ row.row_index + 1 }} (VIN: {{ res.get('vin', '') }})">
|
||||
verif.
|
||||
</label>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- Bara confirmare (sticky jos) -->
|
||||
<div class="sticky-bar">
|
||||
<div style="flex:1; min-width:280px;">
|
||||
<!-- Banner declarant (D12) — direct deasupra input-ului N -->
|
||||
@@ -207,7 +162,7 @@
|
||||
style="max-width:80px;"
|
||||
aria-describedby="n-hint">
|
||||
<span id="n-hint" class="muted" style="font-size:12px; margin-left:6px;">
|
||||
({{ summary.get('ok', 0) }} ok
|
||||
(<span id="n-hint-ok">{{ summary.get('ok', 0) }}</span> ok
|
||||
{% if summary.get('needs_review', 0) %}
|
||||
+ pana la {{ summary.get('needs_review', 0) }} verificate manual
|
||||
{% endif %})
|
||||
@@ -241,9 +196,12 @@
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
<!-- Contor "gata de trimis" citit din DOM (data-ok), ca OOB swap-ul de la editare
|
||||
sa actualizeze N fara a re-randa sectiunea (US-002). -->
|
||||
<span id="preview-ok-count" data-ok="{{ summary.get('ok', 0) }}" hidden></span>
|
||||
|
||||
<div style="padding:8px 0 4px;">
|
||||
<a href="#" class="muted" style="font-size:13px;"
|
||||
hx-get="/_import/reset" hx-target="#import-section" hx-swap="outerHTML">Incarca alt fisier</a>
|
||||
@@ -254,18 +212,32 @@
|
||||
|
||||
<script>
|
||||
(function() {
|
||||
var nOk = {{ summary.get('ok', 0) | int }};
|
||||
/* D-1.2: un singur sticky bar pe ecran — cat preview-ul de import e activ,
|
||||
ascunde sectiunea Trimiteri de pe Acasa (se reveleaza la reset/commit din _upload.html). */
|
||||
var trim = document.getElementById('trimiteri-section');
|
||||
if (trim) trim.style.display = 'none';
|
||||
|
||||
/* Actualizeaza N si bannerul cand se bifeaza needs_review */
|
||||
/* nOk se citeste din DOM (#preview-ok-count[data-ok]) ca OOB swap-ul de la editare
|
||||
sa-l poata actualiza fara re-randarea sectiunii (D-3.1/D-3.4). */
|
||||
function getOk() {
|
||||
var el = document.getElementById('preview-ok-count');
|
||||
return el ? parseInt(el.dataset.ok || '0', 10) : 0;
|
||||
}
|
||||
|
||||
/* Actualizeaza N si bannerul cand se bifeaza needs_review SAU cand se editeaza un rand. */
|
||||
function updateN() {
|
||||
var checked = document.querySelectorAll('input[name="reviewed_rows"]:checked').length;
|
||||
var total = nOk + checked;
|
||||
var total = getOk() + checked;
|
||||
var inp = document.getElementById('n-confirmat');
|
||||
var disp = document.getElementById('n-display');
|
||||
var btn = document.getElementById('confirm-btn');
|
||||
/* Nu re-activa confirm cat un rand e in editare (mutual-exclusion D-3.2). */
|
||||
var editing = document.querySelector('tr[data-editing="1"]') !== null;
|
||||
if (inp) inp.value = total;
|
||||
if (disp) disp.textContent = total;
|
||||
if (btn) btn.disabled = (total === 0);
|
||||
var hintOk = document.getElementById('n-hint-ok');
|
||||
if (hintOk) hintOk.textContent = getOk();
|
||||
if (btn) btn.disabled = (total === 0) || editing;
|
||||
}
|
||||
|
||||
/* Filtrare randuri dupa stare */
|
||||
@@ -281,15 +253,12 @@
|
||||
});
|
||||
}
|
||||
|
||||
/* Expune functiile global pentru onclick inline */
|
||||
/* Expune functiile global pentru onclick/hx-on inline si OOB swap */
|
||||
window.updateN = updateN;
|
||||
window.filterRows = filterRows;
|
||||
|
||||
/* Filtru implicit "Toate" activ la incarcare */
|
||||
filterRows('all');
|
||||
|
||||
/* Focus pe campul N la deschidere (a11y — D12) */
|
||||
var ni = document.getElementById('n-confirmat');
|
||||
if (ni) { ni.focus(); ni.select(); }
|
||||
updateN();
|
||||
})();
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user