Skip to content

Commit

Permalink
Fixed: Code to check for incompleted fieldmapping or missing mappings…
Browse files Browse the repository at this point in the history
… name, earlier we were having two checks for missing mapping name, imcomplete field mapping or missing file upload in IF & ELSE block, now optimised code to do it in a single scope(#326re7p)
  • Loading branch information
shashwatbangar committed Dec 8, 2022
1 parent 82dd0c0 commit 48f9f17
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions src/views/PurchaseOrder.vue
Original file line number Diff line number Diff line change
Expand Up @@ -133,21 +133,21 @@ export default defineComponent({
return !this.fieldMappings[id] ? id : this.generateUniqueMappingPrefId();
},
saveMapping() {
if (this.mappingName && this.file && this.areAllFieldsSelected()) {
showToast(translate("Mapping saved successfully"));
const mappingPrefId = this.generateUniqueMappingPrefId();
this.store.dispatch('user/updateFieldMappings', { mappingPrefId, mappingPrefName: this.mappingName, mappingPrefValue: JSON.parse(JSON.stringify(this.fieldMapping)) })
} else {
if(!this.mappingName) {
showToast(translate("Enter mapping name"));
}
if (!this.file) {
showToast(translate("Upload a file"));
}
if (!this.areAllFieldsSelected()) {
showToast(translate("Map all fields"));
}
if(!this.mappingName) {
showToast(translate("Enter mapping name"));
return
}
if (!this.file) {
showToast(translate("Upload a file"));
return
}
if (!this.areAllFieldsSelected()) {
showToast(translate("Map all fields"));
return
}
const mappingPrefId = this.generateUniqueMappingPrefId();
this.store.dispatch('user/updateFieldMappings', { mappingPrefId, mappingPrefName: this.mappingName, mappingPrefValue: JSON.parse(JSON.stringify(this.fieldMapping)) })
showToast(translate("Mapping saved successfully"));
},
getFile(event) {
this.file = event.target.files[0];
Expand Down

0 comments on commit 48f9f17

Please sign in to comment.