Skip to content

Commit

Permalink
Add error message when importing CTDLASN CSV with empty competency te…
Browse files Browse the repository at this point in the history
…xt column
  • Loading branch information
miledivovic committed Nov 26, 2024
1 parent fed4072 commit 7243fae
Showing 1 changed file with 35 additions and 30 deletions.
65 changes: 35 additions & 30 deletions src/mixins/import.js
Original file line number Diff line number Diff line change
Expand Up @@ -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")) {
Expand Down

0 comments on commit 7243fae

Please sign in to comment.