diff --git a/src/components/CreateFacilityGroupModal.vue b/src/components/CreateFacilityGroupModal.vue new file mode 100644 index 00000000..b4180869 --- /dev/null +++ b/src/components/CreateFacilityGroupModal.vue @@ -0,0 +1,191 @@ + + + \ No newline at end of file diff --git a/src/components/CreateVirtualFacilityModal.vue b/src/components/CreateVirtualFacilityModal.vue index a3c6710b..86b316be 100644 --- a/src/components/CreateVirtualFacilityModal.vue +++ b/src/components/CreateVirtualFacilityModal.vue @@ -106,17 +106,7 @@ export default defineComponent({ }, } }, - ionViewWillEnter() { - this.clearFormData() - }, methods: { - clearFormData() { - this.formData = { - facilityName: '', - facilityId: '', - description: '', - } - }, setFacilityId(event: any) { this.formData.facilityId = event.target.value.trim().toUpperCase().split(' ').join('_'); }, diff --git a/src/components/Filters.vue b/src/components/FacilityFilters.vue similarity index 94% rename from src/components/Filters.vue rename to src/components/FacilityFilters.vue index 54620715..716885dd 100644 --- a/src/components/Filters.vue +++ b/src/components/FacilityFilters.vue @@ -52,7 +52,7 @@ import { mapGetters, useStore } from 'vuex'; import { translate } from '@hotwax/dxp-components' export default defineComponent({ - name: 'Filters', + name: 'FacilityFilters', components: { IonContent, IonHeader, @@ -68,7 +68,7 @@ export default defineComponent({ }, computed: { ...mapGetters({ - query: "facility/getQuery", + query: "facility/getFacilityQuery", facilityTypes: "util/getFacilityTypes", productStores: "util/getProductStores" }) @@ -78,7 +78,7 @@ export default defineComponent({ menuController.close() }, async updateQuery() { - await this.store.dispatch('facility/updateQuery', this.query) + await this.store.dispatch('facility/updateFacilityQuery', this.query) this.closeMenu(); }, }, diff --git a/src/locales/en.json b/src/locales/en.json index 39a274c7..be2b41df 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -39,6 +39,7 @@ "Configure settings later": "Configure settings later", "Configure the order fulfillment capacity of your facility.": "Configure the order fulfillment capacity of your facility.", "Consumed Order Limit": "Consumed Order Limit", + "Create group": "Create group", "Create login credentials": "Create login credentials", "Create Outlet Store": "Create Outlet Store", "Create Outlet Warehouse": "Create Outlet Warehouse", @@ -60,6 +61,7 @@ "Edit": "Edit", "Edit location": "Edit location", "End Time": "End Time", + "Facility group created.": "Facility group created.", "External ID": "External ID", "External mapping created successfully": "External mapping created successfully", "External mapping updated successfully": "External mapping updated successfully", @@ -89,6 +91,7 @@ "Failed to create facility.": "Failed to create facility.", "Failed to create parking.": "Failed to create parking.", "Failed to create facility address.": "Failed to create facility address.", + "Failed to create facility group.": "Failed to create facility group.", "Failed to create facility location": "Failed to create facility location", "Failed to create facility login credentials.": "Failed to create facility login credentials.", "Failed to create shopify mapping": "Failed to create shopify mapping", @@ -156,6 +159,7 @@ "Monday": "Monday", "Name": "Name", "Netsuite": "Netsuite", + "New group": "New group", "New parking": "New parking", "New parking created successfully.": "New parking created successfully.", "Next brokering": "Next brokering", @@ -165,6 +169,7 @@ "No capacity sets the fulfillment capacity to 0, preventing any new orders from being allocated to this facility. Use the \"Reject all orders\" option in the fulfillment pages to clear your facilities fulfillment queue. To add a fulfillment capacity to this facility, use the custom option.": "No capacity sets the fulfillment capacity to 0, preventing any new orders from being allocated to this facility. Use the \"Reject all orders\" option in the fulfillment pages to clear your facilities fulfillment queue. To add a fulfillment capacity to this facility, use the custom option.", "No facilities found": "No facilities found", "No fulfillment capacity": "No fulfillment capacity", + "No groups found": "No groups found", "No party found": "No party found", "No product stores added.": "No product stores added.", "No records found": "No records found", @@ -226,6 +231,7 @@ "Select country": "Select country", "Select state": "Select state", "Search facilities": "Search facilities", + "Search groups": "Search groups", "Search time zones": "Search time zones", "Select time zone": "Select time zone", "Select product stores": "Select product stores", @@ -257,6 +263,7 @@ "Successfully created and associated calendar to the facility.": "Successfully created and associated calendar to the facility.", "Successfully regenerated latitude and longitude for the facility.": "Successfully regenerated latitude and longitude for the facility.", "Sunday": "Sunday", + "System group type": "System group type", "The timezone you select is used to ensure automations you schedule are always accurate to the time you select.": "The timezone you select is used to ensure automations you schedule are always accurate to the time you select.", "These values are used to help customers lookup how close they are to your stores when they are finding nearby stores.": "These values are used to help customers lookup how close they are to your stores when they are finding nearby stores.", "This is the name of the OMS you are connected to right now. Make sure that you are connected to the right instance before proceeding.": "This is the name of the OMS you are connected to right now. Make sure that you are connected to the right instance before proceeding.", diff --git a/src/router/index.ts b/src/router/index.ts index f129eb59..f04c782b 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -11,6 +11,7 @@ import FacilityManagement from '@/views/FacilityManagement.vue' import Settings from '@/views/Settings.vue'; import Parking from '@/views/Parking.vue'; import FindFacilities from '@/views/FindFacilities.vue'; +import FindGroups from '@/views/FindGroups.vue'; import CreateFacility from '@/views/CreateFacility.vue'; import AddFacilityAddress from '@/views/AddFacilityAddress.vue'; import AddFacilityConfig from '@/views/AddFacilityConfig.vue'; @@ -98,6 +99,12 @@ const routes: Array = [ component: Parking, beforeEnter: authGuard }, + { + path: '/find-groups', + name: 'FindGroups', + component: FindGroups, + beforeEnter: authGuard + }, { path: '/settings', name: 'Settings', diff --git a/src/services/FacilityService.ts b/src/services/FacilityService.ts index 54437894..1484c7de 100644 --- a/src/services/FacilityService.ts +++ b/src/services/FacilityService.ts @@ -175,8 +175,6 @@ const getFacilityProductStores = async (payload: any): Promise => { }) } - - const addPartyToFacility = async (payload: any): Promise => { return api({ url: "service/addPartyToFacility", @@ -185,8 +183,6 @@ const addPartyToFacility = async (payload: any): Promise => { }); } - - const removePartyFromFacility = async (payload: any): Promise => { return api({ url: "service/removePartyFromFacility", @@ -195,7 +191,6 @@ const removePartyFromFacility = async (payload: any): Promise => { }); } - const updateProductStoreFacility = async (payload: any): Promise => { return api({ url: "service/updateProductStoreFacility", @@ -212,7 +207,6 @@ const fetchFacilityLocations = async(payload: any): Promise => { }) } - const addFacilityToGroup = async (payload: any): Promise => { return api({ url: "service/addFacilityToGroup", @@ -484,6 +478,14 @@ const fetchOrderCountsByFacility = async (facilityIds: Array): Promise => { + return api({ + url: "performFind", + method: "post", + data: payload + }) +} + const fetchArchivedFacilities = async (): Promise => { let facilities = [] @@ -516,6 +518,56 @@ const fetchArchivedFacilities = async (): Promise => { return facilities } +const fetchFacilityCountByGroup = async (facilityGroupIds: any): Promise => { + if (!facilityGroupIds.length) return [] + const requests = [] + + const facilityGroupIdList = facilityGroupIds + while (facilityGroupIdList.length) { + const batch = facilityGroupIdList.splice(0, 10) + const params = { + inputFields: { + facilityGroupId: batch + }, + viewSize: 250, // maximum view size + entityName: 'FacilityGroupAndMember', + noConditionFind: "Y", + filterByDate: 'Y', + fieldList: ['facilityGroupId', 'facilityId'] + } + requests.push(params) + } + + const facilityCountResponse = await Promise.allSettled(requests.map((params) => api({ + url: 'performFind', + method: 'POST', + data: params + }))) + + const hasFailedResponse = facilityCountResponse.some((response: any) => hasError(response.value) && !response.data.count) + if (hasFailedResponse) { + logger.error('Failed to fetch facility count for some groups') + } + + // taking out the response from Promise.allSettled's 'value' field first + const allResponseData = facilityCountResponse.map((response: any) => response.value) + .reduce((responseData: any, response: any) => { + if (!hasError(response)) { + responseData.push(...response.data.docs) + } + return responseData + }, []) + + return allResponseData.reduce((facilityCountByGroup: any, responseData: any) => { + if (facilityCountByGroup[responseData.facilityGroupId]) { + facilityCountByGroup[responseData.facilityGroupId] += 1 + } else { + facilityCountByGroup[responseData.facilityGroupId] = 1 + } + return facilityCountByGroup + }, {}) +} + export const FacilityService = { addFacilityToGroup, addPartyToFacility, @@ -534,8 +586,10 @@ export const FacilityService = { deleteShopifyShopLocation, fetchArchivedFacilities, fetchFacilityGroup, + fetchFacilityGroups, fetchFacilityLocations, fetchFacilityContactDetails, + fetchFacilityCountByGroup, fetchFacilities, fetchFacilitiesOrderCount, fetchFacilityCalendar, diff --git a/src/services/UtilService.ts b/src/services/UtilService.ts index 40942436..23dd58cd 100644 --- a/src/services/UtilService.ts +++ b/src/services/UtilService.ts @@ -97,11 +97,20 @@ const fetchShopifyShops = async (payload: any): Promise => { }) } +const fetchFacilityGroupTypes = async (payload: any): Promise => { + return api({ + url: "performFind", + method: "post", + data: payload + }); +} + export const UtilService = { fetchCalendars, fetchCalendarWeekTimings, fetchCountries, fetchExternalMappingTypes, + fetchFacilityGroupTypes, fetchFacilityTypes, fetchLocationTypes, fetchProductStores, diff --git a/src/store/modules/facility/FacilityState.ts b/src/store/modules/facility/FacilityState.ts index 270ba163..14a54886 100644 --- a/src/store/modules/facility/FacilityState.ts +++ b/src/store/modules/facility/FacilityState.ts @@ -1,9 +1,12 @@ export default interface FacilityState { - query: { + facilityQuery: { queryString: string, productStoreId: string, facilityTypeId: string - }; + }, + groupQuery: { + queryString: string + }, facilities: { list: Array, total: number @@ -12,6 +15,10 @@ export default interface FacilityState { list: Array, total: number }; - archivedFacilities: Array, + facilityGroups: { + list: Array, + total: number + }; + archivedFacilities: Array; current: any; } \ No newline at end of file diff --git a/src/store/modules/facility/actions.ts b/src/store/modules/facility/actions.ts index afa9ff51..28701190 100644 --- a/src/store/modules/facility/actions.ts +++ b/src/store/modules/facility/actions.ts @@ -60,22 +60,22 @@ const actions: ActionTree = { 'facilityTypeId_op': 'notEqual', } as any - if(state.query.productStoreId) { - filters['productStoreId'] = state.query.productStoreId + if(state.facilityQuery.productStoreId) { + filters['productStoreId'] = state.facilityQuery.productStoreId filters['productStoreId_op'] = 'equals' } - if(state.query.facilityTypeId) { - filters['facilityTypeId'] = state.query.facilityTypeId + if(state.facilityQuery.facilityTypeId) { + filters['facilityTypeId'] = state.facilityQuery.facilityTypeId filters['facilityTypeId_op'] = 'equals' } - if(state.query.queryString) { - filters['facilityId_value'] = state.query.queryString + if(state.facilityQuery.queryString) { + filters['facilityId_value'] = state.facilityQuery.queryString filters['facilityId_op'] = 'contains' filters['facilityId_ic'] = 'Y' filters['facilityId_grp'] = '1' - filters['facilityName_value'] = state.query.queryString + filters['facilityName_value'] = state.facilityQuery.queryString filters['facilityName_op'] = 'contains' filters['facilityName_ic'] = 'Y' filters['facilityName_grp'] = '2' @@ -256,16 +256,23 @@ const actions: ActionTree = { commit(types.FACILITY_POSTAL_ADDRESS_UPDATED , postalAddress); }, - updateQuery({ commit }, query) { + updateFacilityQuery({ commit }, query) { commit(types.FACILITY_QUERY_UPDATED, query) }, + updateGroupQuery({ commit }, query) { + commit(types.FACILITY_GROUP_QUERY_UPDATED, query) + }, + clearFacilityState({ commit }) { commit(types.FACILITY_QUERY_UPDATED, { queryString: '', productStoreId: '', facilityTypeId: '' }) + commit(types.FACILITY_GROUP_QUERY_UPDATED, { + queryString: '', + }) commit(types.FACILITY_LIST_UPDATED , { facilities: [], total: 0 }); commit(types.FACILITY_CURRENT_UPDATED, {}); }, @@ -476,14 +483,6 @@ const actions: ActionTree = { logger.error(error) } - //Applying custom sorting to alwyas bring Brokering queue, Pre-order parking and backorder parking first. - const customOrder = ['BACKORDER_PARKING', 'PRE_ORDER_PARKING', '_NA_']; - facilities.sort((firstFacility:any, secondFacility:any) => { - const firstFacilityOrder = customOrder.indexOf(firstFacility.facilityId); - const secondFacilityOrder = customOrder.indexOf(secondFacility.facilityId); - return secondFacilityOrder - firstFacilityOrder; - }); - emitter.emit("dismissLoader"); commit(types.FACILITY_VIRTUAL_FACILITY_LIST_UPDATED, { facilities, total }); if (facilities.length) { @@ -550,12 +549,6 @@ const actions: ActionTree = { //Applying custom sorting to alwyas bring Brokering queue, Pre-order parking and backorder parking first. const facilities = [...state.virtualFacilities.list, facility] - const customOrder = ['BACKORDER_PARKING', 'PRE_ORDER_PARKING', '_NA_']; - facilities.sort((firstFacility:any, secondFacility:any) => { - const firstFacilityOrder = customOrder.indexOf(firstFacility.facilityId); - const secondFacilityOrder = customOrder.indexOf(secondFacility.facilityId); - return secondFacilityOrder - firstFacilityOrder; - }); commit(types.FACILITY_VIRTUAL_FACILITY_LIST_UPDATED, { facilities, total: facilities.length }); if (facilities.length) { @@ -580,6 +573,87 @@ const actions: ActionTree = { updateArchivedFacilities({ commit }, facilities) { commit(types.FACILITY_ARCHIVED_UPDATED, facilities) }, + + async fetchFacilityGroups({ commit, state, dispatch }, payload) { + let groups = [], total = 0; + if (payload.viewIndex === 0) emitter.emit("presentLoader"); + + const filters = {} as any + + // TODO add other filtering in UI and here + if (state.groupQuery.queryString) { + filters['facilityGroupId_value'] = state.groupQuery.queryString + filters['facilityGroupId_op'] = 'contains' + filters['facilityGroupId_ic'] = 'Y' + filters['facilityGroupId_grp'] = '1' + filters['facilityGroupName_value'] = state.groupQuery.queryString + filters['facilityGroupName_op'] = 'contains' + filters['facilityGroupName_ic'] = 'Y' + filters['facilityGroupName_grp'] = '2' + } + try { + const params = { + inputFields: { + ...filters + }, + entityName: "FacilityGroup", + noConditionFind: 'Y', + orderBy: "facilityGroupName ASC", + fieldList: ["facilityGroupId", "facilityGroupTypeId", "facilityGroupName", "description"], + ...payload + } + + const resp = await FacilityService.fetchFacilityGroups(params) + + if (!hasError(resp) && resp.data.count) { + groups = resp.data.docs + total = resp.data.count + + if (payload.viewIndex && payload.viewIndex > 0) { + groups = JSON.parse(JSON.stringify(state.facilityGroups.list)).concat(groups) + } + } else { + throw resp.data + } + } catch (error) { + logger.error(error) + } + + emitter.emit("dismissLoader"); + commit(types.FACILITY_GROUP_LIST_UPDATED, { groups, total }); + if (groups.length) { + await dispatch('fetchFacilityGroupsAdditionalDetails', payload) + } + }, + + async fetchFacilityGroupsAdditionalDetails({ commit, state }, payload) { + // getting all the groups from state + const cachedGroups = JSON.parse(JSON.stringify(state.facilityGroups.list)); // maintaining facilityGroups as to prepare the facilities payload to fetch additional information + let stateGroups = JSON.parse(JSON.stringify(state.facilityGroups.list)); // maintaining stateGroups as to update the facility information once information in fetched + const total = state.facilityGroups.total + + const facilityGroupIds: Array = []; + + // splitting the groups in batches to fetch the additional groups information + const groups = cachedGroups.splice(payload.viewIndex * (process.env.VUE_APP_VIEW_SIZE as any), process.env.VUE_APP_VIEW_SIZE) + groups.map((group: any) => facilityGroupIds.push(group.facilityGroupId)) + + stateGroups = stateGroups.filter((group: any) => !facilityGroupIds.includes(group.facilityGroupId)) + + try { + const facilityCountByGroup = await FacilityService.fetchFacilityCountByGroup(facilityGroupIds) + groups.map((group: any) => { + group.facilityCount = facilityCountByGroup[group.facilityGroupId] || 0 + }) + } catch (error) { + logger.error(error) + } + commit(types.FACILITY_GROUP_LIST_UPDATED, { groups: stateGroups.concat(groups), total }) + }, + + updateFacilityGroups({ commit }, groups) { + commit(types.FACILITY_GROUP_LIST_UPDATED, { groups, total: groups.length }) + }, } export default actions; \ No newline at end of file diff --git a/src/store/modules/facility/getters.ts b/src/store/modules/facility/getters.ts index 5445a339..0e86a3d7 100644 --- a/src/store/modules/facility/getters.ts +++ b/src/store/modules/facility/getters.ts @@ -9,20 +9,36 @@ const getters: GetterTree = { getVirtualFacilities(state) { return JSON.parse(JSON.stringify(state.virtualFacilities.list)) }, + getFacilityGroups(state) { + return JSON.parse(JSON.stringify(state.facilityGroups.list)) + }, getArchivedFacilities(state) { return JSON.parse(JSON.stringify(state.archivedFacilities)) }, getFacilityProductStores(state) { return state.current.productStores }, - getQuery(state) { - return JSON.parse(JSON.stringify(state.query)) + getFacilityQuery(state) { + return JSON.parse(JSON.stringify(state.facilityQuery)) + }, + getGroupQuery(state) { + return JSON.parse(JSON.stringify(state.groupQuery)) }, - isScrollable(state) { + isFacilitiesScrollable(state) { return ( state.facilities.list?.length > 0 && state.facilities.list?.length < state.facilities.total ); }, + isVirtualFacilitiesScrollable(state) { + return ( + state.virtualFacilities.list?.length > 0 && state.virtualFacilities.list?.length < state.virtualFacilities.total + ); + }, + isFacilityGroupsScrollable(state) { + return ( + state.facilityGroups.list?.length > 0 && state.facilityGroups.list?.length < state.facilityGroups.total + ); + }, getCurrent(state) { return state.current ? JSON.parse(JSON.stringify(state.current)) : {} }, diff --git a/src/store/modules/facility/index.ts b/src/store/modules/facility/index.ts index 295fca62..23ce1222 100644 --- a/src/store/modules/facility/index.ts +++ b/src/store/modules/facility/index.ts @@ -8,11 +8,14 @@ import RootState from '@/store/RootState' const facilityModule: Module = { namespaced: true, state: { - query: { + facilityQuery: { queryString: '', productStoreId: '', facilityTypeId: '' }, + groupQuery: { + queryString: '' + }, facilities: { list: [], total: 0 @@ -21,6 +24,10 @@ const facilityModule: Module = { list: [], total: 0 }, + facilityGroups: { + list: [], + total: 0 + }, archivedFacilities: [], current: {} }, diff --git a/src/store/modules/facility/mutation-types.ts b/src/store/modules/facility/mutation-types.ts index 429f5cb7..3ce2e054 100644 --- a/src/store/modules/facility/mutation-types.ts +++ b/src/store/modules/facility/mutation-types.ts @@ -1,6 +1,7 @@ export const SN_FACILITY = 'facility' export const FACILITY_LIST_UPDATED = SN_FACILITY + '/LIST_UPDATED' export const FACILITY_QUERY_UPDATED = SN_FACILITY + '/QUERY_UPDATED' +export const FACILITY_GROUP_QUERY_UPDATED = SN_FACILITY + '/GROUP_QUERY_UPDATED' export const FACILITY_CURRENT_UPDATED = SN_FACILITY + '/CURRENT_UPDATED' export const FACILITY_LOCATIONS_UPDATED = SN_FACILITY + '/LOCATIONS_UPDATED' export const FACILITY_POSTAL_ADDRESS_UPDATED = SN_FACILITY + '/POSTAL_ADDRESS_UPDATED' @@ -10,4 +11,5 @@ export const FACILITY_CALENDAR_UPDATED = SN_FACILITY + '/CALENDAR_UPDATED' export const FACILITY_PARTIES_UPDATED = SN_FACILITY + '/PARTIES_UPDATED' export const FACILITY_PRODUCT_STORES_UPDATED = SN_FACILITY + '/PRODUCT_STORES_UPDATED' export const FACILITY_VIRTUAL_FACILITY_LIST_UPDATED = SN_FACILITY + '/VIRTUAL_FACILITY_LIST_UPDATED' +export const FACILITY_GROUP_LIST_UPDATED = SN_FACILITY + '/GROUP_LIST_UPDATED' export const FACILITY_ARCHIVED_UPDATED = SN_FACILITY + '/ARCHIVED_UPDATED' diff --git a/src/store/modules/facility/mutations.ts b/src/store/modules/facility/mutations.ts index 849c97e3..3f293470 100644 --- a/src/store/modules/facility/mutations.ts +++ b/src/store/modules/facility/mutations.ts @@ -8,7 +8,10 @@ const mutations: MutationTree = { state.facilities.total = payload.total }, [types.FACILITY_QUERY_UPDATED](state, payload) { - state.query = payload + state.facilityQuery = payload + }, + [types.FACILITY_GROUP_QUERY_UPDATED](state, payload) { + state.groupQuery = payload }, [types.FACILITY_CALENDAR_UPDATED](state, payload) { state.current.calendar = payload @@ -44,6 +47,10 @@ const mutations: MutationTree = { state.virtualFacilities.list = payload.facilities state.virtualFacilities.total = payload.total }, + [types.FACILITY_GROUP_LIST_UPDATED](state, payload) { + state.facilityGroups.list = payload.groups + state.facilityGroups.total = payload.total + }, [types.FACILITY_ARCHIVED_UPDATED](state, payload) { state.archivedFacilities = payload } diff --git a/src/store/modules/util/UtilState.ts b/src/store/modules/util/UtilState.ts index a05db5ee..0ce9d520 100644 --- a/src/store/modules/util/UtilState.ts +++ b/src/store/modules/util/UtilState.ts @@ -1,6 +1,7 @@ export default interface UtilState { calendars: any[]; facilityTypes: object; + facilityGroupTypes: any[]; locationTypes: object; externalMappingTypes: object; productStores: any[]; diff --git a/src/store/modules/util/actions.ts b/src/store/modules/util/actions.ts index 100f0c4f..ed158477 100644 --- a/src/store/modules/util/actions.ts +++ b/src/store/modules/util/actions.ts @@ -33,7 +33,7 @@ const actions: ActionTree = { const cachedFacilityTypes = JSON.parse(JSON.stringify(state.facilityTypes)) // not fetching facility type information again if already present, as it will not be changed so frequently - if(cachedFacilityTypes.length) { + if (Object.keys(cachedFacilityTypes).length) { return; } @@ -66,6 +66,36 @@ const actions: ActionTree = { commit(types.UTIL_FACILITY_TYPES_UPDATED, facilityTypes) }, + async fetchFacilityGroupTypes({ commit, state }) { + const cachedFacilityGroupTypes = JSON.parse(JSON.stringify(state.facilityGroupTypes)) + + // not fetching facility group types information again if already present, as it will not be changed so frequently + if (cachedFacilityGroupTypes.length) { + return; + } + + let facilityGroupTypes = [] + const params = { + viewSize: 100, + noConditionFind: 'Y', + entityName: 'FacilityGroupType', + fieldList: ['facilityGroupTypeId', 'description'] + } as any + + try { + const resp = await UtilService.fetchFacilityGroupTypes(params) + if (!hasError(resp)) { + facilityGroupTypes = resp.data.docs + } else { + throw resp.data + } + } catch (error) { + logger.error(error) + } + + commit(types.UTIL_FACILITY_GROUP_TYPES_UPDATED, facilityGroupTypes) + }, + async fetchLocationTypes({ commit, state }) { const cachedLocationTypes = JSON.parse(JSON.stringify(state.locationTypes)) diff --git a/src/store/modules/util/getters.ts b/src/store/modules/util/getters.ts index e1ceb958..d63e877c 100644 --- a/src/store/modules/util/getters.ts +++ b/src/store/modules/util/getters.ts @@ -15,6 +15,9 @@ const getters: GetterTree = { getFacilityTypes(state) { return state.facilityTypes }, + getFacilityGroupTypes(state) { + return state.facilityGroupTypes + }, getLocationTypes(state) { return state.locationTypes }, diff --git a/src/store/modules/util/index.ts b/src/store/modules/util/index.ts index 7a93a224..ee92555b 100644 --- a/src/store/modules/util/index.ts +++ b/src/store/modules/util/index.ts @@ -12,6 +12,7 @@ const utilModule: Module = { partyRoles: [], productStores: [], facilityTypes: {}, + facilityGroupTypes: [], locationTypes: {}, externalMappingTypes: {}, countries: [], diff --git a/src/store/modules/util/mutation-types.ts b/src/store/modules/util/mutation-types.ts index 25daa052..e6c96ac8 100644 --- a/src/store/modules/util/mutation-types.ts +++ b/src/store/modules/util/mutation-types.ts @@ -2,6 +2,7 @@ export const SN_UTIL = 'util' export const UTIL_CALENDARS_UPDATED = SN_UTIL + '/CALENDARS_UPDATED' export const UTIL_PRODUCT_STORES_UPDATED = SN_UTIL + '/PRODUCT_STORES_UPDATED' export const UTIL_FACILITY_TYPES_UPDATED = SN_UTIL + '/FACILITY_TYPES_UPDATED' +export const UTIL_FACILITY_GROUP_TYPES_UPDATED = SN_UTIL + '/FACILITY_GROUP_TYPES_UPDATED' export const UTIL_LOCATION_TYPES_UPDATED = SN_UTIL + '/LOCATION_TYPES_UPDATED' export const UTIL_COUNTRIES_UPDATED = SN_UTIL + '/COUNTRIES_UPDATED' export const UTIL_EXTERNAL_MAPPING_TYPES_UPDATED = SN_UTIL + '/EXTERNAL_MAPPING_TYPES_UPDATED' diff --git a/src/store/modules/util/mutations.ts b/src/store/modules/util/mutations.ts index f2374282..33e2df5b 100644 --- a/src/store/modules/util/mutations.ts +++ b/src/store/modules/util/mutations.ts @@ -12,6 +12,9 @@ const mutations: MutationTree = { [types.UTIL_FACILITY_TYPES_UPDATED](state, payload) { state.facilityTypes = payload }, + [types.UTIL_FACILITY_GROUP_TYPES_UPDATED](state, payload) { + state.facilityGroupTypes = payload + }, [types.UTIL_LOCATION_TYPES_UPDATED](state, payload) { state.locationTypes = payload }, diff --git a/src/utils/index.ts b/src/utils/index.ts index b0da7257..6a5d4ce4 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -46,4 +46,13 @@ const isValidPassword = (password : string) => { return passwordPattern.test(password); } -export { copyToClipboard, isValidPassword, showToast } +// will sort the list but keeps the customValues at the beginning +const customSort = (list: any, customValues: Array, sortParameter: string) => { + return list.sort((first: any, second: any) => { + const firstVal = customValues.indexOf(first[sortParameter]); + const secondVal = customValues.indexOf(second[sortParameter]); + return secondVal - firstVal; + }); +} + +export { copyToClipboard, customSort, isValidPassword, showToast } diff --git a/src/views/FacilityManagement.vue b/src/views/FacilityManagement.vue index b8f9e8d4..f0c2555e 100644 --- a/src/views/FacilityManagement.vue +++ b/src/views/FacilityManagement.vue @@ -22,14 +22,7 @@ - - - - {{ translate("Parking") }} - - - - +

{{ translate("Groups") }}

@@ -50,7 +43,6 @@ + + \ No newline at end of file diff --git a/src/views/Parking.vue b/src/views/Parking.vue index 367700c0..c8ecedec 100644 --- a/src/views/Parking.vue +++ b/src/views/Parking.vue @@ -15,7 +15,8 @@
- + + {{ facility.facilityName }} @@ -101,7 +102,7 @@ import VirtualFacilityActionsPopover from '@/components/VirtualFacilityActionsPo import ArchivedFacilityModal from '@/components/ArchivedFacilityModal.vue'; import { FacilityService } from '@/services/FacilityService'; import { hasError } from '@/adapter'; -import { showToast } from '@/utils'; +import { customSort, showToast } from '@/utils'; import logger from "@/logger"; export default defineComponent({ @@ -127,7 +128,7 @@ export default defineComponent({ computed: { ...mapGetters({ virtualFacilities: 'facility/getVirtualFacilities', - isScrollable: "facility/isScrollable", + isScrollable: "facility/isVirtualFacilitiesScrollable", }) }, async mounted() { @@ -219,6 +220,7 @@ export default defineComponent({ return { addOutline, archiveOutline, + customSort, ellipsisVerticalOutline, store, translate