This commit is contained in:
2022-03-24 23:14:23 +00:00
parent 4b7fb30a43
commit 13fb9ed3a1

View File

@@ -114,26 +114,32 @@ export default {
if (res.data) {
dat = res.data;
}
console.log("Done parseCSVFile");
//console.log("Done parseCSVFile");
} else {
dat = await parseJSONFile(this.uploadFile);
console.log("Done parse json");
//console.log("Done parse json");
}
console.log(
"The processed data before cleaning is ",
JSON.stringify(dat)
);
// console.log(
// "The processed data before cleaning is ",
// JSON.stringify(dat)
// );
//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:",
// Papa.unparse(dat)
// );
//upload the data
//await this.upload(dat);
await this.upload(dat);
} catch (error) {
window.$gz.errorHandler.handleFormError(error);
}
@@ -283,41 +289,43 @@ function cleanData(dat, atype) {
//at front end it will attempt to match up but not create if not existing
switch (atype) {
case 8: //CUSTOMER
allowedProps.concat([
"Name",
"Active",
"Notes",
"Wiki",
"CustomFields",
"Tags",
"WebAddress",
"AlertNotes",
"BillHeadOffice",
"HeadOfficeName",
"HeadOfficeViz",
"TechNotes",
"AccountNumber",
"ContractName",
"ContractViz",
"ContractExpires",
"Phone1",
"Phone2",
"Phone3",
"Phone4",
"Phone5",
"EmailAddress",
"PostAddress",
"PostCity",
"PostRegion",
"PostCountry",
"PostCode",
"Address",
"City",
"Region",
"Country",
"Latitude",
"Longitude"
]);
allowedProps.push(
...[
"Name",
"Active",
"Notes",
"Wiki",
"CustomFields",
"Tags",
"WebAddress",
"AlertNotes",
"BillHeadOffice",
"HeadOfficeName",
"HeadOfficeViz",
"TechNotes",
"AccountNumber",
"ContractName",
"ContractViz",
"ContractExpires",
"Phone1",
"Phone2",
"Phone3",
"Phone4",
"Phone5",
"EmailAddress",
"PostAddress",
"PostCity",
"PostRegion",
"PostCountry",
"PostCode",
"Address",
"City",
"Region",
"Country",
"Latitude",
"Longitude"
]
);
break;
}
@@ -325,12 +333,8 @@ function cleanData(dat, atype) {
dat.forEach(z => {
for (const prop in z) {
if (allowedProps.includes(prop) == false) {
console.log(`removing unknown property z.${prop}`);
delete z[prop];
} else {
console.log(`Keeping known property z.${prop}`);
}
//console.log(`z.${prop} = ${z[prop]}`);
}
});
}
@@ -413,5 +417,14 @@ Assign it in code to a variable:
"Latitude",
"Longitude"
]
if it was csv it should look like this:
Name,Active,Notes,Wiki,CustomFields,Tags,WebAddress,AlertNotes,BillHeadOffice,HeadOfficeViz,TechNotes,AccountNumber,ContractViz,ContractExpires,Phone1,Phone2,Phone3,Phone4,Phone5,EmailAddress,PostAddress,PostCity,PostRegion,PostCountry,PostCode,Address,City,Region,Country,Latitude,Longitude
"ACopyOf Altenwerth, Willms and Krajcik",true,Advanced web-enabled productivity,,,"black,white",https://example.info,,true,"Gerlach, Howe and Crist",,40810165,,,(868) 464-5253,1-788-655-8853 x08455,536.824.7646,,,Maximo_Ziemann10@example.net,00060 Davion Mission,East Kevonstad,Washington,Iraq,68361-2305,75163 Heller Plains,East Kevonstad,Washington,Iraq,33.3014,-157.7912
"ACopyOf Adams, Macejkovic and Stoltenberg",true,Multi-layered multi-tasking infrastructure,,,zone9,https://example.biz,,false,,,21491466,,,830-720-4993 x86044,1-306-960-6200 x0811,1-269-482-1221 x97391,,,Leanne99@example.com,4399 Hegmann Pass,South Velva,Georgia,Chile,44636-1335,6036 Reggie Pine,South Velva,Georgia,Chile,41.1883,-152.6866
*/
</script>