Skip to content

Commit

Permalink
Merge branch 'fix-select-all' of https://github.com/disha1202/import
Browse files Browse the repository at this point in the history
…into fix-select-all
  • Loading branch information
disha1202 committed Feb 22, 2023
2 parents d114b77 + a7477ac commit 0395c77
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 41 deletions.
32 changes: 10 additions & 22 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "import",
"version": "2.3.0",
"version": "2.4.0",
"private": true,
"description": "Import App",
"scripts": {
Expand All @@ -16,7 +16,7 @@
"@capacitor/core": "^2.4.7",
"@hotwax/app-version-info": "^1.0.0",
"@hotwax/apps-theme": "^1.1.0",
"@hotwax/oms-api": "^1.5.1",
"@hotwax/oms-api": "^1.6.0",
"@ionic/core": "6.2.9",
"@ionic/vue": "6.2.9",
"@ionic/vue-router": "6.2.9",
Expand Down
19 changes: 15 additions & 4 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { createAnimation, IonApp, IonRouterOutlet, IonSplitPane, loadingControll
import { defineComponent } from 'vue';
import emitter from "@/event-bus"
import { mapGetters, useStore } from 'vuex';
import { init, resetConfig } from '@/adapter'
import { initialise, resetConfig } from '@/adapter'
import { showToast } from "@/utils";
import { translate } from "@/i18n";
import { useRouter } from 'vue-router';
Expand Down Expand Up @@ -95,10 +95,22 @@ export default defineComponent({
emitter.on('presentLoader', this.presentLoader);
emitter.on('dismissLoader', this.dismissLoader);
emitter.on('playAnimation', this.playAnimation);
emitter.on('unauthorized', this.unauthorized);
},
created() {
init(this.userToken, this.instanceUrl, this.maxAge)
initialise({
token: this.userToken,
instanceUrl: this.instanceUrl,
cacheMaxAge: this.maxAge,
events: {
unauthorised: this.unauthorized,
responseErrror: () => {
setTimeout(() => this.dismissLoader(), 100);
},
queueTask: (payload: any) => {
emitter.emit("queueTask", payload);
}
}
})
document.addEventListener('swUpdated', this.updateAvailable, { once: true })
navigator.serviceWorker.addEventListener('controllerchange', () => {
if (this.refreshing) return
Expand All @@ -110,7 +122,6 @@ export default defineComponent({
emitter.off('presentLoader', this.presentLoader);
emitter.off('dismissLoader', this.dismissLoader);
emitter.off('playAnimation', this.playAnimation);
emitter.off('unauthorized', this.unauthorized);
resetConfig()
},
computed: {
Expand Down
4 changes: 2 additions & 2 deletions src/adapter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
api,
client,
fetchProducts,
init,
initialise,
isError,
Product,
resetConfig,
Expand All @@ -14,7 +14,7 @@ export {
api,
client,
fetchProducts,
init,
initialise,
isError,
Product,
resetConfig,
Expand Down
1 change: 1 addition & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,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
6 changes: 4 additions & 2 deletions src/logger/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ function getStack(error: any) {
export default {
install(app: any, options: any) {

app.config.errorHandler = (error: any, instance: any, info: any) => {
// We could pass error: any, instance: any, info: any
// TODO Use other variables to extract more information about the error
app.config.errorHandler = (error: any) => {
// TODO Improve code to add more information related to code failed
logger.error("Global handler:" + getStack(error));
}
Expand All @@ -66,4 +68,4 @@ export default {
log(...args: any): void {
logger.log(...args)
}
}
}
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 @@ -196,19 +208,37 @@ export default defineComponent({
component: MissingSkuModal,
componentProps: { 'unidentifiedItems': this.purchaseOrders.unidentifiedItems, type: 'order' }
});
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 @@ -271,6 +301,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 @@ -279,6 +313,10 @@ export default defineComponent({
component: MissingFacilitiesModal,
componentProps: { itemsWithMissingFacility, type: 'order' }
});
missingFacilitiesModal.onDidDismiss().then(() => {
this.searchProduct(this.queryString);
});
return missingFacilitiesModal.present();
},
selectAllItems(segmentSelected: string) {
Expand Down

0 comments on commit 0395c77

Please sign in to comment.