diff --git a/app/javascript/react/components/FileUpload/ModalValidationReport/ModalValidationReport.jsx b/app/javascript/react/components/FileUpload/ModalValidationReport/ModalValidationReport.jsx index cb499f28cd..325b5a5c69 100644 --- a/app/javascript/react/components/FileUpload/ModalValidationReport/ModalValidationReport.jsx +++ b/app/javascript/react/components/FileUpload/ModalValidationReport/ModalValidationReport.jsx @@ -7,15 +7,15 @@ import './frictionless-components.css'; function getReportErrors(task) { const reportErrors = {}; for (const error of task.errors) { - const header = task.resource.schema.fields.map((field) => field.name); + const header = task.resource ? task.resource.schema.fields.map((field) => field.name) : task.labels; // Prepare reportError - let reportError = reportErrors[error.code]; + let reportError = reportErrors[error.type || error.code]; if (!reportError) { reportError = { count: 0, - code: error.code, - name: error.name, + type: error.type || error.code, + name: error.title || error.name, tags: error.tags, description: error.description, header, @@ -25,24 +25,28 @@ function getReportErrors(task) { } // Prepare cells - let data = reportError.data[error.rowPosition || 0]; + let data = reportError.data[error.rowNumber || error.rowPosition || 0]; if (!data) { const values = error.cells || error.labels || []; data = {values, errors: new Set()}; } // Ensure blank row - if (error.code === 'blank-row') { + if (error.type === 'blank-row' || error.code === 'blank-row') { data.values = header.map(() => ''); } // Ensure missing cell - if (error.code === 'missing-cell') { + if (error.type === 'missing-cell') { + data.values[error.fieldNumber - 1] = ''; + } else if (error.code === 'missing-cell') { data.values[error.fieldPosition - 1] = ''; } // Add row errors - if (error.fieldPosition) { + if (error.fieldNumber) { + data.errors.add(error.fieldNumber); + } else if (error.fieldPosition) { data.errors.add(error.fieldPosition); } else if (data.values) { data.errors = new Set(data.values.map((_, index) => index + 1)); @@ -51,8 +55,8 @@ function getReportErrors(task) { // Save reportError reportError.count += 1; reportError.messages.push(error.message); - reportError.data[error.rowPosition || 0] = data; - reportErrors[error.code] = reportError; + reportError.data[error.rowNumber || error.rowPosition || 0] = data; + reportErrors[error.type || error.code] = reportError; } return reportErrors; @@ -70,7 +74,7 @@ function HandleReport(jsReport) {
The report shows the maximum of 10 alerts. More alerts may appear if these 10 are corrected and the file is re-uploaded.
)} {Object.values(reportErrors).map((reportError) => ( -