Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/hotwax/facilities into faci…
Browse files Browse the repository at this point in the history
…lities/hotwax#12
  • Loading branch information
amansinghbais committed Nov 21, 2023
2 parents d67070a + e535611 commit 0745890
Show file tree
Hide file tree
Showing 17 changed files with 424 additions and 72 deletions.
97 changes: 85 additions & 12 deletions src/components/AddLocationModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,34 @@
<ion-content>
<ion-item>
<ion-label>{{ translate("Type") }}</ion-label>
<ion-select interface="popover" :placeholder="translate('Select')" value="bulk" required>
<ion-select-option>{{ "pick/primary" }}</ion-select-option>
<ion-select-option>{{ "bulk" }}</ion-select-option>
<ion-select interface="popover" :placeholder="translate('Select')" v-model="locationInfo.locationTypeEnumId">
<ion-select-option v-for="(description, type) in locationTypes" :key="type" :value="type">{{ description }}</ion-select-option>
</ion-select>
</ion-item>
<ion-item>
<ion-label>{{ translate("Area") }} <ion-text color="danger">*</ion-text></ion-label>
<ion-input placeholder="area"/>
<ion-input :placeholder="translate('area')" v-model="locationInfo.areaId"/>
</ion-item>
<ion-item>
<ion-label>{{ translate("Aisle") }} <ion-text color="danger">*</ion-text></ion-label>
<ion-input placeholder="aisle" />
<ion-input :placeholder="translate('aisle')" v-model="locationInfo.aisleId"/>
</ion-item>
<ion-item>
<ion-label>{{ translate("Section") }} <ion-text color="danger">*</ion-text></ion-label>
<ion-input placeholder="section"/>
<ion-input :placeholder="translate('section')" v-model="locationInfo.sectionId"/>
</ion-item>
<ion-item>
<ion-label>{{ translate("Level") }} <ion-text color="danger">*</ion-text></ion-label>
<ion-input placeholder="level"/>
<ion-input :placeholder="translate('level')" v-model="locationInfo.levelId"/>
</ion-item>
<ion-item>
<ion-label>{{ translate("Sequence") }}</ion-label>
<ion-input placeholder="sequence"/>
<ion-input :placeholder="translate('sequence')" v-model="locationInfo.positionId"/>
</ion-item>
</ion-content>

