diff --git a/src/components/entity/EntityList.vue b/src/components/entity/EntityList.vue index 63e43fe6..de03158d 100644 --- a/src/components/entity/EntityList.vue +++ b/src/components/entity/EntityList.vue @@ -1283,7 +1283,7 @@ export default { "unitEntity", JSON.stringify({ ...self.unitEntity }) ); - self.getData(); + self.getEntityData(); //Checking Access Control self.accessControlService.checkAccessControl(this); }, @@ -1325,9 +1325,10 @@ export default { console.log(error); } }, - async networkCalls() { + async getConfigs() { const self = this; try { + self.showLoader = true; const configPropertiesResponse = await self.configPropertiesService.getConfigProperties(); self.configProperties = configPropertiesResponse.data; @@ -1337,9 +1338,9 @@ export default { console.log(error); } }, - async getData() { + async getEntityData() { const self = this; - if (self.baseUrl === "unit") { + if (self.baseUrl === "unit" && self.selectedUnit) { self.getUnitDetails(); self.assignedRolesUnitChanged = true; self.settingsRolesUnitChanged = true; @@ -1487,25 +1488,12 @@ export default { mounted() { const self = this; self.showLoader = true; - if (self.baseUrl === "unit") { - this.networkCalls(); + if (!self.configProperties) { + self.getConfigs(); } // For unit details page const uEntity = JSON.parse(sessionStorage.getItem("unitEntity")); - - // TODO below checkAccessControl is unnecessary because it's done upon each unit change - // including change made in item search - // if (uEntity && uEntity.currentUnit) - // self.accessControlService.checkAccessControl(this); - - // if (!uEntity) { //} && !self.selectedUnit) { - // self.unitEntity = { unitList: [], currentUnit: "" }; - // self.getAllUnits(); - // } else { - // self.unitEntity = uEntity; - // self.getData(); - // } if (!uEntity) { self.unitEntity = { unitList: [], currentUnit: "" }; @@ -1519,7 +1507,7 @@ export default { } if (self.unitEntity.currentUnit) { - self.getData(); + self.getEntityData(); } let formHTML = document.getElementsByClassName("form")[0]; diff --git a/src/components/shared/Search.vue b/src/components/shared/Search.vue index cdfdfdfe..56cf6250 100644 --- a/src/components/shared/Search.vue +++ b/src/components/shared/Search.vue @@ -839,10 +839,11 @@ export default { // item-search allows only one record to be selected, so no need to handle selectedFilters/selectedRecords if (self.type === "item-search") { self.selectedItemId = record.id; - self.selectedUnit = {}; - self.selectedUnit.name = record.unitName; + self.selectedItem = record; self.selectedCollection = {}; - self.selectedCollection.name = record.collectionName; + self.selectedCollection.id = record.collectionId; + self.selectedUnit = {}; + self.selectedUnit.id = record.unitId; return; } // console.log(self.selectAll); @@ -946,10 +947,10 @@ export default { } }, addItem(item) { - const sefl = this; - sefl.selectedFilters[self.type] = sefl.selectedFilters[self.type] || []; - if (sefl.selectedFilters[self.type].indexOf(item) === -1) - sefl.selectedFilters[self.type].push(item); + const self = this; + self.selectedFilters[self.type] = self.selectedFilters[self.type] || []; + if (self.selectedFilters[self.type].indexOf(item) === -1) + self.selectedFilters[self.type].push(item); }, onCancel() { if (this.type === "item-search") { @@ -1019,53 +1020,68 @@ export default { : [] ); break; - case "item-search": - this.itemService - .getItemDetails(this.selectedItemId) - .then((res) => { - const self = this; - const selectedCollectionId = res._embedded.collection.id; - self.collectionDetailsService - .getCollection(selectedCollectionId) - .then((response) => { - self.selectedCollection = response.data; - //Updating unit id in our session storage for content page - const unitId = response.data._embedded.unit.id; - let uEntity = JSON.parse( - sessionStorage.getItem("unitEntity") - ); - uEntity = uEntity || {}; - console.log("Search: uEntity = " + uEntity); - uEntity.currentUnit = unitId; - sessionStorage.setItem( - "unitEntity", - JSON.stringify({ ...uEntity }) - ); - //checking permission - if (uEntity && uEntity.currentUnit) - self.accessControlService.checkAccessControl(self); - }); - self.selectedItem = res; - self.selectedItem.parentType = self.type; - self.selectedItem.unitName = self.selectedUnit.name; - self.selectedItem.collectionName = self.selectedCollection.name; - self.$router.push("/collections/items/item-search/details"); - }) - .catch((error) => { - this.dataSource = []; - this.clonedDataSource = []; - this.searchWord = ""; - this.selectedItemId = null; - this.errors.search_error = ""; - this.errors.no_data_error = ""; - this.$bvToast.toast("Failed to show the item", { - title: "Notification", - appendToast: true, - variant: "danger", - autoHideDelay: 5000, - }); - }); + case "item-search": { + console.log("item-search: selectedItemId: ", this.selectedItem.id, "selectedCollectionId: ", this.selectedCollection.id, "selectedUnitId: ", this.selectedUnit.id); + let uEntity = JSON.parse( + sessionStorage.getItem("unitEntity") + ); + uEntity = uEntity || {}; + console.log("item-search: uEntity = " + uEntity); + uEntity.currentUnit = this.selectedUnit.id; + sessionStorage.setItem( + "unitEntity", + JSON.stringify({ ...uEntity }) + ); + //checking permission + if (uEntity && uEntity.currentUnit) + self.accessControlService.checkAccessControl(self); + // this.itemService + // .getItemDetails(this.selectedItemId) + // .then((res) => { + // const self = this; + // const selectedCollectionId = res._embedded.collection.id; + // self.collectionDetailsService + // .getCollection(selectedCollectionId) + // .then((response) => { + // self.selectedCollection = response.data; + // //Updating unit id in our session storage for content page + // const unitId = response.data._embedded.unit.id; + // let uEntity = JSON.parse( + // sessionStorage.getItem("unitEntity") + // ); + // uEntity = uEntity || {}; + // console.log("Search: uEntity = " + uEntity); + // uEntity.currentUnit = unitId; + // sessionStorage.setItem( + // "unitEntity", + // JSON.stringify({ ...uEntity }) + // ); + // //checking permission + // if (uEntity && uEntity.currentUnit) + // self.accessControlService.checkAccessControl(self); + // }); + // self.selectedItem = res; + // self.selectedItem.parentType = self.type; + // self.selectedItem.unitName = self.selectedUnit.name; + // self.selectedItem.collectionName = self.selectedCollection.name; + self.$router.push("/collections/items/item-search/details"); + // }) + // .catch((error) => { + // this.dataSource = []; + // this.clonedDataSource = []; + // this.searchWord = ""; + // this.selectedItemId = null; + // this.errors.search_error = ""; + // this.errors.no_data_error = ""; + // this.$bvToast.toast("Failed to show the item", { + // title: "Notification", + // appendToast: true, + // variant: "danger", + // autoHideDelay: 5000, + // }); + // }); break; + } case "workflow-search": this.$emit("handleSearchWorkflows", this.searchFields); if (