Skip to content

Commit

Permalink
Fixed: SAVE MAPPING button saves empty mapping when file not uploaded…
Browse files Browse the repository at this point in the history
…(#326re7p)
  • Loading branch information
shashwatbangar committed Dec 5, 2022
1 parent 646ff9f commit 82dd0c0
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/views/PurchaseOrder.vue
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,20 @@ export default defineComponent({
return !this.fieldMappings[id] ? id : this.generateUniqueMappingPrefId();
},
saveMapping() {
if (this.mappingName) {
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 {
showToast(translate("Enter mapping name"));
if(!this.mappingName) {
showToast(translate("Enter mapping name"));
}
if (!this.file) {
showToast(translate("Upload a file"));
}
if (!this.areAllFieldsSelected()) {
showToast(translate("Map all fields"));
}
}
},
getFile(event) {
Expand Down Expand Up @@ -198,6 +207,9 @@ export default defineComponent({
this.mappingName = fieldMapping.mappingPrefName;
}
},
areAllFieldsSelected() {
return Object.values(this.fieldMapping).every(field => field !== "");
}
},
setup() {
const router = useRouter();
Expand Down

0 comments on commit 82dd0c0

Please sign in to comment.