Skip to content

Commit 7243fae

Browse files
committed
Add error message when importing CTDLASN CSV with empty competency text column
1 parent fed4072 commit 7243fae

File tree

1 file changed

+35
-30
lines changed

1 file changed

+35
-30
lines changed

src/mixins/import.js

Lines changed: 35 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -240,38 +240,43 @@ export default {
240240
me.$store.commit('app/importStatus', feedback);
241241
me.$store.commit('app/importTransition', 'info');
242242
}, function(errorMsg) {
243-
CSVImport.analyzeFile(file, function(data) {
244-
me.$store.commit('app/importFileType', 'csv');
245-
me.importFrameworkName = file.name.replace(".csv", "");
246-
for (let i = 0; i < data.length; i++) {
247-
if (data[i][0] === "") {
248-
data.splice(i, 1);
249-
}
250-
}
251-
for (var i = 0; i < data[0].length; i++) {
252-
let column = {};
253-
column.name = data[0][i];
254-
column.index = i;
255-
me.csvColumns.push(column);
256-
if (column.name.toLowerCase().indexOf("name") !== -1) {
257-
me.importCsvColumnName = column;
258-
}
259-
if (column.name.toLowerCase().indexOf("description") !== -1) {
260-
me.importCsvColumnDescription = column;
261-
}
262-
if (column.name.toLowerCase().indexOf("scope") !== -1) {
263-
me.importCsvColumnScope = column;
243+
if (errorMsg.indexOf('CTDLASN Parse Error') !== -1) {
244+
me.$store.commit('app/addImportError', errorMsg);
245+
me.$store.commit('app/importTransition', 'process');
246+
} else {
247+
CSVImport.analyzeFile(file, function(data) {
248+
me.$store.commit('app/importFileType', 'csv');
249+
me.importFrameworkName = file.name.replace(".csv", "");
250+
for (let i = 0; i < data.length; i++) {
251+
if (data[i][0] === "") {
252+
data.splice(i, 1);
253+
}
264254
}
265-
if (column.name.toLowerCase().indexOf("id") !== -1) {
266-
me.importCsvColumnId = column;
255+
for (var i = 0; i < data[0].length; i++) {
256+
let column = {};
257+
column.name = data[0][i];
258+
column.index = i;
259+
me.csvColumns.push(column);
260+
if (column.name.toLowerCase().indexOf("name") !== -1) {
261+
me.importCsvColumnName = column;
262+
}
263+
if (column.name.toLowerCase().indexOf("description") !== -1) {
264+
me.importCsvColumnDescription = column;
265+
}
266+
if (column.name.toLowerCase().indexOf("scope") !== -1) {
267+
me.importCsvColumnScope = column;
268+
}
269+
if (column.name.toLowerCase().indexOf("id") !== -1) {
270+
me.importCsvColumnId = column;
271+
}
267272
}
268-
}
269-
me.$store.commit('app/importStatus', (me.competencyCount = (data.length - 1)) + " Competencies Detected.");
270-
me.$store.commit('app/importTransition', 'info');
271-
}, function(error) {
272-
me.$store.commit('app/addImportError', error);
273-
me.$store.commit('app/importTransition', 'process');
274-
});
273+
me.$store.commit('app/importStatus', (me.competencyCount = (data.length - 1)) + " Competencies Detected.");
274+
me.$store.commit('app/importTransition', 'info');
275+
}, function(error) {
276+
me.$store.commit('app/addImportError', error);
277+
me.$store.commit('app/importTransition', 'process');
278+
});
279+
}
275280
});
276281
}
277282
} else if (file.name.endsWith(".json") || file.name.endsWith(".jsonld")) {

0 commit comments

Comments
 (0)