From 82dd0c07cff47209d633d2c86b5b5d3299089cf6 Mon Sep 17 00:00:00 2001 From: shashwatbangar Date: Mon, 5 Dec 2022 12:23:03 +0530 Subject: [PATCH] Fixed: SAVE MAPPING button saves empty mapping when file not uploaded(#326re7p) --- src/views/PurchaseOrder.vue | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/views/PurchaseOrder.vue b/src/views/PurchaseOrder.vue index facfd299..990d7311 100644 --- a/src/views/PurchaseOrder.vue +++ b/src/views/PurchaseOrder.vue @@ -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) { @@ -198,6 +207,9 @@ export default defineComponent({ this.mappingName = fieldMapping.mappingPrefName; } }, + areAllFieldsSelected() { + return Object.values(this.fieldMapping).every(field => field !== ""); + } }, setup() { const router = useRouter();