This commit is contained in:
@@ -75,6 +75,7 @@ export default {
|
|||||||
importable() {
|
importable() {
|
||||||
return (
|
return (
|
||||||
(this.doImport || this.doUpdate) &&
|
(this.doImport || this.doUpdate) &&
|
||||||
|
this.uploadFile &&
|
||||||
this.uploadFile.name &&
|
this.uploadFile.name &&
|
||||||
this.ayaType != 0
|
this.ayaType != 0
|
||||||
);
|
);
|
||||||
@@ -128,10 +129,10 @@ export default {
|
|||||||
//strip out any unsupported fields before transmission
|
//strip out any unsupported fields before transmission
|
||||||
cleanData(dat, this.ayaType);
|
cleanData(dat, this.ayaType);
|
||||||
|
|
||||||
// console.log(
|
console.log(
|
||||||
// "The processed data AFTER cleaning is ",
|
"The processed data AFTER cleaning is ",
|
||||||
// JSON.stringify(dat)
|
JSON.stringify(dat)
|
||||||
// );
|
);
|
||||||
|
|
||||||
// console.log(
|
// console.log(
|
||||||
// "if it was csv it should look like this:",
|
// "if it was csv it should look like this:",
|
||||||
@@ -139,7 +140,7 @@ export default {
|
|||||||
// );
|
// );
|
||||||
|
|
||||||
//upload the data
|
//upload the data
|
||||||
await this.upload(dat);
|
//await this.upload(dat);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
window.$gz.errorHandler.handleFormError(error);
|
window.$gz.errorHandler.handleFormError(error);
|
||||||
}
|
}
|
||||||
@@ -250,6 +251,7 @@ async function parseCSVFile(file) {
|
|||||||
return new Promise(function(complete, error) {
|
return new Promise(function(complete, error) {
|
||||||
Papa.parse(file, {
|
Papa.parse(file, {
|
||||||
header: true,
|
header: true,
|
||||||
|
skipEmptyLines: true,
|
||||||
dynamicTyping: true,
|
dynamicTyping: true,
|
||||||
worker: true,
|
worker: true,
|
||||||
complete,
|
complete,
|
||||||
@@ -334,6 +336,14 @@ function cleanData(dat, atype) {
|
|||||||
for (const prop in z) {
|
for (const prop in z) {
|
||||||
if (allowedProps.includes(prop) == false) {
|
if (allowedProps.includes(prop) == false) {
|
||||||
delete z[prop];
|
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(",");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user