diff --git a/src/views/FindGroups.vue b/src/views/FindGroups.vue index 92a238ba..9214cc96 100644 --- a/src/views/FindGroups.vue +++ b/src/views/FindGroups.vue @@ -205,9 +205,9 @@ export default defineComponent({ }, async mounted() { await this.store.dispatch('util/fetchFacilityGroupTypes') + await this.fetchGroups(); }, async ionViewWillEnter() { - await this.fetchGroups(); this.isScrollingEnabled = false; }, methods: { diff --git a/src/views/ManageFacilities.vue b/src/views/ManageFacilities.vue index a7c942a7..a241634f 100644 --- a/src/views/ManageFacilities.vue +++ b/src/views/ManageFacilities.vue @@ -34,9 +34,9 @@ -
+

{{ translate('Total facilities selected for group', {total: selectedFacilities.length, facilityGroupName: currentFacilityGroup.facilityGroupName ? currentFacilityGroup.facilityGroupName : facilityGroupId}) }}

- + {{ translate('Manage sequence') }} @@ -96,6 +96,7 @@ import { hasError } from '@/adapter'; import logger from '@/logger'; import { DateTime } from "luxon"; + import emitter from "@/event-bus"; export default defineComponent({ name: 'FindGroups', @@ -127,16 +128,21 @@ selectedFacilities: [] as any, toast: null as any, currentFacilityGroup: {} as any, - isFacilityMembersModified: false + isFacilityMembersModified: false, + isSavingDetail: false } }, props: ['facilityGroupId'], async mounted() { + emitter.emit('presentLoader') await Promise.all([this.fetchFacilities(), this.fetchFacilityGroup()]) await this.fetchMemberFacilities(); await this.getFilteredFacilities(); + emitter.emit('dismissLoader') }, async beforeRouteLeave() { + if (this.isSavingDetail) return; + let canLeave = false; const alert = await alertController.create({ header: translate("Leave page"), @@ -195,6 +201,15 @@ logger.error('Failed to fetch facility group', err) } }, + async fetchGroups(vSize?: any, vIndex?: any) { + const viewSize = vSize ? vSize : process.env.VUE_APP_VIEW_SIZE; + const viewIndex = vIndex ? vIndex : 0; + const payload = { + viewSize, + viewIndex + }; + await this.store.dispatch('facility/fetchFacilityGroups', payload) + }, async fetchFacilities() { this.facilities = [] let viewIndex = 0, resp @@ -299,6 +314,7 @@ this.isFacilityMembersModified = true; }, async save () { + this.isSavingDetail = true const facilitiesToAdd = this.selectedFacilities.filter((facility: any) => !facility.fromDate) const selectedFacilityIds = this.selectedFacilities ? new Set(this.selectedFacilities.map((facility:any) => facility.facilityId)) as any : []; const facilitiesToRemove = this.memberFacilities.filter((facility: any) => !selectedFacilityIds.has(facility.facilityId)) @@ -338,8 +354,8 @@ } else { showToast(translate("Member facilities updated successfully.")) } - this.fetchMemberFacilities(); this.isFacilityMembersModified = false; + await this.fetchGroups(); this.router.push({ path: `/tabs/find-groups` }) }, async doReorder(event: CustomEvent) {