Add Details DE/EN to description columns filter

Include DETAILS columns in description filter for Present/Missing filtering and improve empty value handling
This commit is contained in:
Christian Vidal Wolf
2026-04-20 16:37:33 +02:00
parent b6b60e7dfb
commit 1d9e77038a
+16 -14
View File
@@ -15,7 +15,7 @@ interface ProductDescriptionsProps {
type TabType = 'all' | 'missingLongDE' | 'missingLongEN' | 'missingShortDE' | 'missingShortEN' | 'complete' | 'incomplete'; type TabType = 'all' | 'missingLongDE' | 'missingLongEN' | 'missingShortDE' | 'missingShortEN' | 'complete' | 'incomplete';
// Description columns that should only have Present/Missing filters // Description columns that should only have Present/Missing filters
const DESCRIPTION_COLUMNS = [COLUMNS.LONG_DE, COLUMNS.LONG_EN, COLUMNS.SHORT_DE, COLUMNS.SHORT_EN]; const DESCRIPTION_COLUMNS = [COLUMNS.LONG_DE, COLUMNS.LONG_EN, COLUMNS.SHORT_DE, COLUMNS.SHORT_EN, COLUMNS.DETAILS_DE, COLUMNS.DETAILS_EN];
export function ProductDescriptions({ data, headers, asinColumnIndex, onEdit, rowStatuses }: ProductDescriptionsProps) { export function ProductDescriptions({ data, headers, asinColumnIndex, onEdit, rowStatuses }: ProductDescriptionsProps) {
const [activeTab, setActiveTab] = useState<TabType>('all'); const [activeTab, setActiveTab] = useState<TabType>('all');
@@ -76,27 +76,29 @@ export function ProductDescriptions({ data, headers, asinColumnIndex, onEdit, ro
if (licenseFilter) result = result.filter(r => r.row[COLUMNS.LICENSE] === licenseFilter); if (licenseFilter) result = result.filter(r => r.row[COLUMNS.LICENSE] === licenseFilter);
// Column-specific filters (Excel-like) // Column-specific filters (Excel-like)
console.log('[Filter] applying columnFilters:', columnFilters, 'result count before:', result.length);
Object.entries(columnFilters).forEach(([colIdx, selectedValues]) => { Object.entries(columnFilters).forEach(([colIdx, selectedValues]) => {
const col = Number(colIdx); const col = Number(colIdx);
const vals = selectedValues as string[]; const vals = selectedValues as string[];
if (vals.length > 0) { if (vals.length > 0) {
// For description columns, filter by present/missing result = result.filter(r => {
const cellVal = r.row[col];
if (DESCRIPTION_COLUMNS.includes(col)) { if (DESCRIPTION_COLUMNS.includes(col)) {
result = result.filter(r => { // For description columns, we match synthetic 'Present'/'Missing' values
const hasValue = Boolean(r.row[col]); const hasValue = cellVal !== undefined && cellVal !== null && String(cellVal).trim() !== '';
const shouldInclude = (vals.includes('Present') && hasValue) || (vals.includes('Missing') && !hasValue); const matchPresent = vals.includes('Present') && hasValue;
return shouldInclude; const matchMissing = vals.includes('Missing') && !hasValue;
}); return matchPresent || matchMissing;
} else { } else {
// For other columns, use regular value matching // For other columns, use regular value matching with improved empty value handling
const before = result.length; const cellStr = String(cellVal ?? '').trim();
result = result.filter(r => { // If the cell is empty/null/undefined, it matches if 'Empty' or '' is selected
const cellVal = String(r.row[col] ?? '').trim(); return vals.some(v => {
return vals.some(v => v.trim() === cellVal); const filterVal = String(v ?? '').trim();
return filterVal === cellStr;
}); });
console.log('[Filter] col', col, 'vals', vals, 'before:', before, 'after:', result.length);
} }
});
} }
}); });