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: Deselecting a single product from a group, deselects all variants(#2kbkwnr) #51

Merged
merged 9 commits into from
Nov 2, 2022
21 changes: 14 additions & 7 deletions src/views/OrderDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@

<div />

<ion-checkbox :checked="isParentProductChecked(id)" @ionChange="selectParentProduct(id, $event)" />
<ion-checkbox :checked="isParentProductChecked(id)" @click="handleChange(true)" @ionChange="selectParentProduct(id, $event)" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of having separate method, I think we could call selectParentProduct(id, $event) on click

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we call selectParentProduct on click it will not select/deselect all the variants as we won't be able to access the current value of checkbox


<ion-button fill="clear" color="medium" @click="UpdateProduct($event, id, true, getParentInformation(id, ordersList.items))">
<ion-icon slot="icon-only" :icon="ellipsisVerticalOutline" />
Expand Down Expand Up @@ -205,12 +205,16 @@ export default defineComponent({
facilities: [] as any,
queryString: "",
searchedProduct: {} as any,
handleOnChange: false
}
},
ionViewDidEnter(){
this.fetchFacilities();
},
methods: {
handleChange(value: any){
this.handleOnChange = value;
},
async listMissingSkus() {
const missingSkuModal = await modalController.create({
component: MissingSkuModal,
Expand Down Expand Up @@ -331,7 +335,7 @@ export default defineComponent({
return popover.present();
},
isParentProductChecked(parentProductId: string) {
const items = (this as any).ordersList.items.filter((item: any) => item.parentProductId === parentProductId)
const items = (this as any).getGroupItems(parentProductId, this.ordersList.items);
return items.every((item: any) => item.isSelected)
},
selectProduct(item: any, event: any) {
Expand Down Expand Up @@ -370,11 +374,14 @@ export default defineComponent({
})
},
selectParentProduct(parentProductId: any, event: any) {
this.ordersList.items.forEach((item: any) => {
if (item.parentProductId == parentProductId) {
item.isSelected = event.detail.checked;
}
})
if(this.handleOnChange){
this.ordersList.items.forEach((item: any) => {
if (item.parentProductId === parentProductId) {
item.isSelected = event.detail.checked;
}
})
}
this.handleOnChange = false;
}
},
setup() {
Expand Down