Skip to content

Commit

Permalink
Merge pull request #74 from amansinghbais/facilities/#70
Browse files Browse the repository at this point in the history
Improved: logic for adding and removing product store in selectProductStore modal and fav-button disable property. (#70)
  • Loading branch information
ravilodhi authored Dec 8, 2023
2 parents 1275831 + 07df884 commit 1f4ffb0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
11 changes: 4 additions & 7 deletions src/components/SelectProductStoreModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</ion-item>
</ion-list>
<ion-fab vertical="bottom" horizontal="end" slot="fixed">
<ion-fab-button :disabled="isProductStoreUpdated()" @click="saveProductStores()">
<ion-fab-button @click="saveProductStores()">
<ion-icon :icon="saveOutline" />
</ion-fab-button>
</ion-fab>
Expand Down Expand Up @@ -73,7 +73,7 @@ export default defineComponent({
facilityProductStores: 'facility/getFacilityProductStores',
})
},
props: ["facilityId", "selectedProductStores"],
props: ["selectedProductStores"],
data() {
return {
selectedProductStoreValues: JSON.parse(JSON.stringify(this.selectedProductStores)),
Expand All @@ -84,8 +84,8 @@ export default defineComponent({
modalController.dismiss({ dismissed: true});
},
async saveProductStores() {
const productStoresToCreate = this.selectedProductStoreValues.filter((selectedFacility: any) => !this.selectedProductStores.some((facility: any) => facility.facilityId === selectedFacility.facilityId))
const productStoresToRemove = this.selectedProductStores.filter((facility: any) => !this.selectedProductStoreValues.some((selectedFacility: any) => facility.facilityId === selectedFacility.facilityId))
const productStoresToCreate = this.selectedProductStoreValues.filter((selectedStore: any) => !this.selectedProductStores.some((store: any) => store.productStoreId === selectedStore.productStoreId))
const productStoresToRemove = this.selectedProductStores.filter((store: any) => !this.selectedProductStoreValues.some((selectedStore: any) => store.productStoreId === selectedStore.productStoreId))
modalController.dismiss({
dismissed: true,
Expand All @@ -108,9 +108,6 @@ export default defineComponent({
},
isSelected(productStoreId: string) {
return this.selectedProductStoreValues.some((productStore: any) => productStore.productStoreId === productStoreId);
},
isProductStoreUpdated() {
return this.selectedProductStoreValues.some((selectedStore: any) => this.selectedProductStores.some((store: any) => store.productStoreId === selectedStore.productStoreId));
}
},
setup() {
Expand Down
2 changes: 1 addition & 1 deletion src/views/FacilityDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ export default defineComponent({
async selectProductStores() {
const selectProductStoreModal = await modalController.create({
component: SelectProductStoreModal,
componentProps: { facilityId: this.facilityId, selectedProductStores: this.facilityProductStores }
componentProps: { selectedProductStores: this.facilityProductStores }
})
selectProductStoreModal.onDidDismiss().then(async(result: any) => {
Expand Down

0 comments on commit 1f4ffb0

Please sign in to comment.