From 2d1283ac969c874e620b62db61422350402d51cf Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Thu, 24 Mar 2022 23:43:29 +0000 Subject: [PATCH] --- ayanova/src/views/adm-import.vue | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/ayanova/src/views/adm-import.vue b/ayanova/src/views/adm-import.vue index 96dee9bf..8f5c4968 100644 --- a/ayanova/src/views/adm-import.vue +++ b/ayanova/src/views/adm-import.vue @@ -75,6 +75,7 @@ export default { importable() { return ( (this.doImport || this.doUpdate) && + this.uploadFile && this.uploadFile.name && this.ayaType != 0 ); @@ -128,10 +129,10 @@ export default { //strip out any unsupported fields before transmission cleanData(dat, this.ayaType); - // console.log( - // "The processed data AFTER cleaning is ", - // JSON.stringify(dat) - // ); + console.log( + "The processed data AFTER cleaning is ", + JSON.stringify(dat) + ); // console.log( // "if it was csv it should look like this:", @@ -139,7 +140,7 @@ export default { // ); //upload the data - await this.upload(dat); + //await this.upload(dat); } catch (error) { window.$gz.errorHandler.handleFormError(error); } @@ -250,6 +251,7 @@ async function parseCSVFile(file) { return new Promise(function(complete, error) { Papa.parse(file, { header: true, + skipEmptyLines: true, dynamicTyping: true, worker: true, complete, @@ -334,6 +336,14 @@ function cleanData(dat, atype) { for (const prop in z) { if (allowedProps.includes(prop) == false) { delete z[prop]; + } else { + if (prop == "Tags") { + //if it's coming from csv then Tags will be a string with comma separated items like this: blue,white,red + //if it's json it will already be an array + if (z.Tags && typeof z.Tags === "string") { + z.Tags = z.Tags.split(","); + } + } } } });