From 9cacc19d15321043e60aa10366c2e03e0090d080 Mon Sep 17 00:00:00 2001 From: Claude Agent Date: Sat, 14 Mar 2026 21:21:49 +0000 Subject: [PATCH] fix(ui): fix set pct badge logic and compact CODMAT form layout MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- api/app/services/mapping_service.py | 6 ++--- api/app/static/js/mappings.js | 29 ++++++++++----------- api/app/templates/missing_skus.html | 40 +++++++++-------------------- 3 files changed, 28 insertions(+), 47 deletions(-) diff --git a/api/app/services/mapping_service.py b/api/app/services/mapping_service.py index ee34ee4..12290cc 100644 --- a/api/app/services/mapping_service.py +++ b/api/app/services/mapping_service.py @@ -88,7 +88,7 @@ def get_mappings(search: str = "", page: int = 1, per_page: int = 50, for r in rows if r.get("activ") == 1 ) - if pct_total >= 99.99: + if abs(pct_total - 100) <= 0.01: complete_skus += 1 else: incomplete_skus += 1 @@ -108,7 +108,7 @@ def get_mappings(search: str = "", page: int = 1, per_page: int = 50, for r in rows 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: filtered_groups[sku] = rows 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 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: meta = sku_pct.get(row["sku"], {"pct_total": 0, "is_complete": False}) diff --git a/api/app/static/js/mappings.js b/api/app/static/js/mappings.js index 95bbfec..5ce168b 100644 --- a/api/app/static/js/mappings.js +++ b/api/app/static/js/mappings.js @@ -145,7 +145,7 @@ function renderTable(mappings, showDeleted) { if (m.is_complete) { pctBadge = ` ✓ 100%`; } 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 = ` ⚠ ${pctVal}%`; } } @@ -276,23 +276,20 @@ function addCodmatLine() { const div = document.createElement('div'); div.className = 'border rounded p-2 mb-2 codmat-line'; div.innerHTML = ` -
- - -
- -
-
-
- - +
+
+ +
+
-
- - +
+
-
- ${idx > 0 ? `` : ''} +
+ +
+
+ ${idx > 0 ? `` : '
'}
`; diff --git a/api/app/templates/missing_skus.html b/api/app/templates/missing_skus.html index 1143ebd..877cdae 100644 --- a/api/app/templates/missing_skus.html +++ b/api/app/templates/missing_skus.html @@ -264,19 +264,6 @@ function openMapModal(sku, productName) { container.innerHTML = ''; 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(); } @@ -286,23 +273,20 @@ function addMapCodmatLine() { const div = document.createElement('div'); div.className = 'border rounded p-2 mb-2 mc-line'; div.innerHTML = ` -
- - -
- -
-
-
- - +
+
+ +
+
-
- - +
+
-
- ${idx > 0 ? `` : ''} +
+ +
+
+ ${idx > 0 ? `` : '
'}
`;