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

Improved: showing loader till whole count detail is fetching and fixed units label showing in product item without quantity (#528) #595

Merged
merged 6 commits into from
Jan 9, 2025
2 changes: 1 addition & 1 deletion src/components/Filters.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</ion-item>
<ion-item button v-if="showAdditionalFilters().noFacility">
<ion-icon slot="start" :icon="locateOutline"/>
<ion-checkbox :value="query.noFacility" @ionChange="updateQuery('noFacility', $event.detail.checked)">{{ translate("No facility") }}</ion-checkbox>
<ion-checkbox v-model="query.noFacility" @ionChange="updateQuery('noFacility', $event.detail.checked)">{{ translate("No facility") }}</ion-checkbox>
</ion-item>

<ion-item lines="none">
Expand Down
4 changes: 3 additions & 1 deletion src/components/MatchProductModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
</template>

<div v-else-if="queryString && isSearching && !products.length" class="empty-state">
<p>{{ translate("No results found for", { queryString }) }}</p>
<p>{{ translate("No results found for", { queryString: prevSearchedQuery }) }}</p>
</div>
<div v-else class="empty-state">
<img src="../assets/images/empty-state-add-product-modal.png" alt="empty-state" />
Expand Down Expand Up @@ -95,6 +95,7 @@ let queryString = ref('');
const isSearching = ref(false);
const selectedProductId = ref("") as Ref<string>;
const isLoading = ref(false);
const prevSearchedQuery = ref("");

async function handleSearch() {
if(!queryString.value.trim()) {
Expand All @@ -120,6 +121,7 @@ async function getProducts() {
logger.error("Failed to fetch products", err)
}
products.value = productsList
prevSearchedQuery.value = queryString.value
isLoading.value = false;
}
function closeModal(payload = {}) {
Expand Down
5 changes: 3 additions & 2 deletions src/views/CountDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ const itemsList = computed(() => {
} else if (selectedSegment.value === 'pending') {
return cycleCountItems.value.itemList.filter(item =>(item.quantity === undefined || item.quantity === null) && item.itemStatusId === "INV_COUNT_CREATED");
} else if (selectedSegment.value === 'counted') {
// Based on discussion, item with rejected and completed status should be shown in the counted segment
return cycleCountItems.value.itemList.filter(item => item.quantity >= 0 || (item.itemStatusId === 'INV_COUNT_REJECTED' || item.itemStatusId === 'INV_COUNT_COMPLETED'));
} else if (selectedSegment.value === 'notCounted') {
return cycleCountItems.value.itemList.filter(item => !item.quantity && item.statusId === "INV_COUNT_REVIEW");
Expand All @@ -295,12 +296,14 @@ const barcodeInput = ref();
let isScanningInProgress = ref(false);

onIonViewDidEnter(async() => {
emitter.emit("presentLoader");
await Promise.allSettled([await fetchCycleCount(), store.dispatch("count/fetchCycleCountItems", { inventoryCountImportId : props?.id })])
selectedSegment.value = 'all';
queryString.value = '';
previousItem = itemsList.value[0]
await store.dispatch("product/currentProduct", itemsList.value[0])
barcodeInput.value?.$el?.setFocus();
emitter.emit("dismissLoader")
})

onIonViewDidLeave(async() => {
Expand Down Expand Up @@ -348,7 +351,6 @@ function inputCountValidation(event) {
}

async function fetchCycleCount() {
emitter.emit("presentLoader");
let payload = props?.id
let resp
try {
Expand All @@ -362,7 +364,6 @@ async function fetchCycleCount() {
logger.error(err)
showToast(translate("Something went wrong"))
}
emitter.emit("dismissLoader")
return;
}

Expand Down
4 changes: 2 additions & 2 deletions src/views/HardCountDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -253,12 +253,14 @@ let isScanningInProgress = ref(false);


onIonViewDidEnter(async() => {
emitter.emit("presentLoader");
await Promise.allSettled([fetchCycleCount(), await store.dispatch("count/fetchCycleCountItems", { inventoryCountImportId : props?.id })])
previousItem = itemsList.value[0];
await store.dispatch("product/currentProduct", itemsList.value?.length ? itemsList.value[0] : {})
barcodeInputRef.value?.$el?.setFocus();
selectedCountUpdateType.value = defaultRecountUpdateBehaviour.value
window.addEventListener('beforeunload', handleBeforeUnload);
emitter.emit("dismissLoader")
})

onIonViewDidLeave(async() => {
Expand Down Expand Up @@ -297,7 +299,6 @@ async function handleBeforeUnload() {
}

async function fetchCycleCount() {
emitter.emit("presentLoader");
try {
const resp = await CountService.fetchCycleCount(props?.id)
if(!hasError(resp)) {
Expand All @@ -309,7 +310,6 @@ async function fetchCycleCount() {
logger.error(err)
showToast(translate("Something went wrong"))
}
emitter.emit("dismissLoader")
}

function handleSegmentChange() {
Expand Down
4 changes: 2 additions & 2 deletions src/views/ProductItemList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
<ion-note v-else-if="item.itemStatusId === 'INV_COUNT_COMPLETED'" color="success">
{{ translate("accepted") }}
</ion-note>
<ion-badge slot="end" v-else-if="item.statusId === 'INV_COUNT_ASSIGNED' && ((item.quantity !== undefined && item.quantity !== null) || (item.scannedCount !== undefined && item.scannedCount !== null))">
<ion-badge slot="end" v-else-if="item.statusId === 'INV_COUNT_ASSIGNED' && ((item.quantity !== undefined && item.quantity !== null) || (item.scannedCount !== undefined && item.scannedCount !== null && item.scannedCount !== ''))">
{{ translate("units", { count: isItemAlreadyAdded(item) ? item.quantity : item.scannedCount }) }}
</ion-badge>
<ion-note v-else-if="item.quantity === undefined || item.quantity === null && item.statusId === 'INV_COUNT_ASSIGNED'">
<ion-note v-else-if="(item.quantity === undefined || item.quantity === null || item.scannedCount === '') && item.statusId === 'INV_COUNT_ASSIGNED'">
{{ translate("pending") }}
</ion-note>
<ion-note v-else-if="item.quantity >= 0 && item.statusId === 'INV_COUNT_REVIEW'">
Expand Down
Loading