diff --git a/src/components/entity/ItemSearch.vue b/src/components/entity/ItemSearch.vue index 6e9be89c..87b5b98a 100644 --- a/src/components/entity/ItemSearch.vue +++ b/src/components/entity/ItemSearch.vue @@ -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: "", @@ -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 { @@ -98,9 +103,11 @@ export default { } }, }, + updated() { this.onSearch(); }, + mounted() { this.onSearch(); }, diff --git a/src/components/shared/Search.vue b/src/components/shared/Search.vue index 56cf6250..fcf57cf0 100644 --- a/src/components/shared/Search.vue +++ b/src/components/shared/Search.vue @@ -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) { @@ -833,6 +837,8 @@ export default { console.log("selectedRecords: ", self.selectedRecords); return; }, + + // event handler when selections in the search results list change onChange(ev, record) { const self = this; @@ -1032,9 +1038,11 @@ export default { "unitEntity", JSON.stringify({ ...uEntity }) ); - //checking permission + // checking permission if (uEntity && uEntity.currentUnit) - self.accessControlService.checkAccessControl(self); + self.accessControlService.checkAccessControl(self); + // go to item detail page + self.$router.push("/collections/items/item-search/details"); // this.itemService // .getItemDetails(this.selectedItemId) // .then((res) => { @@ -1064,22 +1072,22 @@ export default { // 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, - // }); - // }); + // 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":