From 88e3da281b57eb1a69e0be4c8522721a49a0f986 Mon Sep 17 00:00:00 2001 From: yingfeng Date: Wed, 7 Aug 2024 05:42:47 -0400 Subject: [PATCH] AMP-2532: fix entity validation typo --- src/service/entity-service.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/service/entity-service.js b/src/service/entity-service.js index 655b069..b33cead 100644 --- a/src/service/entity-service.js +++ b/src/service/entity-service.js @@ -21,18 +21,23 @@ export default class EntityService { async onUpdateEntityDetails(self) { if (self.baseUrl === 'unit') { - self.unitService.updateUnitDetails(self.selectedUnit.id, self.entity).then(response => { - self.isDataChanged = false; - self.$bvToast.toast("Unit details updated successfully.", self.sharedService.successToastConfig); - }); + // unit Validation rules if (!self.entity.name || !self.entity.taskManager) { self.$bvToast.toast("Please provide required fields!", self.sharedService.erorrToastConfig); return false; } + self.unitService.updateUnitDetails(self.selectedUnit.id, self.entity).then(response => { + self.isDataChanged = false; + self.$bvToast.toast("Unit details updated successfully.", self.sharedService.successToastConfig); + }); } else if (self.baseUrl === 'collection') { self.submitted = true; // Collection Validation rules + if (!self.entity.name) { + self.$bvToast.toast("Please provide required fields!", self.sharedService.erorrToastConfig); + return false; + } if (!self.isCreatePage) { self.collectionService.updateCollection(self.entity).then(response => { self.$bvToast.toast("Collection details updated successfully", self.sharedService.successToastConfig); @@ -70,7 +75,8 @@ export default class EntityService { } } else if (self.baseUrl === 'file') { self.submitted = true; - // Collection Validation rules + + // file Validation rules if (!self.entity.name) { self.$bvToast.toast("Please provide required fields!", self.sharedService.erorrToastConfig); return false; @@ -96,7 +102,7 @@ export default class EntityService { } else if (self.baseUrl === 'item') { self.submitted = true; - // Collection Validation rules + // item Validation rules if (!self.entity.name) { self.$bvToast.toast("Please provide required fields!", self.sharedService.erorrToastConfig); return false; @@ -115,7 +121,6 @@ export default class EntityService { self.selectedItem.selectedItemId = response.id; self.isDataChanged = false; self.$router.push("/collections/items/details"); - // self.$router.push("/collection/details"); }).catch(error => { self.showLoader = false; self.submitted = false; @@ -131,7 +136,6 @@ export default class EntityService { self.itemService.updateItem(self.entity).then(success => { self.showLoader = false; self.$bvToast.toast("Item details updated successfully", { title: 'Notification', appendToast: true, variant: "success", autoHideDelay: 5000 }); - // self.showEdit = !self.showEdit; self.submitted = false; self.isDataChanged = false; }).catch(error => {