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';
// 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) {
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);
// Column-specific filters (Excel-like)
console.log('[Filter] applying columnFilters:', columnFilters, 'result count before:', result.length);
Object.entries(columnFilters).forEach(([colIdx, selectedValues]) => {
const col = Number(colIdx);
const vals = selectedValues as string[];
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)) {
result = result.filter(r => {
const hasValue = Boolean(r.row[col]);
const shouldInclude = (vals.includes('Present') && hasValue) || (vals.includes('Missing') && !hasValue);
return shouldInclude;
});
// For description columns, we match synthetic 'Present'/'Missing' values
const hasValue = cellVal !== undefined && cellVal !== null && String(cellVal).trim() !== '';
const matchPresent = vals.includes('Present') && hasValue;
const matchMissing = vals.includes('Missing') && !hasValue;
return matchPresent || matchMissing;
} else {
// For other columns, use regular value matching
const before = result.length;
result = result.filter(r => {
const cellVal = String(r.row[col] ?? '').trim();
return vals.some(v => v.trim() === cellVal);
// For other columns, use regular value matching with improved empty value handling
const cellStr = String(cellVal ?? '').trim();
// If the cell is empty/null/undefined, it matches if 'Empty' or '' is selected
return vals.some(v => {
const filterVal = String(v ?? '').trim();
return filterVal === cellStr;
});
console.log('[Filter] col', col, 'vals', vals, 'before:', before, 'after:', result.length);
}
});
}
});