@@ -76,7 +76,7 @@
{{ getFacilityGroupTypeDescription(currentFacilityGroupTypeId) }}
-
+
{{ translate('Selected groups') }} : 10
@@ -114,82 +114,6 @@
-
-
@@ -220,7 +144,6 @@ import {
IonTitle,
IonToolbar,
modalController,
- popoverController,
createAnimation
} from '@ionic/vue';
import { defineComponent } from 'vue';
@@ -229,12 +152,9 @@ import { useRouter } from 'vue-router';
import { mapGetters, useStore } from 'vuex';
import { translate } from '@hotwax/dxp-components'
import { customSort, showToast } from '@/utils';
-import CreateFacilityGroupModal from '@/components/CreateFacilityGroupModal.vue';
-import FacilityGroupActionsPopover from '@/components/FacilityGroupActionsPopover.vue';
import { FacilityService } from '@/services/FacilityService';
import { hasError } from '@/adapter';
import logger from '@/logger';
-import emitter from '@/event-bus';
import AddProductStoreToGroupModal from '@/components/AddProductStoreToGroupModal.vue';
import GroupTypeModal from "@/components/GroupTypeModal.vue";
import FacilityGroupDescriptionModal from "@/components/FacilityGroupDescriptionModal.vue";
@@ -285,21 +205,27 @@ export default defineComponent({
})
},
async mounted() {
- emitter.on('playAnimation', this.playAnimation);
+ this.playAnimation();
await this.store.dispatch('util/fetchFacilityGroupTypes')
},
- unmounted() {
- emitter.off('playAnimation', this.playAnimation);
- },
async ionViewWillEnter() {
await this.fetchGroups();
this.isScrollingEnabled = false;
},
methods: {
+ resetParentGroupPage() {
+ if (this.segment === 'facility-groups') {
+ this.currentFacilityGroupTypeId = ''
+ this.isParentGroupDetailAnimationCompleted = false;
+
+ } else {
+ this.playAnimation();
+ }
+ },
setCurrentFacilityGroupType(facilityGroupTypeId: string) {
this.currentFacilityGroupTypeId = facilityGroupTypeId
if (this.currentFacilityGroupTypeId && !this.isParentGroupDetailAnimationCompleted) {
- emitter.emit('playAnimation');
+ this.playAnimation();
this.isParentGroupDetailAnimationCompleted = true;
}
},
@@ -373,6 +299,16 @@ export default defineComponent({
await event.target.complete();
});
},
+ getAssociatedFacilityGroupIds(facilityGroupTypeId: any) {
+ const associatedfacilityGroupIds = [] as any
+
+ this.groups.map((group: any) => {
+ if(group.facilityGroupTypeId && group.facilityGroupTypeId === facilityGroupTypeId) {
+ associatedfacilityGroupIds.push(group.facilityGroupId)
+ }
+ })
+ return associatedfacilityGroupIds
+ },
createFacilityGroup(){
this.router.push('/create-facility-group');
},
@@ -391,93 +327,9 @@ export default defineComponent({
})
facilityLoginModal.present()
},
- async openCreateFacilityGroupModal() {
- const createVirtualFacility = await modalController.create({
- component: CreateFacilityGroupModal
- })
-
- createVirtualFacility.present()
- },
- async openFacilityGroupActionsPopover(event: Event, group: any) {
- const facilityGroupActionsPopover = await popoverController.create({
- component: FacilityGroupActionsPopover,
- event,
- showBackdrop: false,
- componentProps: { group }
- });
-
- facilityGroupActionsPopover.present();
-
- const result = await facilityGroupActionsPopover.onDidDismiss();
- if (result.data && result.data !== group.facilityGroupName) {
- try {
- const resp = await FacilityService.updateFacilityGroup({
- facilityGroupId: group.facilityGroupId,
- facilityGroupName: result.data
- })
-
- if (!hasError(resp)) {
- showToast(translate('Facility group renamed.'))
- const updatedGroups = JSON.parse(JSON.stringify(this.groups))
- .map((groupData: any) => {
- if (group.facilityGroupId === groupData.facilityGroupId) {
- groupData.facilityGroupName = result.data
- }
-
- return groupData
- })
- this.store.dispatch('facility/updateFacilityGroups', updatedGroups)
- } else {
- throw resp.data
- }
- } catch (error) {
- showToast(translate('Failed to rename facility group.'))
- logger.error('Failed to rename facility group.', error)
- }
- }
- },
manageFacilities(facilityGroup: any) {
this.router.push({ path: `/manage-facilities/${facilityGroup.facilityGroupId}`})
},
- getAssociatedFacilityGroupIds(facilityGroupTypeId: any) {
- const associatedfacilityGroupIds = [] as any
-
- this.groups.map((group: any) => {
- if(group.facilityGroupTypeId && group.facilityGroupTypeId === facilityGroupTypeId) {
- associatedfacilityGroupIds.push(group.facilityGroupId)
- }
- })
- return associatedfacilityGroupIds
- },
- async updateFacilityGroupAssociation(event: CustomEvent, prevAssociatedGroups: any, facilityGroupTypeId: string) {
- const selectedGroups = event.detail.value
- const groupsToAdd = selectedGroups.filter((selectedGroupId: string) => !prevAssociatedGroups.includes(selectedGroupId))
- const groupsToRemove = prevAssociatedGroups.filter((prevGroupId: string) => !selectedGroups.includes(prevGroupId))
- const updateGroupPayloads = [] as any
-
- if(!(groupsToAdd.length || groupsToRemove.length)) {
- return;
- }
-
- emitter.emit('presentLoader')
-
- groupsToAdd.map((facilityGroupId: any) => updateGroupPayloads.push({facilityGroupId, facilityGroupTypeId}))
- groupsToRemove.map((facilityGroupId: any) => updateGroupPayloads.push({facilityGroupId, facilityGroupTypeId: ''}))
-
- const responses = await Promise.allSettled(updateGroupPayloads
- .map(async (payload: any) => await FacilityService.updateFacilityGroup(payload))
- )
-
- const hasFailedResponse = responses.some((response: any) => response.status === 'rejected')
- if (hasFailedResponse) {
- showToast(translate("Failed to associate group with system group types."))
- } else {
- showToast(translate("Group associated to system group types."))
- }
-
- await this.fetchGroups()
- emitter.emit('dismissLoader')
- },
async openAddProductStoreToGroupModal(group: any) {
const addProductStoreToGroupModal = await modalController.create({
component: AddProductStoreToGroupModal,