fix(ui): fix set pct badge logic and compact CODMAT form layout

- Fix is_complete check: use abs(pct-100)<=0.01 instead of >=99.99
  so sets with >100% total are correctly shown as incomplete
- Show pct badge with 2 decimals (e.g. "⚠️ 200.00%")
- Remove product name pre-fill in missing SKUs map modal CODMAT field
- Compact CODMAT lines to single row with placeholders instead of labels

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Claude Agent
2026-03-14 21:21:49 +00:00
parent 15ccbe028a
commit 9cacc19d15
3 changed files with 28 additions and 47 deletions

View File

@@ -88,7 +88,7 @@ def get_mappings(search: str = "", page: int = 1, per_page: int = 50,
for r in rows for r in rows
if r.get("activ") == 1 if r.get("activ") == 1
) )
if pct_total >= 99.99: if abs(pct_total - 100) <= 0.01:
complete_skus += 1 complete_skus += 1
else: else:
incomplete_skus += 1 incomplete_skus += 1
@@ -108,7 +108,7 @@ def get_mappings(search: str = "", page: int = 1, per_page: int = 50,
for r in rows for r in rows
if r.get("activ") == 1 if r.get("activ") == 1
) )
is_complete = pct_total >= 99.99 is_complete = abs(pct_total - 100) <= 0.01
if pct_filter == "complete" and is_complete: if pct_filter == "complete" and is_complete:
filtered_groups[sku] = rows filtered_groups[sku] = rows
elif pct_filter == "incomplete" and not is_complete: elif pct_filter == "incomplete" and not is_complete:
@@ -129,7 +129,7 @@ def get_mappings(search: str = "", page: int = 1, per_page: int = 50,
for r in rows for r in rows
if r.get("activ") == 1 if r.get("activ") == 1
) )
sku_pct[sku] = {"pct_total": pct_total, "is_complete": pct_total >= 99.99} sku_pct[sku] = {"pct_total": pct_total, "is_complete": abs(pct_total - 100) <= 0.01}
for row in page_rows: for row in page_rows:
meta = sku_pct.get(row["sku"], {"pct_total": 0, "is_complete": False}) meta = sku_pct.get(row["sku"], {"pct_total": 0, "is_complete": False})

View File