<ion-fab vertical="bottom" horizontal="end" slot="fixed">
<ion-fab-button>
<ion-fab-button @click="saveFacilityLocation">
<ion-icon :icon="saveOutline" />
</ion-fab-button>
</ion-fab>
Expand Down Expand Up @@ -69,6 +68,11 @@ import {
import { defineComponent } from "vue";
import { closeOutline, saveOutline } from "ionicons/icons";
import { translate } from '@hotwax/dxp-components'
import { FacilityService } from "@/services/FacilityService";
import { mapGetters } from 'vuex'
import { hasError } from "@/adapter";
import { showToast } from "@/utils";
import logger from "@/logger";
export default defineComponent({
name: "AddLocationModal",
Expand All @@ -89,11 +93,80 @@ export default defineComponent({
IonTitle,
IonToolbar
},
methods: {
closeModal() {
modalController.dismiss()
props: ["location"],
data() {
return {
locationInfo: {} as any
}
},
mounted() {
this.locationInfo = this.location ? JSON.parse(JSON.stringify(this.location)) : {}
},
computed: {
...mapGetters({
current: 'facility/getCurrent',
locationTypes: 'util/getLocationTypes'
})
},
methods: {
closeModal(result?: string) {
modalController.dismiss({ result });
},
saveFacilityLocation() {
if(!this.locationInfo.aisleId?.trim() || !this.locationInfo.areaId?.trim() || !this.locationInfo.positionId?.trim() || !this.locationInfo.sectionId?.trim() || !this.locationInfo.levelId?.trim()) {
showToast(translate('Please fill all the required fields'))
return;
}
// checking for locationSeqId as when adding new facility we won't be having locationSeqId
if(this.location.locationSeqId) {
this.updateFacilityLocation()
} else {
this.addFacilityLocation()
}
},
async addFacilityLocation() {
const params = {
facilityId: this.current.facilityId,
...this.locationInfo
}
try {
const resp = await FacilityService.createFacilityLocation(params)
if(!hasError(resp)) {
showToast(translate('Facility location created successfully'))
this.closeModal('success');
} else {
throw resp.data
}
} catch(err) {
showToast(translate('Failed to create facility location'))
logger.error('Failed to create facility location', err)
}
},
async updateFacilityLocation() {
const params = {
facilityId: this.current.facilityId,
...this.locationInfo
}
try {
const resp = await FacilityService.updateFacilityLocation(params)
if(!hasError(resp)) {
showToast(translate('Facility location updated successfully'))
this.closeModal('success');
} else {
throw resp.data
}
} catch(err) {
showToast(translate('Failed to update facility location'))
logger.error('Failed to update facility location', err)
}
},
},
setup() {
return {
closeOutline,
Expand Down
48 changes: 45 additions & 3 deletions src/components/LocationDetailsPopover.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<ion-item button @click="addLocationModal">
{{ translate("Edit location") }}
</ion-item>
<ion-item button lines="none">
<ion-item button lines="none" @click="removeLocation">
{{ translate("Remove location") }}
</ion-item>
</ion-list>
Expand All @@ -18,11 +18,17 @@ import {
IonItem,
IonList,
IonListHeader,
modalController
modalController,
popoverController
} from "@ionic/vue";
import { defineComponent } from "vue";
import { translate } from "@hotwax/dxp-components";
import AddLocationModal from "./AddLocationModal.vue";
import { mapGetters, useStore } from "vuex";
import { FacilityService } from "@/services/FacilityService";
import { hasError } from "@/adapter";
import { showToast } from "@/utils";
import logger from "@/logger";
export default defineComponent({
name: "LocationDetailsPopover",
Expand All @@ -32,17 +38,53 @@ export default defineComponent({
IonList,
IonListHeader
},
computed: {
...mapGetters({
current: 'facility/getCurrent'
})
},
props: ["location"],
methods: {
async addLocationModal() {
const addLocationModal = await modalController.create({
component: AddLocationModal
component: AddLocationModal,
componentProps: { location: this.location }
})
addLocationModal.present()
addLocationModal.onDidDismiss().then((result: any) => {
if(result.data?.result) {
popoverController.dismiss();
}
})
},
async removeLocation() {
const params = {
facilityId: this.location.facilityId,
locationSeqId: this.location.locationSeqId
}
try {
const resp = await FacilityService.deleteFacilityLocation(params)
if(!hasError(resp)) {
this.store.dispatch('facility/fetchFacilityLocation')
popoverController.dismiss();
} else {
throw resp.data
}
} catch(err) {
showToast(translate('Failed to remove facility location'))
logger.error('Failed to remove facility location', err)
}
}
},
setup() {
const store = useStore();
return {
store,
translate
};
}
Expand Down
26 changes: 17 additions & 9 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
"Address": "Address",
"Address line 1": "Address line 1",
"Address line 2": "Address line 2",
"aisle": "aisle",
"Aisle": "Aisle",
"aisle": "aisle",
"All": "All",
"Allow pickup": "Allow pickup",
"App": "App",
"Apply": "Apply",
"area": "area",
"Area": "Area",
"area": "area",
"Back to Launchpad": "Back to Launchpad",
"Built: ": "Built: { builtDateTime }",
"Cancel": "Cancel",
Expand All @@ -31,6 +31,7 @@
"Custom mapping": "Custom mapping",
"Country": "Country",
"Days to ship": "Days to ship",
"days to ship": "days to ship",
"Dismiss": "Dismiss",
"Edit": "Edit",
"Edit location": "Edit location",
Expand All @@ -39,10 +40,16 @@
"Facility": "Facility",
"Facility details": "Facility details",
"Facility ID": "Facility ID",
"Facility location created successfully": "Facility location created successfully",
"Facility location updated successfully": "Facility location updated successfully",
"Facility name": "Facility name",
"Facility Management": "Facility Management",
"Failed to create facility location": "Failed to create facility location",
"Failed to fetch facility information": "Failed to fetch facility information",
"Failed to find the facility locations": "Failed to find the facility locations",
"Failed to remove facility location": "Failed to remove facility location",
"Failed to remove party from facility.": "Failed to remove party from facility.",
"Failed to update facility location": "Failed to update facility location",
"Failed to update some role(s).": "Failed to update some role(s).",
"Fetching TimeZones": "Fetching TimeZones",
"Find Facilities": "Find Facilities",
Expand All @@ -60,8 +67,8 @@
"Language": "Language",
"Latitude": "Latitude",
"Latitude & Longitude": "Latitude & Longitude",
"level": "level",
"Level": "Level",
"level": "level",
"Loading": "Loading",
"Location": "Location",
"Location details": "Location details",
Expand Down Expand Up @@ -94,26 +101,27 @@
"orders allocated today": "{orderCount} orders allocated today",
"orders in fulfillment queue": "{orderCount} orders in fulfillment queue",
"Parking": "Parking",
"party id": "party id",
"Party Id": "Party Id",
"Party successfully removed from facility.": "Party successfully removed from facility.",
"Please update atleast one party role.": "Please update atleast one party role.",
"party id": "party id",
"Password": "Password",
"Please contact the administrator.": "Please contact the administrator.",
"Please update atleast one party role.": "Please update atleast one party role.",
"Please fill all the required fields": "Please fill all the required fields",
"primary store": "primary store",
"Product Store": "Product Store",
"Product Stores": "Product Stores",
"Reason:": "Reason:",
"Reset": "Reset",
"Remove": "Remove",
"Remove location": "Remove location",
"role": "role",
"Role": "Role",
"role": "role",
"Role(s) updated successfully.": "Role(s) updated successfully.",
"Saturday": "Saturday",
"Save": "Save",
"section": "section",
"Section": "Section",
"section": "section",
"Select": "Select",
"Search facilities": "Search facilities",
"Search time zones": "Search time zones",
Expand All @@ -125,8 +133,8 @@
"Select your preferred language.": "Select your preferred language.",
"Sell Online": "Sell Online",
"Sell Inventory Online": "Sell Inventory Online",
"sequence": "sequence",
"Sequence": "Sequence",
"sequence": "sequence",
"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.",
"Shopify": "Shopify",
Expand All @@ -137,8 +145,8 @@
"Specify which facility you want to operate from. Order, inventory and other configuration data will be specific to the facility you select.": "Specify which facility you want to operate from. Order, inventory and other configuration data will be specific to the facility you select.",
"Staff": "Staff",
"State": "State",
"Store": "Store",
"store name": "store name",
"Store": "Store",
"Sunday": "Sunday",
"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.",
Expand Down
Loading

0 comments on commit 0745890

Please sign in to comment.