Skip to content

Commit

Permalink
AMP-2532: fix entity validation typo
Browse files Browse the repository at this point in the history
  • Loading branch information
yingfeng-iu committed Aug 7, 2024
1 parent 8a9177a commit 88e3da2
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/service/entity-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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 => {
Expand Down

0 comments on commit 88e3da2

Please sign in to comment.