Skip to content

Commit

Permalink
AMP-2826: incomplete code changes
Browse files Browse the repository at this point in the history
  • Loading branch information
yingfeng-iu committed Mar 25, 2024
1 parent 203036c commit 14c1c26
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 73 deletions.
28 changes: 8 additions & 20 deletions src/components/entity/EntityList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1283,7 +1283,7 @@ export default {
"unitEntity",
JSON.stringify({ ...self.unitEntity })
);
self.getData();
self.getEntityData();
//Checking Access Control
self.accessControlService.checkAccessControl(this);
},
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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: "" };
Expand All @@ -1519,7 +1507,7 @@ export default {
}
if (self.unitEntity.currentUnit) {
self.getData();
self.getEntityData();
}
let formHTML = document.getElementsByClassName("form")[0];
Expand Down
122 changes: 69 additions & 53 deletions src/components/shared/Search.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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") {
Expand Down Expand Up @@ -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 (
Expand Down

0 comments on commit 14c1c26

Please sign in to comment.