From 7243faee616c76728fd78e7cfb5080289dff17ab Mon Sep 17 00:00:00 2001 From: Mile Divovic Date: Tue, 26 Nov 2024 12:12:30 -0800 Subject: [PATCH] Add error message when importing CTDLASN CSV with empty competency text column --- src/mixins/import.js | 65 ++++++++++++++++++++++++-------------------- 1 file changed, 35 insertions(+), 30 deletions(-) diff --git a/src/mixins/import.js b/src/mixins/import.js index 4a5483a00..09307a4d3 100644 --- a/src/mixins/import.js +++ b/src/mixins/import.js @@ -240,38 +240,43 @@ export default { me.$store.commit('app/importStatus', feedback); me.$store.commit('app/importTransition', 'info'); }, function(errorMsg) { - CSVImport.analyzeFile(file, function(data) { - me.$store.commit('app/importFileType', 'csv'); - me.importFrameworkName = file.name.replace(".csv", ""); - for (let i = 0; i < data.length; i++) { - if (data[i][0] === "") { - data.splice(i, 1); - } - } - for (var i = 0; i < data[0].length; i++) { - let column = {}; - column.name = data[0][i]; - column.index = i; - me.csvColumns.push(column); - if (column.name.toLowerCase().indexOf("name") !== -1) { - me.importCsvColumnName = column; - } - if (column.name.toLowerCase().indexOf("description") !== -1) { - me.importCsvColumnDescription = column; - } - if (column.name.toLowerCase().indexOf("scope") !== -1) { - me.importCsvColumnScope = column; + if (errorMsg.indexOf('CTDLASN Parse Error') !== -1) { + me.$store.commit('app/addImportError', errorMsg); + me.$store.commit('app/importTransition', 'process'); + } else { + CSVImport.analyzeFile(file, function(data) { + me.$store.commit('app/importFileType', 'csv'); + me.importFrameworkName = file.name.replace(".csv", ""); + for (let i = 0; i < data.length; i++) { + if (data[i][0] === "") { + data.splice(i, 1); + } } - if (column.name.toLowerCase().indexOf("id") !== -1) { - me.importCsvColumnId = column; + for (var i = 0; i < data[0].length; i++) { + let column = {}; + column.name = data[0][i]; + column.index = i; + me.csvColumns.push(column); + if (column.name.toLowerCase().indexOf("name") !== -1) { + me.importCsvColumnName = column; + } + if (column.name.toLowerCase().indexOf("description") !== -1) { + me.importCsvColumnDescription = column; + } + if (column.name.toLowerCase().indexOf("scope") !== -1) { + me.importCsvColumnScope = column; + } + if (column.name.toLowerCase().indexOf("id") !== -1) { + me.importCsvColumnId = column; + } } - } - me.$store.commit('app/importStatus', (me.competencyCount = (data.length - 1)) + " Competencies Detected."); - me.$store.commit('app/importTransition', 'info'); - }, function(error) { - me.$store.commit('app/addImportError', error); - me.$store.commit('app/importTransition', 'process'); - }); + me.$store.commit('app/importStatus', (me.competencyCount = (data.length - 1)) + " Competencies Detected."); + me.$store.commit('app/importTransition', 'info'); + }, function(error) { + me.$store.commit('app/addImportError', error); + me.$store.commit('app/importTransition', 'process'); + }); + } }); } } else if (file.name.endsWith(".json") || file.name.endsWith(".jsonld")) {