Skip to content

Commit 670cd7c

Browse files
committed
Fixed: Duplicate methods in drop-down in reroute-fulfillment card. Added a modal to choose both carrier and shipment method instead of just shipping method (#422).
1 parent 22a9a31 commit 670cd7c

File tree

4 files changed

+211
-10
lines changed

4 files changed

+211
-10
lines changed
+127
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
<template>
2+
<ion-header>
3+
<ion-toolbar>
4+
<ion-buttons slot="start">
5+
<ion-button @click="closeModal">
6+
<ion-icon slot="icon-only" :icon="closeOutline" />
7+
</ion-button>
8+
</ion-buttons>
9+
<ion-title>{{ translate("Select shipping method") }}</ion-title>
10+
</ion-toolbar>
11+
</ion-header>
12+
<ion-content>
13+
<ion-list>
14+
<ion-item lines="none">
15+
<ion-label>{{ translate('Select which shipping method orders will receive when customer choose to have delivered instead of picked up.') }}</ion-label>
16+
</ion-item>
17+
<ion-item>
18+
<ion-select :label="translate('Carrier')" v-model="carrierPartyId" interface="popover" @ionChange="getProductStoreShipmentMethods(carrierPartyId)">
19+
<ion-select-option v-for="carrier in carriers" :key="carrier.partyId" :value="carrier.partyId">{{ carrier.groupName }}</ion-select-option>
20+
</ion-select>
21+
</ion-item>
22+
<ion-item>
23+
<template v-if="productStoreShipmentMethods && productStoreShipmentMethods.length > 0">
24+
<ion-select :label="translate('Method')" v-model="shipmentMethodTypeId" interface="popover">
25+
<ion-select-option v-for="method in productStoreShipmentMethods" :key="method.productStoreShipMethId" :value="method.shipmentMethodTypeId">{{ method.description }}</ion-select-option>
26+
</ion-select>
27+
</template>
28+
<template v-else>
29+
<ion-label>
30+
{{ translate('No shipment methods linked to', {carrierName: getCarrierName(carrierPartyId)}) }}
31+
</ion-label>
32+
<ion-button @click="openShippingMethodDocumentReference()" fill="clear" color="medium" slot="end">
33+
<ion-icon slot="icon-only" :icon="informationCircleOutline" />
34+
</ion-button>
35+
</template>
36+
</ion-item>
37+
</ion-list>
38+
</ion-content>
39+
<ion-fab vertical="bottom" horizontal="end" slot="fixed">
40+
<ion-fab-button :disabled="!shipmentMethodTypeId" @click="save()">
41+
<ion-icon :icon="saveOutline" />
42+
</ion-fab-button>
43+
</ion-fab>
44+
</template>
45+
46+
<script lang="ts">
47+
import {
48+
IonButton,
49+
IonButtons,
50+
IonContent,
51+
IonFab,
52+
IonFabButton,
53+
IonHeader,
54+
IonIcon,
55+
IonItem,
56+
IonLabel,
57+
IonList,
58+
IonSelect,
59+
IonSelectOption,
60+
IonTitle,
61+
IonToolbar,
62+
modalController
63+
} from '@ionic/vue';
64+
import { defineComponent } from 'vue';
65+
import { closeOutline, informationCircleOutline, saveOutline } from 'ionicons/icons';
66+
import { translate } from '@hotwax/dxp-components';
67+
68+
export default defineComponent({
69+
name: "OrderItemRejHistoryModal",
70+
components: {
71+
IonButton,
72+
IonButtons,
73+
IonContent,
74+
IonFab,
75+
IonFabButton,
76+
IonHeader,
77+
IonIcon,
78+
IonItem,
79+
IonLabel,
80+
IonList,
81+
IonSelect,
82+
IonSelectOption,
83+
IonTitle,
84+
IonToolbar,
85+
},
86+
data(){
87+
return {
88+
carrierPartyId: "",
89+
shipmentMethodTypeId: "",
90+
productStoreShipmentMethods: [] as any
91+
}
92+
},
93+
props: ['currentcConfig', 'carriers', 'availableShipmentMethods'],
94+
mounted() {
95+
this.carrierPartyId = this.currentcConfig.carrierPartyId
96+
this.getProductStoreShipmentMethods(this.carrierPartyId)
97+
this.shipmentMethodTypeId = this.currentcConfig.shipmentMethodTypeId
98+
},
99+
methods: {
100+
closeModal() {
101+
modalController.dismiss({ dismissed: true });
102+
},
103+
async getProductStoreShipmentMethods(carrierPartyId: string) {
104+
this.productStoreShipmentMethods = this.availableShipmentMethods?.filter((method: any) => method.partyId === carrierPartyId) || [];
105+
this.shipmentMethodTypeId = this.productStoreShipmentMethods[0]?.shipmentMethodTypeId;
106+
},
107+
getCarrierName(carrierPartyId: string) {
108+
const selectedCarrier = this.carriers.find((carrier: any) => carrier.partyId === carrierPartyId)
109+
return selectedCarrier && selectedCarrier.groupName ? selectedCarrier.groupName : carrierPartyId
110+
},
111+
openShippingMethodDocumentReference() {
112+
window.open('https://docs.hotwax.co/documents/v/system-admins/fulfillment/shipping-methods/carrier-and-shipment-methods', '_blank');
113+
},
114+
save() {
115+
modalController.dismiss({ dismissed: true, shippingMethod: JSON.stringify({"carrierPartyId": this.carrierPartyId, "shipmentMethodTypeId": this.shipmentMethodTypeId})});
116+
}
117+
},
118+
setup() {
119+
return {
120+
closeOutline,
121+
informationCircleOutline,
122+
saveOutline,
123+
translate
124+
};
125+
},
126+
});
127+
</script>

src/locales/en.json

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"App": "App",
3+
"Add": "Add",
34
"All items were rejected from the order": "All items were rejected from the order",
45
"All order items are rejected": "All order items are rejected",
56
"Allow partial rejection": "Allow partial rejection",
@@ -18,6 +19,7 @@
1819
"Cancel": "Cancel",
1920
"Cancel order before fulfillment": "Cancel order before fulfillment",
2021
"canceled from the order": "canceled from the order",
22+
"Carrier": "Carrier",
2123
"Control what your customers are allowed to edit on their order when they are editing their order on Re-route Fulfillment.": "Control what your customers are allowed to edit on their order when they are editing their order on Re-route Fulfillment.",
2224
"Change": "Change",
2325
"Choose language": "Choose language",
@@ -73,6 +75,7 @@
7375
"Logging in": "Logging in",
7476
"Logging out": "Logging out",
7577
"Logout": "Logout",
78+
"Method": "Method",
7679
"Mismatch": "Mismatch",
7780
"More": "More",
7881
"New notification received.": "New notification received.",
@@ -84,6 +87,7 @@
8487
"No picker assigned.": "No picker assigned.",
8588
"No picker found": "No picker found",
8689
"No records found.": "No records found.",
90+
"No shipment methods linked to": "No shipment methods linked to {carrierName}",
8791
"No time zone found": "No time zone found",
8892
"Notifications": "Notifications",
8993
"Notification Preference": "Notification Preference",
@@ -162,13 +166,15 @@
162166
"Select Facility": "Select Facility",
163167
"Search facilities": "Search facilities",
164168
"Select reason": "Select reason",
169+
"Select shipping method": "Select shipping method",
165170
"Selected TimeZone":"Selected TimeZone",
166171
"Select a different time zone": "Select a different time zone",
167172
"Select time zone": "Select time zone",
168173
"Select the notifications you want to receive.": "Select the notifications you want to receive.",
169174
"Select your preferred language.": "Select your preferred language.",
170175
"Settings": "Settings",
171176
"Select a picker": "Select a picker",
177+
"Select which shipping method orders will receive when customer choose to have delivered instead of picked up.": "Select which shipping method orders will receive when customer choose to have delivered instead of picked up.",
172178
"Send": "Send",
173179
"Ship": "Ship",
174180
"Shipment method": "Shipment method",

src/locales/es.json

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"App": "Aplicación",
3+
"Add": "Add",
34
"All items were rejected from the order": "Todos los artículos fueron rechazados del pedido",
45
"All order items are rejected": "Todos los artículos del pedido son rechazados",
56
"Allow partial rejection": "Permitir rechazo parcial",
@@ -18,6 +19,7 @@
1819
"Cancel": "Cancelar",
1920
"Cancel order before fulfillment": "Cancelar pedido antes del cumplimiento",
2021
"canceled from the order": "cancelado del pedido",
22+
"Carrier": "Carrier",
2123
"Control what your customers are allowed to edit on their order when they are editing their order on Re-route Fulfillment.": "Controle lo que sus clientes pueden editar en su pedido cuando editan su pedido en Reenrutar el cumplimiento.",
2224
"Change": "Cambiar",
2325
"Choose language": "Elegir idioma",
@@ -36,6 +38,7 @@
3638
"Delivery method": "Método de entrega",
3739
"Dismiss": "Descartar",
3840
"eCom Store": "Tienda electrónica",
41+
"Edit": "Edit",
3942
"Edit pickers": "Editar recolectores",
4043
"Email sent successfully": "Correo enviado satisfactoriamente",
4144
"Enable tracking": "Habilitar seguimiento",
@@ -70,6 +73,7 @@
7073
"Logging in": "Iniciando sesión",
7174
"Logging out": "Cerrando sesión",
7275
"Logout": "Cerrar sesión",
76+
"Method": "Method",
7377
"Mismatch": "Desajuste",
7478
"More": "Más",
7579
"New notification received.": "Nueva notificación recibida.",
@@ -81,6 +85,7 @@
8185
"No picker assigned.": "No hay recolector asignado.",
8286
"No picker found": "No se encontró recolector",
8387
"No records found.": "No se encontraron registros.",
88+
"No shipment methods linked to": "No shipment methods linked to {carrierName}",
8489
"No time zone found": "No se encontró zona horaria",
8590
"Notifications": "Notificaciones",
8691
"Notification Preference": "Preferencias de notificación",
@@ -159,13 +164,15 @@
159164
"Select Facility": "Select Facility",
160165
"Search facilities": "Search facilities",
161166
"Select reason": "Seleccionar motivo",
167+
"Select shipping method": "Select shipping method",
162168
"Selected TimeZone":"Selected TimeZone",
163169
"Select a different time zone": "Select a different time zone",
164170
"Select time zone": "Seleccionar zona horaria",
165171
"Select the notifications you want to receive.": "Selecciona las notificaciones que deseas recibir.",
166172
"Select your preferred language.": "Selecciona tu idioma preferido.",
167173
"Settings": "Configuraciones",
168174
"Select a picker": "Seleccionar un recolector",
175+
"Select which shipping method orders will receive when customer choose to have delivered instead of picked up.": "Select which shipping method orders will receive when customer choose to have delivered instead of picked up.",
169176
"Send": "Enviar",
170177
"Ship": "Enviar",
171178
"Shipment method": "Método de envío",

src/views/Settings.vue

+71-10
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,15 @@
6565
<ion-toggle label-placement="start" :disabled="!hasPermission(Actions.APP_RF_CONFIG_UPDATE) || Object.keys(rerouteFulfillmentConfig.orderItemSplit).length == 0" :checked="rerouteFulfillmentConfig.orderItemSplit.settingValue" @ionChange="updateRerouteFulfillmentConfiguration(rerouteFulfillmentConfig.orderItemSplit, $event.detail.checked)">{{ translate("Order item split") }}</ion-toggle>
6666
</ion-item>
6767
<ion-item lines="none">
68-
<ion-select :label="translate('Shipment method')" :disabled="!hasPermission(Actions.APP_RF_CONFIG_UPDATE) || Object.keys(rerouteFulfillmentConfig.shippingMethod).length == 0" interface="popover" :value="rerouteFulfillmentConfig.shippingMethod.settingValue" @ionChange="updateRerouteFulfillmentConfiguration(rerouteFulfillmentConfig.shippingMethod, $event.detail.value)">
69-
<ion-select-option v-for="shipmentMethod in availableShipmentMethods" :key="shipmentMethod.shipmentMethodTypeId" :value="shipmentMethod.shipmentMethodTypeId" >{{ shipmentMethod.description }}</ion-select-option>
70-
</ion-select>
68+
<ion-label v-if="Object.keys(getShipmentMethodConfig()).length > 0">
69+
<p class="overline">{{ translate('Shipment method') }}</p>
70+
{{ getShipmentMethodConfig()?.shipmentMethodDesc }}
71+
<p>{{ getShipmentMethodConfig().carrierName }}</p>
72+
</ion-label>
73+
<ion-label v-else>
74+
{{ translate('Shipment method') }}
75+
</ion-label>
76+
<ion-button slot="end" fill="outline" color="dark" :disabled="!hasPermission(Actions.APP_RF_CONFIG_UPDATE) || Object.keys(rerouteFulfillmentConfig.shippingMethod).length == 0" @click="openEditShipmentMethodModal(rerouteFulfillmentConfig.shippingMethod)">{{ Object.keys(getShipmentMethodConfig()).length > 0 ? translate('Edit') : translate('Add')}}</ion-button>
7177
</ion-item>
7278
</ion-card>
7379

@@ -180,13 +186,13 @@ import {
180186
IonHeader,
181187
IonIcon,
182188
IonItem,
189+
IonLabel,
183190
IonList,
184191
IonPage,
185-
IonSelect,
186-
IonSelectOption,
187192
IonTitle,
188193
IonToggle,
189-
IonToolbar
194+
IonToolbar,
195+
modalController
190196
} from '@ionic/vue';
191197
import { defineComponent, computed } from 'vue';
192198
import {
@@ -209,6 +215,7 @@ import { Actions, hasPermission } from '@/authorization'
209215
import { addNotification, generateTopicName, isFcmConfigured, storeClientRegistrationToken } from "@/utils/firebase";
210216
import emitter from "@/event-bus"
211217
import logger from '@/logger';
218+
import EditShipmentMethodModal from '@/components/EditShipmentMethodModal.vue';
212219
213220
export default defineComponent({
214221
name: 'Settings',
@@ -224,10 +231,9 @@ export default defineComponent({
224231
IonHeader,
225232
IonIcon,
226233
IonItem,
234+
IonLabel,
227235
IonList,
228236
IonPage,
229-
IonSelect,
230-
IonSelectOption,
231237
IonTitle,
232238
IonToggle,
233239
IonToolbar,
@@ -247,6 +253,7 @@ export default defineComponent({
247253
shippingMethod: {},
248254
orderItemSplit: {}
249255
} as any,
256+
carriers: [] as any,
250257
availableShipmentMethods: [] as any,
251258
rerouteFulfillmentConfigMapping: (process.env.VUE_APP_RF_CNFG_MPNG? JSON.parse(process.env.VUE_APP_RF_CNFG_MPNG) : {}) as any
252259
}
@@ -268,6 +275,7 @@ export default defineComponent({
268275
async ionViewWillEnter() {
269276
// Only fetch configuration when environment mapping exists
270277
if (Object.keys(this.rerouteFulfillmentConfigMapping).length > 0) {
278+
this.fetchCarriers()
271279
this.getAvailableShipmentMethods();
272280
this.getRerouteFulfillmentConfiguration();
273281
}
@@ -314,6 +322,59 @@ export default defineComponent({
314322
getDateTime(time: any) {
315323
return DateTime.fromMillis(time).toLocaleString(DateTime.DATETIME_MED);
316324
},
325+
async openEditShipmentMethodModal(config: any) {
326+
const editShipmentMethodModal = await modalController.create({
327+
component: EditShipmentMethodModal,
328+
componentProps: { currentcConfig: this.getShipmentMethodConfig(), carriers: this.carriers, availableShipmentMethods: this.availableShipmentMethods }
329+
});
330+
331+
editShipmentMethodModal.onDidDismiss().then(async(result: any) => {
332+
if(result.data?.shippingMethod) {
333+
await this.updateRerouteFulfillmentConfiguration(config, result.data?.shippingMethod)
334+
}
335+
})
336+
337+
return editShipmentMethodModal.present();
338+
},
339+
getShipmentMethodConfig() {
340+
if (Object.keys(this.rerouteFulfillmentConfig.shippingMethod).length !== 0) {
341+
try {
342+
const shippingMethodConfig = this.rerouteFulfillmentConfig.shippingMethod.settingValue ? JSON.parse(this.rerouteFulfillmentConfig.shippingMethod.settingValue) : {};
343+
if (Object.keys(shippingMethodConfig).length > 0) {
344+
const shipmentMethodDesc = this.availableShipmentMethods.find((shipmentMethod: any) => shipmentMethod.shipmentMethodTypeId === shippingMethodConfig.shipmentMethodTypeId)?.description;
345+
const carrierName = this.carriers.find((carrier: any) => carrier.partyId === shippingMethodConfig.carrierPartyId)?.groupName;
346+
return { ...shippingMethodConfig, shipmentMethodDesc, carrierName };
347+
}
348+
} catch (error) {
349+
console.error('Error parsing shipping method config:', error);
350+
return {};
351+
}
352+
}
353+
return {};
354+
},
355+
async fetchCarriers () {
356+
this.availableShipmentMethods = [];
357+
try {
358+
const resp = await UserService.getRerouteFulfillmentConfig({
359+
"entityName": "CarrierShipmentMethodCount",
360+
"inputFields": {
361+
"roleTypeId": "CARRIER",
362+
"partyTypeId": "PARTY_GROUP"
363+
},
364+
"fieldList": ["partyId", "roleTypeId", "groupName"],
365+
"viewIndex": 0,
366+
"viewSize": 250, // maximum records we could have
367+
"distinct": "Y",
368+
"noConditionFind": "Y",
369+
"orderBy": "groupName"
370+
}) as any;
371+
if (!hasError(resp) && resp.data?.docs) {
372+
this.carriers = resp.data.docs;
373+
}
374+
} catch(err) {
375+
logger.error(err)
376+
}
377+
},
317378
async getAvailableShipmentMethods () {
318379
this.availableShipmentMethods = [];
319380
try {
@@ -325,8 +386,8 @@ export default defineComponent({
325386
},
326387
"filterByDate": 'Y',
327388
"entityName": "ProductStoreShipmentMethView",
328-
"fieldList": ["shipmentMethodTypeId", "description"],
329-
"viewSize": 10
389+
"fieldList": ["productStoreShipMethId", "partyId", "shipmentMethodTypeId", "description"],
390+
"viewSize": 250
330391
}) as any;
331392
if (!hasError(resp) && resp.data?.docs) {
332393
this.availableShipmentMethods = resp.data.docs;

0 commit comments

Comments
 (0)