Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AMP-2826: incomplete code changes #502

Merged
merged 3 commits into from
Apr 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
11 changes: 9 additions & 2 deletions src/components/entity/ItemSearch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ export default {
},
data() {
return {
workflowResultService: new WorkflowResultService(),
itemService: new ItemService(),
loading: false,
searchType: "",
searchSource: [],
workflowResultService: new WorkflowResultService(),
itemService: new ItemService(),
errors: {
search_error: "",
no_data_error: "",
Expand All @@ -66,12 +66,17 @@ export default {
computed: {},
props: {},
methods: {
// handler for handleSearchItems event emitted by child component (the Search pop-up ialog)
searchItems(searchWord) {
this.refreshData(searchWord);
},
// pop up child component (the Search pop-up ialog)
onSearch() {
this.$bvModal.show("modal-lg");
},
// call item search API
async refreshData(searchWord = "") {
const self = this;
try {
Expand All @@ -98,9 +103,11 @@ export default {
}
},
},
updated() {
this.onSearch();
},
mounted() {
this.onSearch();
},
Expand Down
130 changes: 77 additions & 53 deletions src/components/shared/Search.vue
Original file line number Diff line number Diff line change
Expand Up @@ -810,14 +810,18 @@ export default {
const self = this;
self.searchFields.rows[0] = self.searchFields.choosenField;
},

// called when search button clicked
async searchItems() {
this.$emit("handleSearchItems", this.searchWord);
},
// called when enter key pressed on keyword textarea
async searchKeyUp(e) {
if (e.keyCode === 13) {
this.searchItems();
}
},

onSelectAllChange(ev) {
const self = this;
if (ev.srcElement.checked) {
Expand All @@ -833,16 +837,19 @@ export default {
console.log("selectedRecords: ", self.selectedRecords);
return;
},

// event handler when selections in the search results list change
onChange(ev, record) {
const self = this;

// 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 +953,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 +1026,70 @@ 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);
// go to item detail page
self.$router.push("/collections/items/item-search/details");
// 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
Loading