mirror of
https://github.com/christianvidalwolf-prog/Craze-Data-check.git
synced 2026-08-03 16:15:25 +02:00
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:
co-authored by
claude-flow
parent
9f3acd0631
commit
73118ea4c3
@@ -82,6 +82,9 @@ export function CosmeticItemsView({ data, headers, onSaveRow, onCaptureState, ro
|
||||
(Object.entries(columnFilters) as [string, string[]][]).forEach(([colIdx, filterValues]) => {
|
||||
if (!filterValues || filterValues.length === 0) return;
|
||||
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 filterSet = new Set(filterValues.map(normalize));
|
||||
result = result.filter(({ row }) => filterSet.has(normalize(row[colNum])));
|
||||
@@ -102,7 +105,7 @@ export function CosmeticItemsView({ data, headers, onSaveRow, onCaptureState, ro
|
||||
}
|
||||
|
||||
return result;
|
||||
}, [data, search, sortCol, sortDesc, columnFilters, COLUMNS]);
|
||||
}, [data, search, sortCol, sortDesc, columnFilters, COLUMNS, columnUniqueValues]);
|
||||
|
||||
const paginatedData = useMemo(() => {
|
||||
const start = (page - 1) * pageSize;
|
||||
@@ -292,18 +295,29 @@ export function CosmeticItemsView({ data, headers, onSaveRow, onCaptureState, ro
|
||||
<X className="w-4 h-4" />
|
||||
</button>
|
||||
</div>
|
||||
) : (
|
||||
<button
|
||||
onClick={() => startEditCpnp(index, row[COLUMNS.CPNP_NO])}
|
||||
className="w-full text-left px-2 py-1 rounded border border-dashed border-slate-600 text-slate-500 hover:border-indigo-500 hover:text-indigo-400 transition-colors text-[10px]"
|
||||
title="Click to enter CPNP No."
|
||||
>
|
||||
<span className="flex items-center gap-1.5">
|
||||
<Save className="w-3 h-3 opacity-50" />
|
||||
Click to fill...
|
||||
</span>
|
||||
</button>
|
||||
)}
|
||||
) : (() => {
|
||||
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
|
||||
onClick={() => startEditCpnp(index, row[COLUMNS.CPNP_NO])}
|
||||
className="w-full text-left px-2 py-1 rounded border border-dashed border-slate-600 text-slate-500 hover:border-indigo-500 hover:text-indigo-400 transition-colors text-[10px]"
|
||||
title="Click to enter CPNP No."
|
||||
>
|
||||
<span className="flex items-center gap-1.5">
|
||||
<Save className="w-3 h-3 opacity-50" />
|
||||
Click to fill...
|
||||
</span>
|
||||
</button>
|
||||
);
|
||||
})()}
|
||||
</td>
|
||||
</tr>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user