Skip to content

Commit

Permalink
Merge pull request hotwax#227 from amansinghbais/224-disable-modal-fav
Browse files Browse the repository at this point in the history
Improved: added validation on fav button in modal to associate facilites, groupType and product to a facility group (hotwax#224)
  • Loading branch information
ymaheshwari1 authored Mar 22, 2024
2 parents 83c4aa6 + 3f19c12 commit 6e521a7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/components/AddFacilityToGroupModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
</div>
</ion-list>
<ion-fab vertical="bottom" horizontal="end" slot="fixed">
<ion-fab-button @click="confirmSave()">
<ion-fab-button :disabled="!areFacilitiesUpdated()" @click="confirmSave()">
<ion-icon :icon="saveOutline" />
</ion-fab-button>
</ion-fab>
Expand Down Expand Up @@ -216,6 +216,11 @@ export default defineComponent({
};
await this.store.dispatch('facility/fetchFacilityGroups', payload)
},
areFacilitiesUpdated() {
if(this.selectedFacilities.length !== this.selectedFacilityValues.length) return true;
return this.selectedFacilityValues.some((selectedFacility: any) => !this.selectedFacilities.find((facility: any) => facility.facilityId === selectedFacility.facilityId))
}
},
setup() {
const store = useStore();
Expand Down
4 changes: 3 additions & 1 deletion src/components/AddProductStoreToGroupModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ export default defineComponent({
await this.store.dispatch('facility/updateFacilityGroups', this.groups)
},
areProductStoresUpdated() {
return JSON.stringify(this.selectedProductStoreValues) !== JSON.stringify(this.selectedProductStores)
if(this.selectedProductStores.length !== this.selectedProductStoreValues.length) return true;
return this.selectedProductStoreValues.some((selectedProductStore: any) => !this.selectedProductStores.find((productStore: any) => productStore.productStoreId === selectedProductStore.productStoreId))
}
},
setup() {
Expand Down
5 changes: 4 additions & 1 deletion src/components/GroupTypeModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
</form>

<ion-fab vertical="bottom" horizontal="end" slot="fixed">
<ion-fab-button @click="saveGroupType()">
<ion-fab-button :disabled="!isGroupTypeUpdated()" @click="saveGroupType()">
<ion-icon :icon="saveOutline" />
</ion-fab-button>
</ion-fab>
Expand Down Expand Up @@ -118,6 +118,9 @@ export default defineComponent({
showToast(translate("Failed to update facility group type."))
logger.error(err)
}
},
isGroupTypeUpdated() {
return this.facilityGroup.facilityGroupTypeId !== this.facilityGroupValue.facilityGroupTypeId
}
},
setup() {
Expand Down

0 comments on commit 6e521a7

Please sign in to comment.