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

fix: search not working on PO review page(#85zrmf7ed) #182

Merged
merged 7 commits into from
Feb 22, 2023
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
1 change: 1 addition & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
"New version available, please update the app.": "New version available, please update the app.",
"No field mapping found. Please create new.": "No field mapping found. Please create new.",
"No new file upload. Please try again": "No new file upload. Please try again",
"No results found": "No results found",
"No time zone found": "No time zone found",
"OMS": "OMS",
"OMS instance": "OMS instance",
Expand Down
56 changes: 47 additions & 9 deletions src/views/PurchaseOrderReview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<ion-content :fullscreen="true">
<div class="header">
<div class="search">
<ion-searchbar :placeholder="$t('Search products')" v-model="queryString" v-on:keyup.enter="queryString = $event.target.value; searchProduct(queryString)" />
<ion-searchbar :placeholder="$t('Search products')" @keyup.enter="queryString = $event.target.value; searchProduct(queryString)" />
</div>

<div class="filters">
Expand Down Expand Up @@ -51,13 +51,25 @@
</ion-item>
</div>
</div>
<div v-if="segmentSelected === 'all'">
<PurchaseOrderDetail :purchaseOrders="purchaseOrders" :itemsByPoId ="purchaseOrders.parsed" />
<div v-if="searchedProduct?.pseudoId">
<PurchaseOrderDetail :purchaseOrders="purchaseOrders" :itemsByPoId ="{[searchedProduct?.orderId]: [searchedProduct]}" />
</div>
<div v-for="(po, poId) in purchaseOrders.parsed" :key="poId" >
<PurchaseOrderDetail v-if="segmentSelected === poId" :itemsByPoId="{[poId]: po}" :purchaseOrders="purchaseOrders" />

<div class="ion-text-center" v-else-if="queryString">
<p>{{ $t("No results found")}}</p>
</div>

<div v-else>
<div v-if="segmentSelected === 'all'">
<PurchaseOrderDetail :purchaseOrders="purchaseOrders" :itemsByPoId ="purchaseOrders.parsed" />
</div>
<div v-for="(po, poId) in purchaseOrders.parsed" :key="poId" >
<PurchaseOrderDetail v-if="segmentSelected === poId" :itemsByPoId="{[poId]: po}" :purchaseOrders="purchaseOrders" />
</div>
</div>



<ion-fab vertical="bottom" horizontal="end" slot="fixed">
<ion-fab-button :disabled="isDateInvalid()" @click="save">
<ion-icon :icon="cloudUploadOutline" />
Expand All @@ -67,7 +79,7 @@
</ion-content>

<ion-footer>
<ion-segment @ionChange="selectAllItems($event.target.value)" v-model="segmentSelected">
<ion-segment @ionChange="selectAllItems($event.target.value); searchProduct(queryString);" v-model="segmentSelected">
<ion-segment-button value="all">
<ion-label>{{ $t("All") }}</ion-label>
</ion-segment-button>
Expand Down Expand Up @@ -189,19 +201,37 @@ export default defineComponent({
component: MissingSkuModal,
componentProps: { 'unidentifiedItems': this.purchaseOrders.unidentifiedItems }
});
missingSkuModal.onDidDismiss().then(() => {
this.searchProduct(this.queryString);
});

return missingSkuModal.present();
},
searchProduct(sku: any) {
const product = this.getProduct(sku);
this.searchedProduct = Object.values(this.purchaseOrders).flat().find((item: any) => {
return item.pseudoId === product.pseudoId;
})
if (!product?.pseudoId) {
this.searchedProduct = {};
return;
}
if(this.segmentSelected === 'all'){
this.searchedProduct = Object.values(this.purchaseOrders.parsed).flat().find((item: any) => {
return item.pseudoId === product.pseudoId;
})
} else {
this.searchedProduct = this.purchaseOrders.parsed[this.segmentSelected].find((item: any) => {
return item.pseudoId === product.pseudoId;
})
}
},
async openDateTimeParseErrorModal() {
const dateTimeParseErrorModal = await modalController.create({
component: DateTimeParseErrorModal,
componentProps: { numberOfItems: Object.values(this.purchaseOrders.parsed).flat().length, numberOfPos: Object.keys(this.purchaseOrders.parsed).length }
});
dateTimeParseErrorModal.onDidDismiss().then(() => {
this.searchProduct(this.queryString);
});

return dateTimeParseErrorModal.present();
},
async save(){
Expand Down Expand Up @@ -264,6 +294,10 @@ export default defineComponent({
const bulkAdjustmentModal = await modalController.create({
component: BulkAdjustmentModal,
});
bulkAdjustmentModal.onDidDismiss().then(() => {
this.searchProduct(this.queryString);
})

return bulkAdjustmentModal.present();
},
async openMissingFacilitiesModal() {
Expand All @@ -272,6 +306,10 @@ export default defineComponent({
component: MissingFacilityModal,
componentProps: { itemsWithMissingFacility, facilities: this.facilities }
});
missingFacilitiesModal.onDidDismiss().then(() => {
this.searchProduct(this.queryString);
});

return missingFacilitiesModal.present();
},
selectAllItems(segmentSelected: string) {
Expand Down