Skip to content

Commit

Permalink
Merge pull request #75 from k2maan/find-facility-group
Browse files Browse the repository at this point in the history
Implemented: flow to find and create facility groups
  • Loading branch information
ravilodhi authored Dec 8, 2023
2 parents 0af853f + 7df52ae commit 909c387
Show file tree
Hide file tree
Showing 24 changed files with 658 additions and 70 deletions.
191 changes: 191 additions & 0 deletions src/components/CreateFacilityGroupModal.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
<template>
<ion-header>
<ion-toolbar>
<ion-buttons slot="start">
<ion-button @click="closeModal()">
<ion-icon slot="icon-only" :icon="closeOutline" />
</ion-button>
</ion-buttons>
<ion-title>{{ translate("New group") }}</ion-title>
</ion-toolbar>
</ion-header>

<ion-content>
<form @keyup.enter="createFacilityGroup">
<ion-list>
<ion-item>
<ion-label position="floating">
{{ translate("Name") }} <ion-text color="danger">*</ion-text>
</ion-label>
<ion-input v-model="formData.facilityGroupName"/>
</ion-item>
<ion-item ref="facilityGroupId">
<ion-label position="floating">
{{ translate("Internal ID") }}
</ion-label>
<ion-input v-model="formData.facilityGroupId" @ionChange="validateFacilityGroupId" @ionBlur="markFacilityGroupIdTouched" />
<ion-note slot="error">
{{ translate('Internal ID cannot be more than 20 characters.') }}
</ion-note>
</ion-item>
<ion-item lines="none">
<ion-label>{{ translate("System group type") }}</ion-label>
<ion-select interface="popover" v-model="formData.facilityGroupTypeId">
<ion-select-option :value="facilityGroupType.facilityGroupTypeId" :key="facilityGroupType.facilityGroupTypeId" v-for="facilityGroupType in facilityGroupTypes">
{{ facilityGroupType.description ? facilityGroupType.description : facilityGroupType.facilityGroupTypeId }}
</ion-select-option>
</ion-select>
</ion-item>
<ion-item>
<ion-label position="floating">
{{ translate("Description") }}
</ion-label>
<ion-input v-model="formData.description"/>
</ion-item>
</ion-list>

<ion-fab vertical="bottom" horizontal="end" slot="fixed">
<ion-fab-button @click="createFacilityGroup" @keyup.enter.stop>
<ion-icon :icon="addOutline" />
</ion-fab-button>
</ion-fab>
</form>
</ion-content>
</template>

<script lang="ts">
import {
IonButton,
IonButtons,
IonContent,
IonFab,
IonFabButton,
IonHeader,
IonIcon,
IonInput,
IonItem,
IonLabel,
IonList,
IonNote,
IonSelect,
IonSelectOption,
IonText,
IonTitle,
IonToolbar,
modalController
} from "@ionic/vue";
import { defineComponent } from "vue";
import { addOutline, closeOutline } from "ionicons/icons";
import { translate } from '@hotwax/dxp-components'
import { FacilityService } from "@/services/FacilityService";
import { mapGetters, useStore } from 'vuex'
import { hasError } from "@/adapter";
import { showToast } from "@/utils";
import logger from "@/logger";
export default defineComponent({
name: "CreateFacilityGroupModal",
components: {
IonButton,
IonButtons,
IonContent,
IonFab,
IonFabButton,
IonHeader,
IonIcon,
IonInput,
IonItem,
IonLabel,
IonList,
IonNote,
IonSelect,
IonSelectOption,
IonText,
IonTitle,
IonToolbar
},
computed: {
...mapGetters({
groups: 'facility/getFacilityGroups',
facilityGroupTypes: 'util/getFacilityGroupTypes',
})
},
data() {
return {
formData: {
facilityGroupId: '',
facilityGroupName: '',
facilityGroupTypeId: '',
description: '',
},
}
},
mounted() {
// setting facilityGroupTypeId as the first groupTypeId
this.formData.facilityGroupTypeId = this.facilityGroupTypes[0].facilityGroupTypeId
},
methods: {
closeModal() {
modalController.dismiss();
},
async createFacilityGroup() {
if (!this.formData.facilityGroupId?.trim() || !this.formData.facilityGroupName?.trim()) {
showToast(translate('Please fill all the required fields'))
return;
}
if (this.formData.facilityGroupId.length > 20) {
showToast(translate('Internal ID cannot be more than 20 characters.'))
return
}
try {
const payload = {
...this.formData,
}
const resp = await FacilityService.createFacilityGroup(payload);
if (!hasError(resp)) {
showToast(translate("Facility group created."))
const createdGroup = {
...this.formData,
facilityCount: 0
}
const updatedFacilityGroups = [...this.groups, createdGroup]
await this.store.dispatch('facility/updateFacilityGroups', updatedFacilityGroups)
} else {
throw resp.data;
}
} catch (error) {
logger.error(error)
showToast(translate('Failed to create facility group.'))
}
modalController.dismiss()
},
validateFacilityGroupId(event: any) {
const value = event.target.value;
(this as any).$refs.facilityGroupId.$el.classList.remove('ion-valid');
(this as any).$refs.facilityGroupId.$el.classList.remove('ion-invalid');
if (value === '') return;
this.formData.facilityGroupId.length <= 20
? (this as any).$refs.facilityGroupId.$el.classList.add('ion-valid')
: (this as any).$refs.facilityGroupId.$el.classList.add('ion-invalid');
},
markFacilityGroupIdTouched() {
(this as any).$refs.facilityGroupId.$el.classList.add('ion-touched');
},
},
setup() {
const store = useStore();
return {
addOutline,
closeOutline,
store,
translate
};
},
});
</script>
10 changes: 0 additions & 10 deletions src/components/CreateVirtualFacilityModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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('_');
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -68,7 +68,7 @@ export default defineComponent({
},
computed: {
...mapGetters({
query: "facility/getQuery",
query: "facility/getFacilityQuery",
facilityTypes: "util/getFacilityTypes",
productStores: "util/getProductStores"
})
Expand All @@ -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();
},
},
Expand Down
7 changes: 7 additions & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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.",
Expand Down
7 changes: 7 additions & 0 deletions src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -98,6 +99,12 @@ const routes: Array<RouteRecordRaw> = [
component: Parking,
beforeEnter: authGuard
},
{
path: '/find-groups',
name: 'FindGroups',
component: FindGroups,
beforeEnter: authGuard
},
{
path: '/settings',
name: 'Settings',
Expand Down
Loading

0 comments on commit 909c387

Please sign in to comment.