@@ -145,7 +145,7 @@ function renderTable(mappings, showDeleted) {
if (m.is_complete) { if (m.is_complete) {
pctBadge = ` <span class="badge-pct complete" title="100% alocat">&#10003; 100%</span>`; pctBadge = ` <span class="badge-pct complete" title="100% alocat">&#10003; 100%</span>`;
} else { } else {
const pctVal = typeof m.pct_total === 'number' ? m.pct_total.toFixed(0) : m.pct_total; const pctVal = typeof m.pct_total === 'number' ? m.pct_total.toFixed(2) : m.pct_total;
pctBadge = ` <span class="badge-pct incomplete" title="${pctVal}% alocat">&#9888; ${pctVal}%</span>`; pctBadge = ` <span class="badge-pct incomplete" title="${pctVal}% alocat">&#9888; ${pctVal}%</span>`;
} }
} }
@@ -276,23 +276,20 @@ function addCodmatLine() {
const div = document.createElement('div'); const div = document.createElement('div');
div.className = 'border rounded p-2 mb-2 codmat-line'; div.className = 'border rounded p-2 mb-2 codmat-line';
div.innerHTML = ` div.innerHTML = `
<div class="mb-2 position-relative"> <div class="row g-2 align-items-center">
<label class="form-label form-label-sm mb-1">CODMAT (Articol ROA)</label> <div class="col position-relative">
<input type="text" class="form-control form-control-sm cl-codmat" placeholder="Cauta codmat sau denumire..." autocomplete="off" data-idx="${idx}"> <input type="text" class="form-control form-control-sm cl-codmat" placeholder="Cauta CODMAT..." autocomplete="off" data-idx="${idx}">
<div class="autocomplete-dropdown d-none cl-ac-dropdown"></div> <div class="autocomplete-dropdown d-none cl-ac-dropdown"></div>
<small class="text-muted cl-selected"></small> <small class="text-muted cl-selected"></small>
</div> </div>
<div class="row"> <div class="col-auto" style="width:90px">
<div class="col-5"> <input type="number" class="form-control form-control-sm cl-cantitate" value="1" step="0.001" min="0.001" placeholder="Cant." title="Cantitate ROA">
<label class="form-label form-label-sm mb-1">Cantitate ROA</label>
<input type="number" class="form-control form-control-sm cl-cantitate" value="1" step="0.001" min="0.001">
</div> </div>
<div class="col-5"> <div class="col-auto" style="width:90px">
<label class="form-label form-label-sm mb-1">Procent Pret (%)</label> <input type="number" class="form-control form-control-sm cl-procent" value="100" step="0.01" min="0" max="100" placeholder="% Pret" title="Procent Pret">
<input type="number" class="form-control form-control-sm cl-procent" value="100" step="0.01" min="0" max="100">
</div> </div>
<div class="col-2 d-flex align-items-end"> <div class="col-auto">
${idx > 0 ? `<button type="button" class="btn btn-sm btn-outline-danger" onclick="this.closest('.codmat-line').remove()"><i class="bi bi-x-lg"></i></button>` : ''} ${idx > 0 ? `<button type="button" class="btn btn-sm btn-outline-danger" onclick="this.closest('.codmat-line').remove()"><i class="bi bi-x-lg"></i></button>` : '<div style="width:31px"></div>'}
</div> </div>
</div> </div>
`; `;

View File

@@ -264,19 +264,6 @@ function openMapModal(sku, productName) {
container.innerHTML = ''; container.innerHTML = '';
addMapCodmatLine(); addMapCodmatLine();
// Pre-search with product name
if (productName) {
setTimeout(() => {
const input = container.querySelector('.mc-codmat');
if (input) {
input.value = productName;
mcAutocomplete(input,
container.querySelector('.mc-ac-dropdown'),
container.querySelector('.mc-selected'));
}
}, 100);
}
new bootstrap.Modal(document.getElementById('mapModal')).show(); new bootstrap.Modal(document.getElementById('mapModal')).show();
} }
@@ -286,23 +273,20 @@ function addMapCodmatLine() {
const div = document.createElement('div'); const div = document.createElement('div');
div.className = 'border rounded p-2 mb-2 mc-line'; div.className = 'border rounded p-2 mb-2 mc-line';
div.innerHTML = ` div.innerHTML = `
<div class="mb-2 position-relative"> <div class="row g-2 align-items-center">
<label class="form-label form-label-sm mb-1">CODMAT (Articol ROA)</label> <div class="col position-relative">
<input type="text" class="form-control form-control-sm mc-codmat" placeholder="Cauta codmat sau denumire..." autocomplete="off"> <input type="text" class="form-control form-control-sm mc-codmat" placeholder="Cauta CODMAT..." autocomplete="off">
<div class="autocomplete-dropdown d-none mc-ac-dropdown"></div> <div class="autocomplete-dropdown d-none mc-ac-dropdown"></div>
<small class="text-muted mc-selected"></small> <small class="text-muted mc-selected"></small>
</div> </div>
<div class="row"> <div class="col-auto" style="width:90px">
<div class="col-5"> <input type="number" class="form-control form-control-sm mc-cantitate" value="1" step="0.001" min="0.001" placeholder="Cant." title="Cantitate ROA">
<label class="form-label form-label-sm mb-1">Cantitate ROA</label>
<input type="number" class="form-control form-control-sm mc-cantitate" value="1" step="0.001" min="0.001">
</div> </div>
<div class="col-5"> <div class="col-auto" style="width:90px">
<label class="form-label form-label-sm mb-1">Procent Pret (%)</label> <input type="number" class="form-control form-control-sm mc-procent" value="100" step="0.01" min="0" max="100" placeholder="% Pret" title="Procent Pret">
<input type="number" class="form-control form-control-sm mc-procent" value="100" step="0.01" min="0" max="100">
</div> </div>
<div class="col-2 d-flex align-items-end"> <div class="col-auto">
${idx > 0 ? `<button type="button" class="btn btn-sm btn-outline-danger" onclick="this.closest('.mc-line').remove()"><i class="bi bi-x"></i></button>` : ''} ${idx > 0 ? `<button type="button" class="btn btn-sm btn-outline-danger" onclick="this.closest('.mc-line').remove()"><i class="bi bi-x"></i></button>` : '<div style="width:31px"></div>'}
</div> </div>
</div> </div>
`; `;