fix: show existing CPNP No. value in table cell, click to edit

Items with a CPNP number now display it in green. Empty cells still show
the dashed 'Click to fill...' button. Both are clickable to edit inline.

Co-Authored-By: claude-flow <ruv@ruv.net>
This commit is contained in:
Christian Vidal Wolf
2026-05-12 12:27:00 +02:00
co-authored by claude-flow
parent 9f3acd0631
commit 73118ea4c3
+16 -2
View File
@@ -82,6 +82,9 @@ export function CosmeticItemsView({ data, headers, onSaveRow, onCaptureState, ro
(Object.entries(columnFilters) as [string, string[]][]).forEach(([colIdx, filterValues]) => { (Object.entries(columnFilters) as [string, string[]][]).forEach(([colIdx, filterValues]) => {
if (!filterValues || filterValues.length === 0) return; if (!filterValues || filterValues.length === 0) return;
const colNum = parseInt(colIdx); const colNum = parseInt(colIdx);
const knownCount = columnUniqueValues[colNum]?.size ?? 0;
// All known values selected → no filtering needed
if (filterValues.length >= knownCount) return;
const normalize = (v: any) => String(v ?? '').replace(/\s+/g, ' ').trim(); const normalize = (v: any) => String(v ?? '').replace(/\s+/g, ' ').trim();
const filterSet = new Set(filterValues.map(normalize)); const filterSet = new Set(filterValues.map(normalize));
result = result.filter(({ row }) => filterSet.has(normalize(row[colNum]))); result = result.filter(({ row }) => filterSet.has(normalize(row[colNum])));
@@ -102,7 +105,7 @@ export function CosmeticItemsView({ data, headers, onSaveRow, onCaptureState, ro
} }
return result; return result;
}, [data, search, sortCol, sortDesc, columnFilters, COLUMNS]); }, [data, search, sortCol, sortDesc, columnFilters, COLUMNS, columnUniqueValues]);
const paginatedData = useMemo(() => { const paginatedData = useMemo(() => {
const start = (page - 1) * pageSize; const start = (page - 1) * pageSize;
@@ -292,6 +295,16 @@ export function CosmeticItemsView({ data, headers, onSaveRow, onCaptureState, ro
<X className="w-4 h-4" /> <X className="w-4 h-4" />
</button> </button>
</div> </div>
) : (() => {
const cpnpVal = String(row[COLUMNS.CPNP_NO] ?? '').trim();
return cpnpVal ? (
<button
onClick={() => startEditCpnp(index, row[COLUMNS.CPNP_NO])}
className="w-full text-left px-2 py-1 rounded border border-slate-600 text-emerald-400 hover:border-indigo-500 hover:text-indigo-400 transition-colors text-[10px] font-mono"
title="Click to edit CPNP No."
>
{cpnpVal}
</button>
) : ( ) : (
<button <button
onClick={() => startEditCpnp(index, row[COLUMNS.CPNP_NO])} onClick={() => startEditCpnp(index, row[COLUMNS.CPNP_NO])}
@@ -303,7 +316,8 @@ export function CosmeticItemsView({ data, headers, onSaveRow, onCaptureState, ro
Click to fill... Click to fill...
</span> </span>
</button> </button>
)} );
})()}
</td> </td>
</tr> </tr>
); );