diff --git a/ayanova/src/views/adm-import.vue b/ayanova/src/views/adm-import.vue index 7e63c0aa..de831bd6 100644 --- a/ayanova/src/views/adm-import.vue +++ b/ayanova/src/views/adm-import.vue @@ -98,7 +98,11 @@ export default { console.log("Done parse json"); } - console.log("The final data is ", dat); + console.log("The processed data is ", dat); + + //strip out any unsupported fields before transmission + cleanData(dat, this.ayaType); + //upload the data await this.upload(dat); } catch (error) { @@ -222,4 +226,98 @@ async function parseJSONFile(file) { } }); } + +////////////////////////////////////////////////////////// +// +// remove unsupported props from data +// +function cleanData(dat, atype) { + var allowedProps = []; + //{"data":[{"id":8,"name":"Customer"},{"id":15,"name":"Head Office"},{"id":20,"name":"Part"},{"id":25,"name":"Project"},{"id":31,"name":"Unit"},{"id":32,"name":"Unit model"},{"id":33,"name":"Vendor"},{"id":62,"name":"Service rate"},{"id":63,"name":"Travel rate"},{"id":65,"name":"Part Assembly"},{"id":66,"name":"Part Warehouse"},{"id":72,"name":"Task group"}]} + switch (atype) { + case 8: + allowedProps.concat(["Name"]); + break; + } +} + +/* HOW TO GET PROPERTY NAMES EASILY +Get the object from network traffic: +Assign it in code to a variable: + var v = { + Name: "XYZ Accounting", + Active: true, + Notes: "Ergonomic impactful info-mediaries", + Wiki: null, + CustomFields: null, + Tags: ["black", "zone2", "zone3"], + WebAddress: "https://example.biz", + AlertNotes: null, + BillHeadOffice: true, + HeadOfficeId: 1, + HeadOfficeViz: "XYZ Head Office", + TechNotes: null, + AccountNumber: "10402542", + ContractId: null, + ContractViz: null, + ContractExpires: null, + LastWorkOrderViz: 350, + LastServiceDateViz: "2022-03-09T00:00:00Z", + Phone1: "373-707-7322 x535", + Phone2: "281.718.4551", + Phone3: "1-452-791-5760 x84358", + Phone4: null, + Phone5: null, + EmailAddress: "Annabel.Hahn64@example.org", + PostAddress: null, + PostCity: null, + PostRegion: null, + PostCountry: null, + PostCode: null, + Address: "9723 Tiara Summit", + City: "Hansenside", + Region: "Mississippi", + Country: "Japan", + Latitude: -7.7692, + Longitude: 165.0654 + }; + In a javascript console use this Object.getOwnPropertyNames(); will output a nice array with field names +[ + "Name", + "Active", + "Notes", + "Wiki", + "CustomFields", + "Tags", + "WebAddress", + "AlertNotes", + "BillHeadOffice", + "HeadOfficeId", + "HeadOfficeViz", + "TechNotes", + "AccountNumber", + "ContractId", + "ContractViz", + "ContractExpires", + "LastWorkOrderViz", + "LastServiceDateViz", + "Phone1", + "Phone2", + "Phone3", + "Phone4", + "Phone5", + "EmailAddress", + "PostAddress", + "PostCity", + "PostRegion", + "PostCountry", + "PostCode", + "Address", + "City", + "Region", + "Country", + "Latitude", + "Longitude" +] +*/