From 6f75144aaec077e578f5d832eaf83cea4bcf00d9 Mon Sep 17 00:00:00 2001 From: Ravi Lodhi Date: Mon, 12 Aug 2024 18:17:46 +0530 Subject: [PATCH 1/9] Improved: Updated facility groups ui as per the new design (#293). --- .../FacilityGroupDescriptionModal.vue | 26 +- src/locales/en.json | 21 +- src/router/index.ts | 7 + src/views/CreateFacilityGroup.vue | 226 +++++++++++++++ src/views/FindGroups.vue | 262 +++++++++++++++++- src/views/ManageFacilities.vue | 54 ++-- 6 files changed, 540 insertions(+), 56 deletions(-) create mode 100644 src/views/CreateFacilityGroup.vue diff --git a/src/components/FacilityGroupDescriptionModal.vue b/src/components/FacilityGroupDescriptionModal.vue index 0b649d2a..807d6385 100644 --- a/src/components/FacilityGroupDescriptionModal.vue +++ b/src/components/FacilityGroupDescriptionModal.vue @@ -6,13 +6,18 @@ - {{ facilityGroup?.description ? translate('Edit group description') : translate('Add group description') }} + {{ translate('Edit group detail') }} - +
{{ translate("Name") }} *
+ +
+ + { if (this.facilityGroup.facilityGroupId === groupData.facilityGroupId) { + groupData.facilityGroupName = this.facilityGroupName groupData.description = this.facilityGroupDescription } @@ -109,9 +124,8 @@ export default defineComponent({ } } catch (error) { - showToast(translate('Failed to update group description.')) + showToast(translate('Failed to update group detail.')) } - popoverController.dismiss(); this.closeModal(); emitter.emit('dismissLoader') }, diff --git a/src/locales/en.json b/src/locales/en.json index 837ffb50..00081290 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -4,7 +4,6 @@ "Add description": "Add description", "Add Group": "Add Group", "Add locations to facility": "Add locations to facility", - "Add group description": "Add group description", "Staff member": "Staff member", "Add Store": "Add Store", "Add Store Address": "Add Store Address", @@ -22,6 +21,7 @@ "aisle": "aisle", "All": "All", "Allow pickup": "Allow pickup", + "Any edits made on this page will be lost.": "Any edits made on this page will be lost.", "App": "App", "Apply": "Apply", "Archive": "Archive", @@ -77,9 +77,11 @@ "Distribution Center": "Distribution Center", "Edit description": "Edit description", "Failed to associate calendar to the facility.": "Failed to associate calendar to the facility.", + "Failed to associate group to parent group." : "Failed to associate group to parent group.", + "Failed to remove group from parent group.": "Failed to remove group from parent group.", "Filters": "Filters", "Edit": "Edit", - "Edit group description": "Edit group description", + "Edit details": "Edit details", "Edit location": "Edit location", "End Time": "End Time", "Facility group created.": "Facility group created.", @@ -97,13 +99,13 @@ "Facility created successfully.": "Facility created successfully.", "Facility configurations created successfully.": "Facility configurations created successfully.", "Facility contact updated successfully.": "Facility contact updated successfully.", - "Facility deselected. Click the save button to remove it from the group.": "Facility deselected. Click the save button to remove it from the group.", "Facility details": "Facility details", "Facility External ID": "Facility External ID", "Facility external ID updated.": "Facility external ID updated.", "Facility group deleted.": "Facility group deleted.", "Facility group type updated successfully.": "Facility group type updated successfully.", "Facility group name cannot be empty": "Facility group name cannot be empty", + "Facility groups": "Facility groups", "Facility ID": "Facility ID", "Facility latitude and longitude removed successfully.": "Facility latitude and longitude removed successfully.", "Facility latitude and longitude updated successfully.": "Facility latitude and longitude updated successfully.", @@ -116,7 +118,6 @@ "Facility name is required.": "Facility name is required.", "Facility Management": "Facility Management", "Facility renamed successfully.": "Facility renamed successfully.", - "Facility selected. Click the save button to add it to the group.": "Facility selected. Click the save button to add it to the group.", "Facility SubType": "Facility SubType", "Facility Type": "Facility Type", "Facility zipcode": "Facility zipcode", @@ -152,6 +153,7 @@ "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.", "Failed to update some groups for facility": "Failed to update some groups for facility", "Facility type updated": "Facility type updated", "Failed to unarchive parking.": "Failed to unarchive parking.", @@ -163,7 +165,6 @@ "Failed to update facility type.": "Failed to update facility type.", "Failed to update fulfillment capacity for ": "Failed to update fulfillment capacity for {facilityName}", "Failed to update fulfillment setting": "Failed to update fulfillment setting", - "Failed to update group description.": "Failed to update group description.", "Failed to update primary product store": "Failed to update primary product store", "Failed to update sell inventory online setting": "Failed to update sell inventory online setting", "Failed to update shopify mapping": "Failed to update shopify mapping", @@ -184,13 +185,16 @@ "Go to Launchpad": "Go to Launchpad", "Go to OMS": "Go to OMS", "Group": "Group", + "Group associated to parent group.": "Group associated to parent group.", "Group associated to system group types.": "Group associated to system group types.", + "Group detail updated.": "Group detail updated.", "Group type": "Group type", "Group unlinked from facility": "Group unlinked from facility", "groups": "{count} groups", "Groups": "Groups", "group description": "group description", "Group description updated.": "Group description updated.", + "Group removed from parent group.": "Group removed from parent group.", "Identification": "Identification", "Include all": "Include all", "Internal ID": "Internal ID", @@ -201,6 +205,8 @@ "Language": "Language", "Latitude": "Latitude", "Latitude & Longitude": "Latitude & Longitude", + "LEAVE": "LEAVE", + "Leave page": "Leave page", "Level": "Level", "level": "level", "Link to groups": "Link to groups", @@ -264,6 +270,8 @@ "Outlet Store logins": "Outlet Store logins", "Outlet Warehouse login": "Outlet Warehouse login", "Outlet Warehouse logins": "Outlet Warehouse logins", + "Parent group associations": "Parent group associations", + "Parent groups": "Parent groups", "Parking": "Parking", "Parking archived successfully.": "Parking archived successfully.", "Parking renamed successfully.": "Parking renamed successfully.", @@ -317,7 +325,6 @@ "Save configurations": "Save configurations", "Section": "Section", "section": "section", - "System groups": "System groups", "Select": "Select", "Select a saved calendar of store hours or create a new calendar": "Select a saved calendar of store hours or create a new calendar", "Select country": "Select country", @@ -339,6 +346,7 @@ "Settings": "Settings", "Setting fulfillment capacity to 0 disables new order from being allocated to this facility. Leave this empty if this facility's fulfillment capacity is unrestricted.": "Setting fulfillment capacity to 0 disables new order from being allocated to this facility. Leave this empty if this facility's fulfillment capacity is unrestricted.", "Setup Store": "Setup Store", + "Selected groups": "Selected groups", "Selected TimeZone": "Selected TimeZone", "Shipping name": "Shipping name", "Shopify": "Shopify", @@ -353,6 +361,7 @@ "Staff": "Staff", "Start Time": "Start Time", "State": "State", + "Stay": "Stay", "Store": "Store", "Stores": "Stores", "store name": "store name", diff --git a/src/router/index.ts b/src/router/index.ts index 89508be1..127ef4e1 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -12,6 +12,7 @@ import AddFacilityAddress from '@/views/AddFacilityAddress.vue'; import AddFacilityConfig from '@/views/AddFacilityConfig.vue'; import Tabs from '@/components/Tabs.vue' import ManageFacilities from '@/views/ManageFacilities.vue'; +import CreateFacilityGroup from '@/views/CreateFacilityGroup.vue'; // Defining types for the meta values declare module 'vue-router' { @@ -107,6 +108,12 @@ const routes: Array = [ component: ManageFacilities, props: true, beforeEnter: authGuard, + }, + { + path: '/create-facility-group', + name: 'Create Facility Group', + component: CreateFacilityGroup, + beforeEnter: authGuard, } ] diff --git a/src/views/CreateFacilityGroup.vue b/src/views/CreateFacilityGroup.vue new file mode 100644 index 00000000..31e4be5f --- /dev/null +++ b/src/views/CreateFacilityGroup.vue @@ -0,0 +1,226 @@ + + + + diff --git a/src/views/FindGroups.vue b/src/views/FindGroups.vue index d674c84b..18dd41a1 100644 --- a/src/views/FindGroups.vue +++ b/src/views/FindGroups.vue @@ -3,9 +3,119 @@ {{ translate("Groups") }} + + + {{ translate("Facility groups") }} + + + {{ translate("Parent group associations") }} + + + + + + + + + + + + + + + + + @@ -74,20 +183,23 @@ :loading-text="translate('Loading')" /> + -
+ --> \ No newline at end of file diff --git a/src/views/ManageFacilities.vue b/src/views/ManageFacilities.vue index 6a0e05b0..a7c942a7 100644 --- a/src/views/ManageFacilities.vue +++ b/src/views/ManageFacilities.vue @@ -136,35 +136,32 @@ await this.fetchMemberFacilities(); await this.getFilteredFacilities(); }, - methods: { - async beforeRouteLeave() { - if(!this.toast) return - - let canLeave = false; - const alert = await alertController.create({ - header: translate("Leave page"), - message: translate("Any edits made on this page will be lost."), - buttons: [ - { - text: translate("STAY"), - handler: () => { - canLeave = false; - }, + async beforeRouteLeave() { + let canLeave = false; + const alert = await alertController.create({ + header: translate("Leave page"), + message: translate("Any edits made on this page will be lost."), + buttons: [ + { + text: translate("STAY"), + handler: () => { + canLeave = false; }, - { - text: translate("LEAVE"), - handler: () => { - canLeave = true; - this.toast.dismiss() - }, + }, + { + text: translate("LEAVE"), + handler: () => { + canLeave = true; }, - ], - }); + }, + ], + }); - alert.present() - await alert.onDidDismiss() - return canLeave - }, + alert.present() + await alert.onDidDismiss() + return canLeave + }, + methods: { getFilteredFacilities() { let nonMemberFacilities = this.facilities ? this.facilities : [] as any; const selectedFacilityIds = this.selectedFacilities ? new Set(this.selectedFacilities.map((facility:any) => facility.facilityId)) as any : []; @@ -279,7 +276,6 @@ this.selectedFacilities = [...this.selectedFacilities, {...facility, sequenceNum}] this.getFilteredFacilities(); this.isFacilityMembersModified = true; - showToast(translate("Facility selected. Click the save button to add it to the group.")) }, selectAll() { let sequenceNum = 1; @@ -296,13 +292,11 @@ this.selectedFacilities = [...this.selectedFacilities, ...facilitiesWithSequences] this.getFilteredFacilities(); this.isFacilityMembersModified = true; - showToast(translate("Facility selected. Click the save button to add it to the group.")) }, async removeFacility(facility: any) { this.selectedFacilities = this.selectedFacilities.filter((selectedFacility: any) => selectedFacility.facilityId !== facility.facilityId); this.getFilteredFacilities(); this.isFacilityMembersModified = true; - showToast(translate("Facility deselected. Click the save button to remove it from the group.")) }, async save () { const facilitiesToAdd = this.selectedFacilities.filter((facility: any) => !facility.fromDate) @@ -346,7 +340,7 @@ } this.fetchMemberFacilities(); this.isFacilityMembersModified = false; - this.$router.push({ path: `/tabs/find-groups` }) + this.router.push({ path: `/tabs/find-groups` }) }, async doReorder(event: CustomEvent) { const previousSeq = JSON.parse(JSON.stringify(this.selectedFacilities)) From b4c3f144b0dc3cd31a842ebf9fac27498299599d Mon Sep 17 00:00:00 2001 From: Ravi Lodhi Date: Mon, 12 Aug 2024 19:05:27 +0530 Subject: [PATCH 2/9] 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, From 6b05f2835032b08792825a51f0a6b480d99859e2 Mon Sep 17 00:00:00 2001 From: Ravi Lodhi Date: Mon, 12 Aug 2024 19:08:27 +0530 Subject: [PATCH 3/9] Improved: Removed unused code (#293). --- src/views/FindGroups.vue | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/views/FindGroups.vue b/src/views/FindGroups.vue index 09ade837..827bd8d3 100644 --- a/src/views/FindGroups.vue +++ b/src/views/FindGroups.vue @@ -205,7 +205,6 @@ export default defineComponent({ }) }, async mounted() { - this.playAnimation(); await this.store.dispatch('util/fetchFacilityGroupTypes') }, async ionViewWillEnter() { @@ -217,9 +216,6 @@ export default defineComponent({ if (this.segment === 'facility-groups') { this.currentFacilityGroupTypeId = '' this.isParentGroupDetailAnimationCompleted = false; - - } else { - this.playAnimation(); } }, setCurrentFacilityGroupType(facilityGroupTypeId: string) { From c14031e9282b9a8a3834ce09341d9e9c073716d8 Mon Sep 17 00:00:00 2001 From: Ravi Lodhi Date: Mon, 12 Aug 2024 19:16:49 +0530 Subject: [PATCH 4/9] Improved: Displayed associated facility count (#293). --- src/views/FindGroups.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/FindGroups.vue b/src/views/FindGroups.vue index 827bd8d3..e55e73de 100644 --- a/src/views/FindGroups.vue +++ b/src/views/FindGroups.vue @@ -87,7 +87,7 @@

{{ group.facilityGroupId }}

- 10 + {{ group.facilityCount }}
From 447ecee066d88d5a56352d259095b192d86aa136 Mon Sep 17 00:00:00 2001 From: Ravi Lodhi Date: Tue, 13 Aug 2024 17:59:17 +0530 Subject: [PATCH 5/9] Improved: Displayed facility count in chip (#293). --- src/views/FindGroups.vue | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/views/FindGroups.vue b/src/views/FindGroups.vue index e55e73de..92a238ba 100644 --- a/src/views/FindGroups.vue +++ b/src/views/FindGroups.vue @@ -45,10 +45,9 @@ {{ translate('Facilities') }} - {{ group.facilityCount }} - - - + + {{ group.facilityCount}} + {{translate('Edit details')}} @@ -147,7 +146,7 @@ import { createAnimation } from '@ionic/vue'; import { defineComponent } from 'vue'; -import { ellipsisVerticalOutline, addOutline, bagHandleOutline, businessOutline, settingsOutline } from 'ionicons/icons'; +import { ellipsisVerticalOutline, addOutline, bagHandleOutline, businessOutline } from 'ionicons/icons'; import { useRouter } from 'vue-router'; import { mapGetters, useStore } from 'vuex'; import { translate } from '@hotwax/dxp-components' @@ -368,7 +367,6 @@ export default defineComponent({ businessOutline, customSort, ellipsisVerticalOutline, - settingsOutline, router, store, translate From 6582426f067d28937959ffdbed217edf9e719960 Mon Sep 17 00:00:00 2001 From: Ravi Lodhi Date: Tue, 13 Aug 2024 19:05:08 +0530 Subject: [PATCH 6/9] Improved: Fetched groups detail on save from manage facilities page. Also added loader on manage facilities page. (#293) --- src/views/FindGroups.vue | 2 +- src/views/ManageFacilities.vue | 24 ++++++++++++++++++++---- 2 files changed, 21 insertions(+), 5 deletions(-) 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) { From 29b9ed2b6bbd43a40e674d4f0ffe447551b6400f Mon Sep 17 00:00:00 2001 From: Ravi Lodhi Date: Wed, 14 Aug 2024 10:27:35 +0530 Subject: [PATCH 7/9] Improved: Added support to associate product store with facility group on group creation. (#293) --- src/views/CreateFacilityGroup.vue | 20 +++++++++++++++++++- src/views/FindGroups.vue | 2 +- src/views/ManageFacilities.vue | 10 ---------- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/views/CreateFacilityGroup.vue b/src/views/CreateFacilityGroup.vue index 31e4be5f..b5b64a1f 100644 --- a/src/views/CreateFacilityGroup.vue +++ b/src/views/CreateFacilityGroup.vue @@ -82,6 +82,7 @@ import { useRouter } from 'vue-router' import { hasError } from "@/adapter"; import { generateInternalId, showToast } from "@/utils"; import logger from "@/logger"; +import { DateTime } from "luxon"; export default defineComponent({ name: "CreateFacilityGroup", @@ -103,7 +104,6 @@ export default defineComponent({ }, computed: { ...mapGetters({ - groups: 'facility/getFacilityGroups', facilityGroupTypes: 'util/getFacilityGroupTypes', productStores: 'util/getProductStores', }) @@ -157,6 +157,9 @@ export default defineComponent({ const resp = await FacilityService.createFacilityGroup(payload); if (!hasError(resp)) { const facilityGroupId = resp.data.facilityGroupId + if (this.formData.productStoreId) { + await this.associateFacilityGroupToStore(this.formData.productStoreId, facilityGroupId); + } await this.manageFacilityAlert(facilityGroupId) } else { throw resp.data; @@ -166,11 +169,26 @@ export default defineComponent({ showToast(translate('Failed to create facility group.')) } }, + async associateFacilityGroupToStore(productStoreId: string, facilityGroupId: string) { + try { + const resp = await FacilityService.createProductStoreFacilityGroup({ + "productStoreId": productStoreId, + "facilityGroupId": facilityGroupId, + "fromDate": DateTime.now().toMillis() + }) + if (hasError(resp)) { + throw resp; + } + } catch (error) { + logger.error(error) + } + }, async manageFacilityAlert(facilityGroupId: string) { const message = 'Creating group without facilities is essentially empty. Would you prefer to associate facilities during group creation or allow for later addition?' const alert = await alertController.create({ header: translate('Add facilities'), message: translate(message), + backdropDismiss: false, buttons: [ { text: translate("Skip"), diff --git a/src/views/FindGroups.vue b/src/views/FindGroups.vue index 9214cc96..92a238ba 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 a241634f..b47e5270 100644 --- a/src/views/ManageFacilities.vue +++ b/src/views/ManageFacilities.vue @@ -201,15 +201,6 @@ 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 @@ -355,7 +346,6 @@ showToast(translate("Member facilities updated successfully.")) } this.isFacilityMembersModified = false; - await this.fetchGroups(); this.router.push({ path: `/tabs/find-groups` }) }, async doReorder(event: CustomEvent) { From c368dd20be6b9bccd6342f7404bb9b67d3d924b8 Mon Sep 17 00:00:00 2001 From: Ravi Lodhi Date: Wed, 14 Aug 2024 11:40:21 +0530 Subject: [PATCH 8/9] Improved: Added option to select multiple product stores while creating group. (#293) --- src/locales/en.json | 4 +++ src/views/CreateFacilityGroup.vue | 43 ++++++++++++++++++++----------- 2 files changed, 32 insertions(+), 15 deletions(-) diff --git a/src/locales/en.json b/src/locales/en.json index 8dbe839c..da3075af 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -52,7 +52,9 @@ "Contact number": "Contact number", "Country": "Country", "Create ": "Create ", + "Create a new group": "Create a new group", "Create Distribution Center login": "Create Distribution Center login", + "Create group": "Create group", "Create login credentials": "Create login credentials", "Create Outlet Store": "Create Outlet Store", "Create Outlet Store login": "Create Outlet Store login", @@ -296,7 +298,9 @@ "primary store": "primary store", "Product Store": "Product Store", "Product Stores": "Product Stores", + "Product store": "Product store", "Product stores": "Product stores", + "product stores": "{count} product stores", "Product stores updated successfully.": "Product stores updated successfully.", "Quick edit": "Quick edit", "Reason:": "Reason:", diff --git a/src/views/CreateFacilityGroup.vue b/src/views/CreateFacilityGroup.vue index b5b64a1f..99f9f334 100644 --- a/src/views/CreateFacilityGroup.vue +++ b/src/views/CreateFacilityGroup.vue @@ -24,16 +24,16 @@ - + {{ facilityGroupType.description ? facilityGroupType.description : facilityGroupType.facilityGroupTypeId }} - + - {{ productStore.storeName ? productStore.storeName : productStore.productStoreId }} + {{ productStore.storeName ? productStore.storeName : productStore.productStoreId }} @@ -45,7 +45,7 @@
- {{ translate("Create Group") }} + {{ translate("Create group") }}
@@ -59,6 +59,9 @@ import { IonBackButton, IonButton, + IonCard, + IonCardHeader, + IonCardTitle, IonContent, IonHeader, IonIcon, @@ -89,6 +92,9 @@ export default defineComponent({ components: { IonBackButton, IonButton, + IonCard, + IonCardHeader, + IonCardTitle, IonContent, IonHeader, IonIcon, @@ -115,9 +121,9 @@ export default defineComponent({ facilityGroupName: '', facilityGroupTypeId: '', description: '', - productStoreId: '' }, isFacilityGroupTypeDisabled: false, + selectedProductStoreIds: [] } }, props: ['selectedFacilityGroupTypeId'], @@ -129,6 +135,10 @@ export default defineComponent({ } }, methods: { + updateFacilityGroupProductStores(event: any) { + const selectedProductStoreIds = event.detail.value; + this.selectedProductStoreIds = selectedProductStoreIds + }, setFacilityGroupId(event: any) { this.formData.facilityGroupId = generateInternalId(event.target.value) }, @@ -157,8 +167,8 @@ export default defineComponent({ const resp = await FacilityService.createFacilityGroup(payload); if (!hasError(resp)) { const facilityGroupId = resp.data.facilityGroupId - if (this.formData.productStoreId) { - await this.associateFacilityGroupToStore(this.formData.productStoreId, facilityGroupId); + if (this.selectedProductStoreIds.length > 0) { + await this.associateFacilityGroupToStore(facilityGroupId, this.selectedProductStoreIds); } await this.manageFacilityAlert(facilityGroupId) } else { @@ -169,15 +179,18 @@ export default defineComponent({ showToast(translate('Failed to create facility group.')) } }, - async associateFacilityGroupToStore(productStoreId: string, facilityGroupId: string) { + async associateFacilityGroupToStore(facilityGroupId: string, productStoreIds: string[]) { try { - const resp = await FacilityService.createProductStoreFacilityGroup({ - "productStoreId": productStoreId, - "facilityGroupId": facilityGroupId, - "fromDate": DateTime.now().toMillis() - }) - if (hasError(resp)) { - throw resp; + const responses = await Promise.allSettled(productStoreIds + .map(async (productStoreId: any) => await FacilityService.createProductStoreFacilityGroup({ + "productStoreId": productStoreId, + "facilityGroupId": facilityGroupId, + "fromDate": DateTime.now().toMillis() + })) + ) + const hasFailedResponse = responses.some((response: any) => response.status === 'rejected') + if (hasFailedResponse) { + console.log("Error in associating group to some of the product stores") } } catch (error) { logger.error(error) From fe66e7cf9ee3a487145ac81fe3cba6f3df7af633 Mon Sep 17 00:00:00 2001 From: Ravi Lodhi Date: Wed, 14 Aug 2024 12:08:29 +0530 Subject: [PATCH 9/9] Fixed: Facility group search. (#293) --- src/store/modules/facility/actions.ts | 3 +++ src/views/FindGroups.vue | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/store/modules/facility/actions.ts b/src/store/modules/facility/actions.ts index 6d7e7613..690d9d4d 100644 --- a/src/store/modules/facility/actions.ts +++ b/src/store/modules/facility/actions.ts @@ -721,6 +721,9 @@ const actions: ActionTree = { } total = resp.data.count } else { + if (payload.viewIndex === 0 ) { + groups = [] + } throw resp.data } } catch (error) { diff --git a/src/views/FindGroups.vue b/src/views/FindGroups.vue index 92a238ba..ed1b8d17 100644 --- a/src/views/FindGroups.vue +++ b/src/views/FindGroups.vue @@ -21,7 +21,7 @@
-
+