Skip to content

Commit

Permalink
Merge pull request #467 from amansinghbais/fix-count-detail-state
Browse files Browse the repository at this point in the history
Improved: state management on count update and tab change
  • Loading branch information
ravilodhi authored Oct 11, 2024
2 parents 306e69c + d43aaf2 commit 59bf248
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
7 changes: 6 additions & 1 deletion src/store/modules/count/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const actions: ActionTree<CountState, RootState> = {

const params = {
...payload,
pageSize: 100
pageSize: 200
}

if(state.query.facilityIds.length) {
Expand Down Expand Up @@ -176,9 +176,14 @@ const actions: ActionTree<CountState, RootState> = {
commit(types.COUNT_ITEMS_UPDATED, items)
},

async updateCycleCountItems ({ commit }, payload) {
commit(types.COUNT_ITEMS_UPDATED, { itemList: payload })
},

async clearCycleCountItems ({ commit }) {
commit(types.COUNT_ITEMS_UPDATED, [])
},

async fetchCycleCountImportSystemMessages({commit} ,payload) {

Check warning on line 187 in src/store/modules/count/actions.ts

View workflow job for this annotation

GitHub Actions / call-workflow-in-another-repo / reusable_workflow_job (18.x)

'payload' is defined but never used

Check warning on line 187 in src/store/modules/count/actions.ts

View workflow job for this annotation

GitHub Actions / call-workflow-in-another-repo / build_and_deploy

'payload' is defined but never used

Check warning on line 187 in src/store/modules/count/actions.ts

View workflow job for this annotation

GitHub Actions / call-workflow-in-another-repo / reusable_workflow_job (20.x)

'payload' is defined but never used
let systemMessages;
try {
Expand Down
20 changes: 15 additions & 5 deletions src/views/CountDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
<Image :src="getProduct(item.productId)?.mainImageUrl" />
</div>
</div>
<div class="detail">
<div class="detail" v-if="Object.keys(product)?.length">
<ion-item lines="none">
<ion-label class="ion-text-wrap">
<h1>{{ getProductIdentificationValue(productStoreSettings["productIdentificationPref"].primaryId, getProduct(product.productId)) }}</h1>
Expand Down Expand Up @@ -345,10 +345,11 @@ function updateFilteredItems() {
});
}
if (filteredItems.value.length > 0) {
store.dispatch("product/currentProduct", product.value);
updateNavigationState(filteredItems.value.indexOf(product.value));
const updatedProduct = Object.keys(product.value)?.length ? product.value : filteredItems.value[0]
store.dispatch("product/currentProduct", updatedProduct);
updateNavigationState(filteredItems.value.indexOf(updatedProduct));
} else {
store.dispatch("product/currentProduct", null);
store.dispatch("product/currentProduct", {});
isFirstItem.value = true
isLastItem.value = false
}
Expand Down Expand Up @@ -445,9 +446,18 @@ async function saveCount() {
product.value.quantity = inputCount.value
product.value.countedByGroupName = userProfile.value.userFullName
product.value.countedByUserLoginId = userProfile.value.username
await store.dispatch('product/currentProduct', product.value);
inputCount.value = '';
product.value.isRecounting = false;
const items = JSON.parse(JSON.stringify(itemsList.value))
items.map((item) => {
if(item.importItemSeqId === product.value?.importItemSeqId) {
item.quantity = product.value.quantity
item.countedByGroupName = userProfile.value.userFullName
item.countedByUserLoginId = userProfile.value.username
}
})
await store.dispatch('count/updateCycleCountItems', items);
await store.dispatch('product/currentProduct', product.value);
} else {
throw resp.data;
}
Expand Down

0 comments on commit 59bf248

Please sign in to comment.