From b4c3f144b0dc3cd31a842ebf9fac27498299599d Mon Sep 17 00:00:00 2001 From: Ravi Lodhi Date: Mon, 12 Aug 2024 19:05:27 +0530 Subject: [PATCH] Improved: Removed unused code (#293). --- .../FacilityGroupActionsPopover.vue | 163 --------------- src/locales/en.json | 1 - src/views/FindGroups.vue | 196 +++--------------- 3 files changed, 24 insertions(+), 336 deletions(-) delete mode 100644 src/components/FacilityGroupActionsPopover.vue diff --git a/src/components/FacilityGroupActionsPopover.vue b/src/components/FacilityGroupActionsPopover.vue deleted file mode 100644 index ce5e42d8..00000000 --- a/src/components/FacilityGroupActionsPopover.vue +++ /dev/null @@ -1,163 +0,0 @@ - - - \ No newline at end of file diff --git a/src/locales/en.json b/src/locales/en.json index 00081290..8dbe839c 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -150,7 +150,6 @@ "Failed to remove facility mapping": "Failed to remove facility mapping", "Failed to remove party from facility.": "Failed to remove party from facility.", "Failed to remove shopify mapping": "Failed to remove shopify mapping", - "Failed to rename facility group.": "Failed to rename facility group.", "Failed to rename parking.": "Failed to rename parking.", "Failed to update facility group type.": "Failed to update facility group type.", "Failed to update group detail.": "Failed to update group detail.", diff --git a/src/views/FindGroups.vue b/src/views/FindGroups.vue index 18dd41a1..09ade837 100644 --- a/src/views/FindGroups.vue +++ b/src/views/FindGroups.vue @@ -3,8 +3,8 @@ {{ translate("Groups") }} - - + + {{ translate("Facility groups") }} @@ -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,