From 5ac0ebfebad176c3aba599528425d237f3bc4a64 Mon Sep 17 00:00:00 2001 From: k2maan Date: Mon, 31 Jul 2023 18:17:12 +0530 Subject: [PATCH 01/50] Implemented: option to turn on/off eCom inventory (#141) --- src/authorization/Actions.ts | 3 +- src/authorization/Rules.ts | 3 +- src/locales/en.json | 7 ++ src/locales/es.json | 2 + src/services/UserService.ts | 42 +++++++++++- src/views/Settings.vue | 124 ++++++++++++++++++++++++++++++++++- 6 files changed, 174 insertions(+), 7 deletions(-) diff --git a/src/authorization/Actions.ts b/src/authorization/Actions.ts index 96403ac7..f09c45db 100644 --- a/src/authorization/Actions.ts +++ b/src/authorization/Actions.ts @@ -1,5 +1,6 @@ export default { - "APP_TURN_OFF_STORE": "APP_TURN_OFF_STORE", + "APP_UPDT_STR_FULFLMNT_CONFIG": "APP_UPDT_STR_FULFLMNT_CONFIG", + "APP_UPDT_ECOM_INV_CONFIG": "APP_UPDT_ECOM_INV_CONFIG", "APP_UNPACK_ORDER": "APP_UNPACK_ORDER", "APP_RECYCLE_ORDER": "APP_RECYCLE_ORDER", } \ No newline at end of file diff --git a/src/authorization/Rules.ts b/src/authorization/Rules.ts index 928d66fc..83cb7ece 100644 --- a/src/authorization/Rules.ts +++ b/src/authorization/Rules.ts @@ -5,7 +5,8 @@ export default { "APP_EXIM_VIEW": "", "APP_UPLOAD_IMPORT_ORDERS_VIEW": "", "APP_DOWNLOAD_PACKED_ORDERS_VIEW": "", - "APP_TURN_OFF_STORE": "COMMON_ADMIN", + "APP_UPDT_STR_FULFLMNT_CONFIG": "COMMON_ADMIN", + "APP_UPDT_ECOM_INV_CONFIG": "COMMON_ADMIN", "APP_UNPACK_ORDER": "COMMON_ADMIN", "APP_RECYCLE_ORDER": "COMMON_ADMIN", } as any \ No newline at end of file diff --git a/src/locales/en.json b/src/locales/en.json index 4be1a76b..a21e6520 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -38,6 +38,7 @@ "Download orders that are packed and haven't been shipped yet. Use the downloaded file to send the packed order details to a carrier where shipping labels and tracking codes will be generated.": "Download orders that are packed and haven't been shipped yet. Use the downloaded file to send the packed order details to a carrier where shipping labels and tracking codes will be generated.", "Download packed orders": "Download packed orders", "eCom Store": "eCom Store", + "ECom inventory status updated successfully": "ECom inventory status updated successfully", "Edit packaging": "Edit packaging", "Email": "Email", "Enter key": "Enter key", @@ -58,6 +59,7 @@ "Failed to add box": "Failed to add box", "Failed to create picklist for orders": "Failed to create picklist for orders", "Failed to delete CSV mapping.": "Failed to delete CSV mapping.", + "Failed to fetch eCom inventory config": "Failed to fetch eCom inventory config", "Failed to generate shipping label": "Failed to generate shipping label", "Failed to get packed orders information": "Failed to get packed orders information", "Failed to pack order": "Failed to pack order", @@ -69,6 +71,7 @@ "Failed to recycle in progress orders": "Failed to recycle in progress orders", "Failed to recycle outstanding orders": "Failed to recycle outstanding orders", "Failed to update CSV mapping.": "Failed to update CSV mapping.", + "Failed to update eCom inventory status": "Failed to update eCom inventory status", "Failed to update facility": "Failed to update facility", "Failed to update order": "Failed to update order", "Field mapping name": "Field mapping name", @@ -206,6 +209,10 @@ "To Name": "To Name", "Tracking Code": "Tracking Code", "Tracking ID": "Tracking ID", + "Turn off eCom inventory": "Turn off eCom inventory", + "Turn on eCom inventory": "Turn on eCom inventory", + "Turn on eCom inventory for ": "Turn on eCom inventory for { facilityName }", + "Turn off eCom inventory for ": "Turn off eCom inventory for { facilityName }", "Turn off fulfillment": "Turn off fulfillment", "Turn on fulfillment": "Turn on fulfillment", "Turn on fulfillment for ": "Turn on fulfillment for { facilityName }", diff --git a/src/locales/es.json b/src/locales/es.json index 31724ae4..5a867ff6 100644 --- a/src/locales/es.json +++ b/src/locales/es.json @@ -206,6 +206,8 @@ "To Name": "To Name", "Tracking Code": "Código de Seguimiento", "Tracking ID": "ID de Seguimiento", + "Turn off Ecom inventory": "Turn off Ecom inventory", + "Turn on Ecom inventory": "Turn on Ecom inventory", "Turn off fulfillment": "Desactivar Cumplimiento", "Turn on fulfillment": "Activar Cumplimiento", "Turn on fulfillment for ": "Activar cumplimiento para {facilityName}", diff --git a/src/services/UserService.ts b/src/services/UserService.ts index 9e7f36fa..282b2818 100644 --- a/src/services/UserService.ts +++ b/src/services/UserService.ts @@ -45,7 +45,39 @@ const updateFacility = async (payload: any): Promise => { }) } -const recycleInProgressOrders = async(payload: any): Promise => { +const updateFacilityToGroup = async (payload: any): Promise => { + return api({ + url: "service/updateFacilityToGroup", + method: "post", + data: payload + }) +} + +const addFacilityToGroup = async (payload: any): Promise => { + return api({ + url: "service/addFacilityToGroup", + method: "post", + data: payload + }) +} + +const getFacilityGroupDetails = async (payload: any): Promise => { + return api({ + url: "performFind", + method: "get", + params: payload + }) +} + +const getFacilityGroupAndMemberDetails = async (payload: any): Promise => { + return api({ + url: "performFind", + method: "get", + params: payload + }) +} + +const recycleInProgressOrders = async (payload: any): Promise => { return api({ url: "service/bulkRejectStoreInProgressOrders", method: "post", @@ -97,7 +129,7 @@ const getEComStores = async (token: any, facilityId: any): Promise => { baseURL, params, headers: { - Authorization: 'Bearer ' + token, + Authorization: 'Bearer ' + token, 'Content-Type': 'application/json' } }); @@ -234,7 +266,7 @@ const getUserProfile = async (token: any): Promise => { method: "get", baseURL, headers: { - Authorization: 'Bearer ' + token, + Authorization: 'Bearer ' + token, 'Content-Type': 'application/json' } }); @@ -286,6 +318,7 @@ const getFieldMappings = async (payload: any): Promise => { } export const UserService = { + addFacilityToGroup, createFieldMapping, deleteFieldMapping, login, @@ -293,6 +326,8 @@ export const UserService = { getEComStores, getFacilityDetails, getFieldMappings, + getFacilityGroupDetails, + getFacilityGroupAndMemberDetails, getInProgressOrdersCount, getOutstandingOrdersCount, getUserProfile, @@ -303,5 +338,6 @@ export const UserService = { setUserTimeZone, getUserPermissions, updateFacility, + updateFacilityToGroup, updateFieldMapping } \ No newline at end of file diff --git a/src/views/Settings.vue b/src/views/Settings.vue index 0358d936..54dab65e 100644 --- a/src/views/Settings.vue +++ b/src/views/Settings.vue @@ -58,8 +58,12 @@
- {{ $t("Turn off fulfillment") }} - {{ $t("Turn on fulfillment") }} + {{ $t("Turn off fulfillment") }} + {{ $t("Turn on fulfillment") }} +
+
+ {{ $t("Turn off eCom inventory") }} + {{ $t("Turn on eCom inventory") }}
@@ -138,6 +142,7 @@ export default defineComponent({ return { baseURL: process.env.VUE_APP_BASE_URL, currentFacilityDetails: {} as any, + facilityGroupDetails: {} as any, outstandingOrdersCount: 0, inProgressOrdersCount: 0 }; @@ -153,10 +158,15 @@ export default defineComponent({ isStoreFulfillmentTurnOn() { // considered that if facility details are not available then also fulfillment will be turned on return this.currentFacilityDetails.maximumOrderLimit != 0 + }, + isEcomInvTurnedOn() { + // if facilityGroupDetails are there, configuration is turned on + return Object.keys(this.facilityGroupDetails).length } }, ionViewWillEnter() { this.getCurrentFacilityDetails() + this.getEcomInvStatus() this.getOutstandingOrdersCount() this.getInProgressOrdersCount() }, @@ -249,6 +259,45 @@ export default defineComponent({ logger.error('Failed to fetch current facility details', err) } }, + async getEcomInvStatus() { + let resp: any; + try { + this.facilityGroupDetails = {} + + resp = await UserService.getFacilityGroupDetails({ + "entityName": "FacilityGroup", + "inputFields": { + "facilityGroupTypeId": 'SHOPIFY_GROUP_FAC' + }, + "fieldList": ["facilityGroupId", "facilityGroupTypeId"], + "viewSize": 1, + }) + + if (!hasError(resp)) { + const facilityGroupData = resp.data.docs[0] + resp = await UserService.getFacilityGroupDetails({ + "entityName": "FacilityGroupAndMember", + "inputFields": { + "facilityId": this.currentFacility.facilityId, + "facilityGroupId": facilityGroupData.facilityGroupId + }, + "fieldList": ["facilityGroupId", "facilityId", "fromDate"], + "viewSize": 1, + "filterByDate": 'Y' + }) + + if (!hasError(resp)) { + this.facilityGroupDetails = resp.data.docs[0] + this.facilityGroupDetails.facilityGroupId = facilityGroupData.facilityGroupId + } + else throw resp.data + } else { + throw resp.data + } + } catch (err) { + logger.error('Failed to fetch eCom inventory config', err) + } + }, async openRecyclePopover(ev: Event) { const popover = await popoverController.create({ component: RecyclePopover, @@ -307,6 +356,43 @@ export default defineComponent({ logger.error('Failed to update facility', err) } }, + async updateFacilityToGroup() { + let resp; + try { + resp = await UserService.updateFacilityToGroup({ + "facilityId": this.currentFacility.facilityId, + "facilityGroupId": this.facilityGroupDetails.facilityGroupId, + "fromDate": this.facilityGroupDetails.fromDate + }) + + if (!hasError(resp)) { + showToast(translate('ECom inventory status updated successfully')) + } else { + throw resp.data + } + } catch (err) { + showToast(translate('Failed to update eCom inventory status')) + logger.error('Failed to update eCom inventory status', err) + } + }, + async addFacilityToGroup() { + let resp; + try { + resp = await UserService.addFacilityToGroup({ + "facilityId": this.currentFacility.facilityId, + "facilityGroupId": this.facilityGroupDetails.facilityGroupId + }) + + if (!hasError(resp)) { + showToast(translate('ECom inventory status updated successfully')) + } else { + throw resp.data + } + } catch (err) { + showToast(translate('Failed to update eCom inventory status')) + logger.error('Failed to update eCom inventory status', err) + } + }, async turnOnFulfillment() { const alert = await alertController.create({ header: this.$t('Turn on fulfillment for ', { facilityName: this.currentFacility.name }), @@ -351,6 +437,40 @@ export default defineComponent({ await alert.present(); }, + async turnOnEcomInv() { + const alert = await alertController.create({ + header: this.$t('Turn on eCom inventory for ', { facilityName: this.currentFacility.name }), + message: translate('Are you sure you want perform this action?'), + buttons: [{ + text: translate('Cancel'), + role: 'cancel' + }, { + text: translate('Save'), + handler: async () => { + await this.addFacilityToGroup() + } + }], + }); + + await alert.present(); + }, + async turnOffEcomInv() { + const alert = await alertController.create({ + header: this.$t('Turn off eCom inventory for ', { facilityName: this.currentFacility.name }), + message: translate('Are you sure you want perform this action?'), + buttons: [{ + text: translate('Cancel'), + role: 'cancel' + }, { + text: translate('Save'), + handler: async () => { + await this.updateFacilityToGroup() + } + }], + }); + + await alert.present(); + }, async recycleOutstandingOrders() { const alert = await alertController.create({ header: translate('Recycle outstanding orders'), From 57dc2870547ff2366a62380bb940fcf0001c8859 Mon Sep 17 00:00:00 2001 From: k2maan Date: Tue, 1 Aug 2023 11:16:19 +0530 Subject: [PATCH 02/50] Added: missing labels in es.json and reverted unwanted formatting changes (#141) --- src/locales/en.json | 2 +- src/locales/es.json | 9 +++++++-- src/services/UserService.ts | 6 +++--- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/locales/en.json b/src/locales/en.json index a21e6520..4cbe73e1 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -211,8 +211,8 @@ "Tracking ID": "Tracking ID", "Turn off eCom inventory": "Turn off eCom inventory", "Turn on eCom inventory": "Turn on eCom inventory", - "Turn on eCom inventory for ": "Turn on eCom inventory for { facilityName }", "Turn off eCom inventory for ": "Turn off eCom inventory for { facilityName }", + "Turn on eCom inventory for ": "Turn on eCom inventory for { facilityName }", "Turn off fulfillment": "Turn off fulfillment", "Turn on fulfillment": "Turn on fulfillment", "Turn on fulfillment for ": "Turn on fulfillment for { facilityName }", diff --git a/src/locales/es.json b/src/locales/es.json index 5a867ff6..056fff2f 100644 --- a/src/locales/es.json +++ b/src/locales/es.json @@ -38,6 +38,7 @@ "Download orders that are packed and haven't been shipped yet. Use the downloaded file to send the packed order details to a carrier where shipping labels and tracking codes will be generated.": "Descarga los pedidos que están empacados y aún no se han enviado. Utiliza el archivo descargado para enviar los detalles de los pedidos empacados a una empresa de transporte donde se generarán las etiquetas de envío y los códigos de seguimiento.", "Download packed orders": "Descargar pedidos empacados", "eCom Store": "Tienda eCom", + "ECom inventory status updated successfully": "ECom inventory status updated successfully", "Edit packaging": "Editar empaque", "Email": "Email", "Enter key": "Ingresar clave", @@ -58,6 +59,7 @@ "Failed to add box": "Error al agregar la caja", "Failed to create picklist for orders": "Error al crear la lista de selección para los pedidos", "Failed to delete CSV mapping.": "Failed to delete CSV mapping.", + "Failed to fetch eCom inventory config": "Failed to fetch eCom inventory config", "Failed to generate shipping label": "Error al generar la etiqueta de envío", "Failed to get packed orders information": "Error al obtener la información de los pedidos empacados", "Failed to pack order": "Error al empacar el pedido", @@ -69,6 +71,7 @@ "Failed to recycle in progress orders": "Error al reciclar los pedidos en curso", "Failed to recycle outstanding orders": "Error al reciclar los pedidos pendientes", "Failed to update CSV mapping.": "Failed to update CSV mapping.", + "Failed to update eCom inventory status": "Failed to update eCom inventory status", "Failed to update facility": "Error al actualizar la instalación", "Failed to update order": "Error al actualizar el pedido", "Field mapping name": "Field mapping name", @@ -206,8 +209,10 @@ "To Name": "To Name", "Tracking Code": "Código de Seguimiento", "Tracking ID": "ID de Seguimiento", - "Turn off Ecom inventory": "Turn off Ecom inventory", - "Turn on Ecom inventory": "Turn on Ecom inventory", + "Turn off eCom inventory": "Turn off eCom inventory", + "Turn on eCom inventory": "Turn on eCom inventory", + "Turn off eCom inventory for ": "Turn off eCom inventory for { facilityName }", + "Turn on eCom inventory for ": "Turn on eCom inventory for { facilityName }", "Turn off fulfillment": "Desactivar Cumplimiento", "Turn on fulfillment": "Activar Cumplimiento", "Turn on fulfillment for ": "Activar cumplimiento para {facilityName}", diff --git a/src/services/UserService.ts b/src/services/UserService.ts index 282b2818..f43b69fd 100644 --- a/src/services/UserService.ts +++ b/src/services/UserService.ts @@ -77,7 +77,7 @@ const getFacilityGroupAndMemberDetails = async (payload: any): Promise => { }) } -const recycleInProgressOrders = async (payload: any): Promise => { +const recycleInProgressOrders = async(payload: any): Promise => { return api({ url: "service/bulkRejectStoreInProgressOrders", method: "post", @@ -129,7 +129,7 @@ const getEComStores = async (token: any, facilityId: any): Promise => { baseURL, params, headers: { - Authorization: 'Bearer ' + token, + Authorization: 'Bearer ' + token, 'Content-Type': 'application/json' } }); @@ -266,7 +266,7 @@ const getUserProfile = async (token: any): Promise => { method: "get", baseURL, headers: { - Authorization: 'Bearer ' + token, + Authorization: 'Bearer ' + token, 'Content-Type': 'application/json' } }); From cb10f9fb7f56d43b605f9ad2ec199e3cc8a4c990 Mon Sep 17 00:00:00 2001 From: k2maan Date: Tue, 1 Aug 2023 12:43:15 +0530 Subject: [PATCH 03/50] Implemented: logic to hide the buttons if config is not there and ficed labels (#141) --- src/views/Settings.vue | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/views/Settings.vue b/src/views/Settings.vue index 54dab65e..37ec5651 100644 --- a/src/views/Settings.vue +++ b/src/views/Settings.vue @@ -63,7 +63,7 @@
{{ $t("Turn off eCom inventory") }} - {{ $t("Turn on eCom inventory") }} + {{ $t("Turn on eCom inventory") }}
@@ -160,8 +160,13 @@ export default defineComponent({ return this.currentFacilityDetails.maximumOrderLimit != 0 }, isEcomInvTurnedOn() { - // if facilityGroupDetails are there, configuration is turned on - return Object.keys(this.facilityGroupDetails).length + // if facilityGroupDetails are there with fromDate (using fromDate as a flag for + // getting data from getFacilityGroupAndMemberDetails) - facility is turned on + return Object.keys(this.facilityGroupDetails).length && this.facilityGroupDetails?.fromDate + }, + isEcomInvConfigured() { + // if facilityGroupDetails are there with facilityGroupId, configuration is there but turned off + return Object.keys(this.facilityGroupDetails).length && this.facilityGroupDetails?.facilityGroupId } }, ionViewWillEnter() { @@ -274,21 +279,21 @@ export default defineComponent({ }) if (!hasError(resp)) { - const facilityGroupData = resp.data.docs[0] - resp = await UserService.getFacilityGroupDetails({ + // using facilityGroupId as a flag for getting data from getFacilityGroupDetails + this.facilityGroupDetails.facilityGroupId = resp.data.docs[0].facilityGroupId + resp = await UserService.getFacilityGroupAndMemberDetails({ "entityName": "FacilityGroupAndMember", "inputFields": { "facilityId": this.currentFacility.facilityId, - "facilityGroupId": facilityGroupData.facilityGroupId + "facilityGroupId": this.facilityGroupDetails.facilityGroupId }, - "fieldList": ["facilityGroupId", "facilityId", "fromDate"], + "fieldList": ["facilityId", "fromDate"], "viewSize": 1, "filterByDate": 'Y' }) if (!hasError(resp)) { - this.facilityGroupDetails = resp.data.docs[0] - this.facilityGroupDetails.facilityGroupId = facilityGroupData.facilityGroupId + this.facilityGroupDetails = { ...this.facilityGroupDetails, ...resp.data.docs[0] } } else throw resp.data } else { @@ -423,7 +428,7 @@ export default defineComponent({ async turnOffFulfillment() { const alert = await alertController.create({ header: this.$t('Turn off fulfillment for ', { facilityName: this.currentFacility.name }), - message: translate('Are you sure you want perform this action?'), + message: translate('Are you sure you want to perform this action?'), buttons: [{ text: translate('Cancel'), role: 'cancel' @@ -440,7 +445,7 @@ export default defineComponent({ async turnOnEcomInv() { const alert = await alertController.create({ header: this.$t('Turn on eCom inventory for ', { facilityName: this.currentFacility.name }), - message: translate('Are you sure you want perform this action?'), + message: translate('Are you sure you want to perform this action?'), buttons: [{ text: translate('Cancel'), role: 'cancel' @@ -457,7 +462,7 @@ export default defineComponent({ async turnOffEcomInv() { const alert = await alertController.create({ header: this.$t('Turn off eCom inventory for ', { facilityName: this.currentFacility.name }), - message: translate('Are you sure you want perform this action?'), + message: translate('Are you sure you want to perform this action?'), buttons: [{ text: translate('Cancel'), role: 'cancel' From 144c1ff73dd5a40a0789124e24f7c1dca2263842 Mon Sep 17 00:00:00 2001 From: k2maan Date: Wed, 23 Aug 2023 12:21:55 +0530 Subject: [PATCH 04/50] Updated: replaced button UI and logic with toggle (#141) --- src/views/Settings.vue | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/src/views/Settings.vue b/src/views/Settings.vue index 73767983..9ccaacce 100644 --- a/src/views/Settings.vue +++ b/src/views/Settings.vue @@ -106,7 +106,7 @@ {{ $t("Fulfill online orders") }} - + @@ -121,7 +121,7 @@ {{ $t("Sell online") }} - + @@ -266,7 +266,8 @@ export default defineComponent({ facilityGroupDetails: {} as any, outstandingOrdersCount: 0, inProgressOrdersCount: 0, - isStoreFulfilmentTurnedOn: true + isStoreFulfilmentTurnedOn: true, + isEComInvTurnedOn: true }; }, computed: { @@ -282,14 +283,14 @@ export default defineComponent({ // considered that if facility details are not available then also fulfillment will be turned on return this.currentFacilityDetails.maximumOrderLimit != 0 }, - isEcomInvTurnedOn() { + eComInvStatus() { // if facilityGroupDetails are there with fromDate (using fromDate as a flag for // getting data from getFacilityGroupAndMemberDetails) - facility is turned on - return Object.keys(this.facilityGroupDetails).length && this.facilityGroupDetails?.fromDate + return !!(Object.keys(this.facilityGroupDetails).length && this.facilityGroupDetails?.fromDate) }, - isEcomInvConfigured() { + eComInvConfigStatus() { // if facilityGroupDetails are there with facilityGroupId, configuration is there but turned off - return Object.keys(this.facilityGroupDetails).length && this.facilityGroupDetails?.facilityGroupId + return !!(Object.keys(this.facilityGroupDetails).length && this.facilityGroupDetails?.facilityGroupId) } }, mounted() { @@ -365,6 +366,10 @@ export default defineComponent({ } } catch (err) { logger.error('Failed to fetch eCom inventory config', err) + } finally { + // updating it here as facilityGroupDetails is not available in the lifecycle hooks + // and using the computed property in the lifecycle hook is not updating it later + this.isEComInvTurnedOn = !!(Object.keys(this.facilityGroupDetails).length && this.facilityGroupDetails?.fromDate) } }, logout () { @@ -461,6 +466,12 @@ export default defineComponent({ if (event.detail.checked === this.fulfillmentStatus) return event.detail.checked ? this.turnOnFulfillment() : this.turnOffFulfillment() }, + async updateEComInvStatus(event: any) { + // condition to stop alert from re-popping as ionChange is triggered + // because isEComInvStatus is updated + if (event.detail.checked === this.eComInvStatus) return + event.detail.checked ? this.turnOnEComInv() : this.turnOffEComInv() + }, async turnOnFulfillment() { const alert = await alertController.create({ header: this.$t('Turn on fulfillment for ', { facilityName: this.currentFacility.name }), @@ -509,13 +520,15 @@ export default defineComponent({ await alert.present(); }, - async turnOnEcomInv() { + async turnOnEComInv() { const alert = await alertController.create({ header: this.$t('Turn on eCom inventory for ', { facilityName: this.currentFacility.name }), message: translate('Are you sure you want to perform this action?'), buttons: [{ text: translate('Cancel'), - role: 'cancel' + handler: () => { + this.isEComInvTurnedOn = this.eComInvStatus + } }, { text: translate('Save'), handler: async () => { @@ -526,13 +539,15 @@ export default defineComponent({ await alert.present(); }, - async turnOffEcomInv() { + async turnOffEComInv() { const alert = await alertController.create({ header: this.$t('Turn off eCom inventory for ', { facilityName: this.currentFacility.name }), message: translate('Are you sure you want to perform this action?'), buttons: [{ text: translate('Cancel'), - role: 'cancel' + handler: () => { + this.isEComInvTurnedOn = this.eComInvStatus + } }, { text: translate('Save'), handler: async () => { From 08f295ffcbf114655e6065c80a5cb64d03df31b0 Mon Sep 17 00:00:00 2001 From: k2maan Date: Wed, 23 Aug 2023 12:25:47 +0530 Subject: [PATCH 05/50] Removed: unused code (#141) --- src/views/Settings.vue | 68 ------------------------------------------ 1 file changed, 68 deletions(-) diff --git a/src/views/Settings.vue b/src/views/Settings.vue index 9ccaacce..17dad510 100644 --- a/src/views/Settings.vue +++ b/src/views/Settings.vue @@ -558,74 +558,6 @@ export default defineComponent({ await alert.present(); }, - async recycleOutstandingOrders() { - const alert = await alertController.create({ - header: translate('Recycle outstanding orders'), - message: this.$t('Are you sure you want to recycle outstanding order(s)?', { ordersCount: this.outstandingOrdersCount }), - buttons: [{ - text: translate('No'), - role: 'cancel' - }, { - text: translate('Yes'), - handler: async () => { - let resp; - - try { - resp = await UserService.recycleOutstandingOrders({ - "facilityId": this.currentFacility.facilityId, - "productStoreId": this.currentEComStore.productStoreId, - "reasonId": "INACTIVE_STORE" - }) - - if(!hasError(resp)) { - showToast(translate('Recycling has been started. All outstanding orders will be recycled shortly.')) - } else { - throw resp.data - } - } catch(err) { - showToast(translate('Failed to recycle outstanding orders')) - logger.error('Failed to recycle outstanding orders', err) - } - } - }] - }); - - await alert.present(); - }, - async recycleInProgressOrders() { - const alert = await alertController.create({ - header: translate('Recycle in progress orders'), - message: this.$t('Are you sure you want to recycle in progress order(s)?', { ordersCount: this.inProgressOrdersCount }), - buttons: [{ - text: translate('No'), - role: 'cancel' - }, { - text: translate('Yes'), - handler: async () => { - let resp; - - try { - resp = await UserService.recycleInProgressOrders({ - "facilityId": this.currentFacility.facilityId, - "productStoreId": this.currentEComStore.productStoreId, - "reasonId": "INACTIVE_STORE" - }) - - if(!hasError(resp)) { - showToast(translate('Recycling has been started. All in progress orders will be recycled shortly.')) - } else { - throw resp.data - } - } catch(err) { - showToast(translate('Failed to recycle in progress orders')) - logger.error('Failed to recycle in progress orders', err) - } - } - }] - }); - - await alert.present(); - }, async setEComStore(event: any) { // not updating the ecomstore when the current value in vuex state and selected value are same // or when an empty value is given (on logout) From 3204b027661f06708ade5567e8247d8a773776bc Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Thu, 24 Aug 2023 10:22:35 +0530 Subject: [PATCH 06/50] Implemented: Store Order Limit on Online Fulfillment Card in the settings page(#241) --- src/locales/en.json | 17 +++- src/locales/es.json | 17 +++- src/services/UserService.ts | 9 ++ src/views/Settings.vue | 143 ++++++++++++++++++-------------- src/views/orderLimitPopover.vue | 110 ++++++++++++++++++++++++ 5 files changed, 231 insertions(+), 65 deletions(-) create mode 100644 src/views/orderLimitPopover.vue diff --git a/src/locales/en.json b/src/locales/en.json index ab3f8c74..1fd80e22 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -9,6 +9,7 @@ "Additional documents": "Additional documents", "Address 1": "Address 1", "Address 2": "Address 2", + "Apply": "Apply", "Authenticating": "Authenticating", "Are you sure you want to change the time zone to?": "Are you sure you want to change the time zone to?", "Are you sure you want to delete this CSV mapping? This action cannot be undone.": "Are you sure you want to delete this CSV mapping? This action cannot be undone.", @@ -28,12 +29,15 @@ "Completed": "Completed", "Configuration Missing": "Configuration Missing", "Confirm": "Confirm", + "Configure the order fulfillment capacity of your facility.": "Configure the order fulfillment capacity of your facility.", "Control whether the store's inventory should be made available for online sales or not.": "Control whether the store's inventory should be made available for online sales or not.", "Copied": "Copied { value }", "Copied to clipboard": "Copied to clipboard", "Country Code": "Country Code", "CSV Mapping": "CSV Mapping", "Custom Label": "Custom Label", + "Custom": "Custom", + "Custom fulfillment capacity": "Custom fulfillment capacity", "Customer letter": "Customer letter", "Damaged": "Damaged", "Define custom label for": "Define custom label for {field}", @@ -82,7 +86,7 @@ "File downloaded successfully": "File downloaded successfully", "File uploaded successfully": "File uploaded successfully", "Full Address": "Full Address", - "Fulfill online orders": "Fulfill online orders", + "Fulfillment Capacity": "Fulfillment Capacity", "Generate packing slip": "Generate packing slip", "Generate shipping label": "Generate shipping label", "Go to OMS": "Go to OMS", @@ -109,7 +113,9 @@ "Mismatch": "Mismatch", "No": "No", "No data Found.": "No data Found.", + "No capacity removes 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.": "No capacity removes 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.", "No new file upload. Please try again": "No new file upload. Please try again", + "No fulfillment capacity": "No fulfillment capacity", "No reason": "No reason", "No results found for . Try searching Open or Completed tab instead. If you still can't find what you're looking for, try switching stores.": "No results found for { searchedQuery }. Try searching Open or Completed tab instead.{ lineBreak } If you still can't find what you're looking for, try switching stores.", "No results found for . Try searching In Progress or Open tab instead. If you still can't find what you're looking for, try switching stores.": "No results found for { searchedQuery }. Try searching In Progress or Open tab instead.{ lineBreak } If you still can't find what you're looking for, try switching stores.", @@ -124,6 +130,9 @@ "On": "On", "Online Order Fulfillment": "Online Order Fulfillment", "Open": "Open", + "orders allocated today": "{orderCount} orders allocated today", + "orders in fulfillment queue": "{orderCount} orders in fulfillment queue", + "Order fulfillment capacity updated successfully": "Order fulfillment capacity updated successfully", "Ordered": "Ordered", "Order ID": "Order ID", "Order packed successfully": "Order packed successfully", @@ -136,6 +145,7 @@ "Out of stock": "Out of stock", "New mapping": "New mapping", "Next day": "Next day", + "No Capacity": "No Capacity", "No packed shipments to ship for these orders": "No packed shipments to ship for these orders", "package": "package", "packages": "packages", @@ -197,6 +207,7 @@ "Select your preferred language.": "Select your preferred language.", "Sell inventory online": "Sell inventory online", "Sell online": "Sell online", + "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.", "Settings": "Settings", "Set Limit": "Set Limit", "Ship": "Ship", @@ -239,6 +250,10 @@ "Turn on fulfillment": "Turn on fulfillment", "Turn on fulfillment for ": "Turn on fulfillment for { facilityName }", "Turn off fulfillment for ": "Turn off fulfillment for { facilityName }", + "Unlimited": "Unlimited", + "Unlimited Capacity": "Unlimited Capacity", + "Unlimited capacity removes the fulfillment capacity limit entirely. To add a fulfillment capacity to this facility, use the custom option.": "Unlimited capacity removes the fulfillment capacity limit entirely. To add a fulfillment capacity to this facility, use the custom option.", + "Unlimited fulfillment capacity": "Unlimited fulfillment capacity", "Unpack": "Unpack", "Unpacking this order will send it back to 'In progress' and it will have to be repacked.": "Unpacking this order will send it back to 'In progress' and it will have to be repacked.", "Update": "Update", diff --git a/src/locales/es.json b/src/locales/es.json index 26896679..015e5263 100644 --- a/src/locales/es.json +++ b/src/locales/es.json @@ -9,6 +9,7 @@ "Additional documents": "Additional documents", "Address 1": "Address 1", "Address 2": "Address 2", + "Apply": "Apply", "Authenticating": "Authenticating", "Are you sure you want to change the time zone to?": "¿Estás seguro/a de que quieres cambiar la zona horaria a?", "Are you sure you want to delete this CSV mapping? This action cannot be undone.": "Are you sure you want to delete this CSV mapping? This action cannot be undone.", @@ -28,11 +29,14 @@ "Completed": "Completado", "Configuration Missing": "Configuración Faltante", "Confirm": "Confirmar", + "Configure the order fulfillment capacity of your facility.": "Configure the order fulfillment capacity of your facility.", "Control whether the store's inventory should be made available for online sales or not.": "Control whether the store's inventory should be made available for online sales or not.", "Copied": "Copiado {texto}", "Copied to clipboard": "Copiado al portapapeles", "Country Code": "Country Code", "CSV Mapping": "CSV Mapping", + "Custom": "Custom", + "Custom fulfillment capacity": "Custom fulfillment capacity", "Custom Label": "Etiqueta Personalizada", "Customer letter": "Carta al Cliente", "Damaged": "Dañado", @@ -82,7 +86,7 @@ "File downloaded successfully": "Archivo descargado exitosamente", "File uploaded successfully": "Archivo cargado exitosamente", "Full Address": "Full Address", - "Fulfill online orders": "Fulfill online orders", + "Fulfillment Capacity": "Fulfillment Capacity", "Generate packing slip": "Generate packing slip", "Generate shipping label": "Generate shipping label", "Go to OMS": "Go to OMS", @@ -108,6 +112,8 @@ "Mapping name": "Mapping name", "Mismatch": "Inconsistencia", "No": "No", + "No Capacity": "No Capacity", + "No capacity removes 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 removes 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 data Found.": "No data Found.", "No new file upload. Please try again": "No se cargó ningún archivo nuevo. Por favor, inténtalo nuevamente.", "No reason": "Sin motivo", @@ -115,8 +121,11 @@ "No results found for . Try searching In Progress or Open tab instead. If you still can't find what you're looking for, try switching stores.": "No results found for { searchedQuery }. Try searching In Progress or Open tab instead.{ lineBreak } If you still can't find what you're looking for, try switching stores.", "No results found for . Try searching In Progress or Completed tab instead. If you still can't find what you're looking for, try switching stores.": "No results found for { searchedQuery }. Try searching In Progress or Completed tab instead.{ lineBreak } If you still can't find what you're looking for, try switching stores.", "No time zone found": "No se encontró zona horaria", + "No fulfillment capacity": "No fulfillment capacity", "Not in Stock": "No en Stock", "order": "pedido", + "orders allocated today": "{orderCount} orders allocated today", + "orders in fulfillment queue": "{orderCount} orders in fulfillment queue", "of": "de", "Off": "Apagado", "OMS": "OMS", @@ -125,6 +134,7 @@ "Online Order Fulfillment": "Online Order Fulfillment", "Open": "Abierto", "Ordered": "Ordenado", + "Order fulfillment capacity updated successfully": "Order fulfillment capacity updated successfully", "Order ID": "ID del Pedido", "Order packed successfully": "Pedido empacado exitosamente", "Order packed successfully. Document generation in process": "Order packed successfully. Document generation in process", @@ -198,6 +208,7 @@ "Select your preferred language.": "Select your preferred language.", "Sell inventory online": "Sell inventory online", "Sell online": "Sell online", + "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.", "Settings": "Configuraciones", "Set Limit": "Establecer Límite", "Ship": "Enviar", @@ -239,6 +250,10 @@ "Turn on fulfillment": "Activar Cumplimiento", "Turn on fulfillment for ": "Activar cumplimiento para {facilityName}", "Turn off fulfillment for ": "Desactivar cumplimiento para {facilityName}", + "Unlimited": "Unlimited", + "Unlimited Capacity": "Unlimited Capacity", + "Unlimited fulfillment capacity": "Unlimited fulfillment capacity", + "Unlimited capacity removes the fulfillment capacity limit entirely. To add a fulfillment capacity to this facility, use the custom option.": "Unlimited capacity removes the fulfillment capacity limit entirely. To add a fulfillment capacity to this facility, use the custom option.", "Unpack": "Desempacar", "Unpacking this order will send it back to 'In progress' and it will have to be repacked.": "Desempacar este pedido lo enviará de vuelta a 'En curso' y tendrá que ser vuelto a empacar.", "Update": "Update", diff --git a/src/services/UserService.ts b/src/services/UserService.ts index 6742dc6e..d3ba6af5 100644 --- a/src/services/UserService.ts +++ b/src/services/UserService.ts @@ -37,6 +37,15 @@ const getFacilityDetails = async (payload: any): Promise => { }) } +const getCurrentOrderCount = async (payload: any): Promise => { + return api({ + url: "performFind", + method: "get", + params: payload, + cached: true + }) +} + const updateFacility = async (payload: any): Promise => { return api({ url: "service/updateFacility", diff --git a/src/views/Settings.vue b/src/views/Settings.vue index 099b916d..6ad0fc3d 100644 --- a/src/views/Settings.vue +++ b/src/views/Settings.vue @@ -101,12 +101,23 @@ - {{ $t('Specify whether the store should fulfill online orders or not.') }} + {{ $t('Configure the order fulfillment capacity of your facility.') }} - - {{ $t("Fulfill online orders") }} - - + + {{ $t("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.") }} + + + {{currentFacilityDetails?.orderCount}} + + {{currentFacilityDetails?.maximumOrderLimit}} + + + {{ $t("orders allocated today", {orderCount: currentFacilityDetails?.orderCount}) }} + {{ $t("Unlimited") }} + + + {{ $t("orders in fulfillment queue", {orderCount: currentFacilityDetails?.orderCount}) }} + {{ fulfillmentOrderLimit }} @@ -203,6 +214,7 @@ import { IonCardHeader, IonCardTitle, IonCardSubtitle, + IonChip, IonContent, IonHeader, IonIcon, @@ -210,13 +222,16 @@ import { IonLabel, IonMenuButton, IonPage, + IonProgressBar, IonSelect, IonSelectOption, IonTitle, + IonText, IonToggle, IonToolbar, modalController, - alertController + alertController, + popoverController } from '@ionic/vue'; import { defineComponent } from 'vue'; import { codeWorkingOutline, ellipsisVerticalOutline, globeOutline, openOutline, timeOutline } from 'ionicons/icons' @@ -231,6 +246,7 @@ import logger from '@/logger'; import { Actions, hasPermission } from '@/authorization' import { DateTime } from 'luxon'; import Image from '@/components/Image.vue'; +import orderLimitPopover from '@/views/orderLimitPopover.vue' export default defineComponent({ name: 'Settings', @@ -242,6 +258,7 @@ export default defineComponent({ IonCardHeader, IonCardTitle, IonCardSubtitle, + IonChip, IonContent, IonHeader, IonIcon, @@ -249,9 +266,11 @@ export default defineComponent({ IonLabel, IonMenuButton, IonPage, + IonProgressBar, IonSelect, IonSelectOption, IonTitle, + IonText, IonToggle, IonToolbar, Image @@ -263,7 +282,8 @@ export default defineComponent({ appVersion: "", locales: process.env.VUE_APP_LOCALES ? JSON.parse(process.env.VUE_APP_LOCALES) : {"en": "English"}, currentFacilityDetails: {} as any, - isStoreFulfilmentTurnedOn: true + orderLimitMode: 'custom', + fulfillmentOrderLimit: 0 }; }, computed: { @@ -285,6 +305,7 @@ export default defineComponent({ }, ionViewWillEnter() { this.getCurrentFacilityDetails() + this.getCurrentOrdersCount() }, methods: { async getCurrentFacilityDetails() { @@ -310,11 +331,38 @@ export default defineComponent({ } catch(err) { logger.error('Failed to fetch current facility details', err) } finally { - // declaration of isStoreFulfilmentTurnedOn in lifecycle hooks always - // returns 'true' because of the != 0 condition, hence, updating it here - this.isStoreFulfilmentTurnedOn = this.currentFacilityDetails?.maximumOrderLimit != 0 + this.updateOrderLimitMode() + } + }, + async getCurrentOrdersCount() { + let resp: any; + try { + resp = await UserService.getFacilityDetails({ + "entityName": "FacilityOrderCount", + "inputFields": { + "facilityId": this.currentFacility.facilityId + } + }) + + if(!hasError(resp) && resp.data.count) { + this.currentFacilityDetails.orderCount = resp.data.count + } else { + throw resp.data + } + } catch(err) { + console.log("Failed to fetch total orders count", err); } }, + updateOrderLimitMode() { + this.fulfillmentOrderLimit = this.currentFacilityDetails?.maximumOrderLimit + if(this.currentFacilityDetails?.maximumOrderLimit == 0){ + this.orderLimitMode = 'no-capacity' + }else if(this.currentFacilityDetails?.maximumOrderLimit == null || ""){ + this.orderLimitMode = 'unlimited' + }else{ + this.orderLimitMode = 'custom' + } + }, logout () { this.store.dispatch('user/logout').then(() => { this.store.dispatch('order/clearOrders') @@ -325,6 +373,24 @@ export default defineComponent({ goToLaunchpad() { window.location.href = `${process.env.VUE_APP_LOGIN_URL}` }, + async changeOrderLimitPopover(ev: Event) { + const popover = await popoverController.create({ + component: orderLimitPopover, + event: ev, + translucent: true, + showBackdrop: false, + componentProps: {fulfillmentOrderLimit: this.fulfillmentOrderLimit} + }); + popover.present(); + + const result = await popover.onDidDismiss(); + + if(result.data != undefined && result.data !== this.fulfillmentOrderLimit){ + const resultData = result.data; + await this.updateFacility(resultData) + this.updateOrderLimitMode() + } + }, async setFacility (event: any) { // not updating the facility when the current facility in vuex state and the selected facility are same // or when an empty value is given (on logout) @@ -346,18 +412,18 @@ export default defineComponent({ }); return timeZoneModal.present(); }, - async updateFacility(maximumOrderLimit: number) { + async updateFacility(maximumOrderLimit: any) { let resp; try { resp = await UserService.updateFacility({ "facilityId": this.currentFacility.facilityId, - maximumOrderLimit + maximumOrderLimit: maximumOrderLimit }) if(!hasError(resp)) { - this.currentFacilityDetails.maximumOrderLimit = maximumOrderLimit - showToast(translate('Facility updated successfully')) + this.currentFacilityDetails.maximumOrderLimit = maximumOrderLimit === "" ? null : maximumOrderLimit + showToast(translate('Order fulfillment capacity updated successfully')) } else { throw resp.data } @@ -370,55 +436,6 @@ export default defineComponent({ // condition to stop alert from re-popping as ionChange is triggered // because isStoreFulfilmentTurnedOn is updated if (event.detail.checked === this.fulfillmentStatus) return - event.detail.checked ? this.turnOnFulfillment() : this.turnOffFulfillment() - }, - async turnOnFulfillment() { - const alert = await alertController.create({ - header: this.$t('Turn on fulfillment for ', { facilityName: this.currentFacility.name }), - buttons: [{ - text: translate('Cancel'), - handler: () => { - this.isStoreFulfilmentTurnedOn = this.fulfillmentStatus - } - }, { - text: translate('Save'), - handler: (data) => { - // Adding this extra check as min attribute does not work when providing input using keyboard - if (data.setLimit <= 0) { - showToast(translate('Provide a value greater than 0')) - return; - } - this.updateFacility(data.setLimit) - } - }], - inputs: [{ - name: 'setLimit', - min: 1, - type: 'number', - placeholder: translate('Set Limit') - }], - }); - - await alert.present(); - }, - async turnOffFulfillment() { - const alert = await alertController.create({ - header: this.$t('Turn off fulfillment for ', { facilityName: this.currentFacility.name }), - message: translate('Are you sure you want perform this action?'), - buttons: [{ - text: translate('Cancel'), - handler: () => { - this.isStoreFulfilmentTurnedOn = this.fulfillmentStatus - } - }, { - text: translate('Save'), - handler: () => { - this.updateFacility(0); - } - }] - }); - - await alert.present(); }, async setEComStore(event: any) { // not updating the ecomstore when the current value in vuex state and selected value are same diff --git a/src/views/orderLimitPopover.vue b/src/views/orderLimitPopover.vue new file mode 100644 index 00000000..35d6a6a9 --- /dev/null +++ b/src/views/orderLimitPopover.vue @@ -0,0 +1,110 @@ + + + \ No newline at end of file From 4a1b2ab850b9413b544613eea2d80a7d91d60ad8 Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Thu, 24 Aug 2023 16:31:29 +0530 Subject: [PATCH 07/50] Fixed: changed the indentation, removed console, used console.error for online store fulfillment card (#241) --- src/views/Settings.vue | 14 +-- src/views/orderLimitPopover.vue | 177 ++++++++++++++++---------------- 2 files changed, 95 insertions(+), 96 deletions(-) diff --git a/src/views/Settings.vue b/src/views/Settings.vue index 6ad0fc3d..669d0b1f 100644 --- a/src/views/Settings.vue +++ b/src/views/Settings.vue @@ -350,18 +350,18 @@ export default defineComponent({ throw resp.data } } catch(err) { - console.log("Failed to fetch total orders count", err); + console.error("Failed to fetch total orders count", err); } }, updateOrderLimitMode() { this.fulfillmentOrderLimit = this.currentFacilityDetails?.maximumOrderLimit if(this.currentFacilityDetails?.maximumOrderLimit == 0){ - this.orderLimitMode = 'no-capacity' - }else if(this.currentFacilityDetails?.maximumOrderLimit == null || ""){ - this.orderLimitMode = 'unlimited' - }else{ - this.orderLimitMode = 'custom' - } + this.orderLimitMode = 'no-capacity' + }else if(this.currentFacilityDetails?.maximumOrderLimit == null || this.currentFacilityDetails?.maximumOrderLimit == ""){ + this.orderLimitMode = 'unlimited' + }else{ + this.orderLimitMode = 'custom' + } }, logout () { this.store.dispatch('user/logout').then(() => { diff --git a/src/views/orderLimitPopover.vue b/src/views/orderLimitPopover.vue index 35d6a6a9..9c1c95d6 100644 --- a/src/views/orderLimitPopover.vue +++ b/src/views/orderLimitPopover.vue @@ -1,110 +1,109 @@ \ No newline at end of file From 0ee1271ab4c2fb81af4a86507d807b45f7f698b9 Mon Sep 17 00:00:00 2001 From: k2maan Date: Fri, 25 Aug 2023 11:55:55 +0530 Subject: [PATCH 08/50] Removed: unnecessary variable declrataions (#141) --- src/views/Settings.vue | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/views/Settings.vue b/src/views/Settings.vue index 17dad510..e1c79e01 100644 --- a/src/views/Settings.vue +++ b/src/views/Settings.vue @@ -264,8 +264,6 @@ export default defineComponent({ locales: process.env.VUE_APP_LOCALES ? JSON.parse(process.env.VUE_APP_LOCALES) : {"en": "English"}, currentFacilityDetails: {} as any, facilityGroupDetails: {} as any, - outstandingOrdersCount: 0, - inProgressOrdersCount: 0, isStoreFulfilmentTurnedOn: true, isEComInvTurnedOn: true }; From 8e28f5dce36d416b7a1856de20f03b56264fea8a Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Thu, 31 Aug 2023 14:33:28 +0530 Subject: [PATCH 09/50] Fixed: removed merge conflict markers and updated api functions (#241) --- src/locales/en.json | 2 +- src/locales/es.json | 5 +---- src/services/UserService.ts | 5 +++-- ...{orderLimitPopover.vue => OrderLimitPopover.vue} | 4 ++-- src/views/Settings.vue | 13 ++++++------- 5 files changed, 13 insertions(+), 16 deletions(-) rename src/views/{orderLimitPopover.vue => OrderLimitPopover.vue} (94%) diff --git a/src/locales/en.json b/src/locales/en.json index a9e69e6e..466af26e 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -110,7 +110,7 @@ "Mapping name": "Mapping name", "Mismatch": "Mismatch", "No data Found.": "No data Found.", - "No capacity removes 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.": "No capacity removes 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.", + "No capacity removes 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 removes 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. {space}To add a fulfillment capacity to this facility, use the custom option.", "No new file upload. Please try again": "No new file upload. Please try again", "No fulfillment capacity": "No fulfillment capacity", "No reason": "No reason", diff --git a/src/locales/es.json b/src/locales/es.json index da395b7a..be6f6277 100644 --- a/src/locales/es.json +++ b/src/locales/es.json @@ -109,12 +109,9 @@ "Map all fields": "Map all fields", "Mapping name": "Mapping name", "Mismatch": "Inconsistencia", -<<<<<<< HEAD "No": "No", "No Capacity": "No Capacity", - "No capacity removes 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 removes 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.", -======= ->>>>>>> 04f84c131e2f571d53035eb722edea3a19cdef04 + "No capacity removes 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 removes 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. {space}To add a fulfillment capacity to this facility, use the custom option.", "No data Found.": "No data Found.", "No new file upload. Please try again": "No se cargó ningún archivo nuevo. Por favor, inténtalo nuevamente.", "No reason": "Sin motivo", diff --git a/src/services/UserService.ts b/src/services/UserService.ts index d3ba6af5..0ab48a12 100644 --- a/src/services/UserService.ts +++ b/src/services/UserService.ts @@ -37,7 +37,7 @@ const getFacilityDetails = async (payload: any): Promise => { }) } -const getCurrentOrderCount = async (payload: any): Promise => { +const getCurrentOrdersCount = async (payload: any): Promise => { return api({ url: "performFind", method: "get", @@ -294,5 +294,6 @@ export const UserService = { setUserTimeZone, getUserPermissions, updateFacility, - updateFieldMapping + updateFieldMapping, + getCurrentOrdersCount } \ No newline at end of file diff --git a/src/views/orderLimitPopover.vue b/src/views/OrderLimitPopover.vue similarity index 94% rename from src/views/orderLimitPopover.vue rename to src/views/OrderLimitPopover.vue index 9c1c95d6..c0cc0ef4 100644 --- a/src/views/orderLimitPopover.vue +++ b/src/views/OrderLimitPopover.vue @@ -60,7 +60,7 @@ export default defineComponent({ this.showOrderLimitAlert("Custom fulfillment capacity", "", true) } else if (limit === 'no-capacity') { this.setLimit = 0 - this.showOrderLimitAlert("No fulfillment capacity", "No capacity removes 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.", false) + this.showOrderLimitAlert("No fulfillment capacity", "No capacity removes 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.", false) } else if (limit === 'unlimited') { this.setLimit = "" this.showOrderLimitAlert("Unlimited fulfillment capacity", "Unlimited capacity removes the fulfillment capacity limit entirely. To add a fulfillment capacity to this facility, use the custom option.", false) @@ -69,7 +69,7 @@ export default defineComponent({ async showOrderLimitAlert(header: any, message: any, showInput = false) { const alert = await alertController.create({ header: translate(header), - message: translate(message), + message: translate(message, {space: '

'}), inputs: showInput ? [{ name: "setLimit", placeholder: "Order fulfillment capacity", diff --git a/src/views/Settings.vue b/src/views/Settings.vue index 669d0b1f..53eb3024 100644 --- a/src/views/Settings.vue +++ b/src/views/Settings.vue @@ -246,7 +246,7 @@ import logger from '@/logger'; import { Actions, hasPermission } from '@/authorization' import { DateTime } from 'luxon'; import Image from '@/components/Image.vue'; -import orderLimitPopover from '@/views/orderLimitPopover.vue' +import OrderLimitPopover from '@/views/OrderLimitPopover.vue' export default defineComponent({ name: 'Settings', @@ -303,9 +303,9 @@ export default defineComponent({ mounted() { this.appVersion = this.appInfo.branch ? (this.appInfo.branch + "-" + this.appInfo.revision) : this.appInfo.tag; }, - ionViewWillEnter() { - this.getCurrentFacilityDetails() - this.getCurrentOrdersCount() + async ionViewWillEnter() { + await this.getCurrentFacilityDetails() + await this.getCurrentOrdersCount() }, methods: { async getCurrentFacilityDetails() { @@ -337,13 +337,12 @@ export default defineComponent({ async getCurrentOrdersCount() { let resp: any; try { - resp = await UserService.getFacilityDetails({ + resp = await UserService.getCurrentOrdersCount({ "entityName": "FacilityOrderCount", "inputFields": { "facilityId": this.currentFacility.facilityId } }) - if(!hasError(resp) && resp.data.count) { this.currentFacilityDetails.orderCount = resp.data.count } else { @@ -375,7 +374,7 @@ export default defineComponent({ }, async changeOrderLimitPopover(ev: Event) { const popover = await popoverController.create({ - component: orderLimitPopover, + component: OrderLimitPopover, event: ev, translucent: true, showBackdrop: false, From 491f7d4d34c78402d0085c43aaca3982e3830ef4 Mon Sep 17 00:00:00 2001 From: Yash Maheshwari Date: Thu, 31 Aug 2023 16:10:44 +0530 Subject: [PATCH 10/50] Updated: entries for static text in locale file(#141) --- src/locales/en.json | 2 +- src/locales/es.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/locales/en.json b/src/locales/en.json index 2d4951fb..26656182 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -13,7 +13,7 @@ "Are you sure you want to change the time zone to?": "Are you sure you want to change the time zone to?", "Are you sure you want to delete this CSV mapping? This action cannot be undone.": "Are you sure you want to delete this CSV mapping? This action cannot be undone.", "Are you sure you want to update this CSV mapping? This action cannot be undone.": "Are you sure you want to update this CSV mapping? This action cannot be undone.", - "Are you sure you want perform this action?": "Are you sure you want perform this action?", + "Are you sure you want to perform this action?": "Are you sure you want to perform this action?", "Are you sure you want to reject outstanding order(s)?": "Are you sure you want to reject { ordersCount } outstanding order(s)?", "Are you sure you want to reject in progress order(s)?": "Are you sure you want to reject { ordersCount } in progress order(s)?", "Assign Pickers": "Assign Pickers", diff --git a/src/locales/es.json b/src/locales/es.json index b4e7c680..03a8d06c 100644 --- a/src/locales/es.json +++ b/src/locales/es.json @@ -13,7 +13,7 @@ "Are you sure you want to change the time zone to?": "¿Estás seguro/a de que quieres cambiar la zona horaria a?", "Are you sure you want to delete this CSV mapping? This action cannot be undone.": "Are you sure you want to delete this CSV mapping? This action cannot be undone.", "Are you sure you want to update this CSV mapping? This action cannot be undone.": "Are you sure you want to update this CSV mapping? This action cannot be undone.", - "Are you sure you want perform this action?": "¿Estás seguro/a de que quieres realizar esta acción?", + "Are you sure you want to perform this action?": "Are you sure you want to perform this action?", "Are you sure you want to reject outstanding order(s)?": "Are you sure you want to reject { ordersCount } outstanding order(s)?", "Are you sure you want to reject in progress order(s)?": "Are you sure you want to reject { ordersCount } in progress order(s)?", "Assign Pickers": "Asignar Recolectores", From bddbff92dfa5eaa31bc658258608f254d4ae738d Mon Sep 17 00:00:00 2001 From: Yash Maheshwari Date: Thu, 31 Aug 2023 18:38:24 +0530 Subject: [PATCH 11/50] Implemented: support to enable/disable ecom inventory from settings page(#141) --- src/views/Settings.vue | 99 +++++++++++++++++------------------------- 1 file changed, 40 insertions(+), 59 deletions(-) diff --git a/src/views/Settings.vue b/src/views/Settings.vue index e1c79e01..ae10e0f7 100644 --- a/src/views/Settings.vue +++ b/src/views/Settings.vue @@ -121,7 +121,7 @@ {{ $t("Sell online") }} - + @@ -265,7 +265,7 @@ export default defineComponent({ currentFacilityDetails: {} as any, facilityGroupDetails: {} as any, isStoreFulfilmentTurnedOn: true, - isEComInvTurnedOn: true + isEComInvEnabled: false }; }, computed: { @@ -280,15 +280,6 @@ export default defineComponent({ fulfillmentStatus() { // considered that if facility details are not available then also fulfillment will be turned on return this.currentFacilityDetails.maximumOrderLimit != 0 - }, - eComInvStatus() { - // if facilityGroupDetails are there with fromDate (using fromDate as a flag for - // getting data from getFacilityGroupAndMemberDetails) - facility is turned on - return !!(Object.keys(this.facilityGroupDetails).length && this.facilityGroupDetails?.fromDate) - }, - eComInvConfigStatus() { - // if facilityGroupDetails are there with facilityGroupId, configuration is there but turned off - return !!(Object.keys(this.facilityGroupDetails).length && this.facilityGroupDetails?.facilityGroupId) } }, mounted() { @@ -330,6 +321,7 @@ export default defineComponent({ async getEcomInvStatus() { let resp: any; try { + this.isEComInvEnabled = false this.facilityGroupDetails = {} resp = await UserService.getFacilityGroupDetails({ @@ -357,17 +349,17 @@ export default defineComponent({ if (!hasError(resp)) { this.facilityGroupDetails = { ...this.facilityGroupDetails, ...resp.data.docs[0] } + + // When getting data from group member enabling the eCom inventory + this.isEComInvEnabled = true + } else { + throw resp.data } - else throw resp.data } else { throw resp.data } } catch (err) { logger.error('Failed to fetch eCom inventory config', err) - } finally { - // updating it here as facilityGroupDetails is not available in the lifecycle hooks - // and using the computed property in the lifecycle hook is not updating it later - this.isEComInvTurnedOn = !!(Object.keys(this.facilityGroupDetails).length && this.facilityGroupDetails?.fromDate) } }, logout () { @@ -393,6 +385,7 @@ export default defineComponent({ }); this.store.dispatch('order/clearOrders') this.getCurrentFacilityDetails(); + this.getEcomInvStatus(); } }, async changeTimeZone() { @@ -427,10 +420,12 @@ export default defineComponent({ resp = await UserService.updateFacilityToGroup({ "facilityId": this.currentFacility.facilityId, "facilityGroupId": this.facilityGroupDetails.facilityGroupId, - "fromDate": this.facilityGroupDetails.fromDate + "fromDate": this.facilityGroupDetails.fromDate, + "thruDate": DateTime.now().toMillis() }) if (!hasError(resp)) { + this.isEComInvEnabled = false showToast(translate('ECom inventory status updated successfully')) } else { throw resp.data @@ -449,6 +444,7 @@ export default defineComponent({ }) if (!hasError(resp)) { + this.isEComInvEnabled = true showToast(translate('ECom inventory status updated successfully')) } else { throw resp.data @@ -465,10 +461,33 @@ export default defineComponent({ event.detail.checked ? this.turnOnFulfillment() : this.turnOffFulfillment() }, async updateEComInvStatus(event: any) { - // condition to stop alert from re-popping as ionChange is triggered - // because isEComInvStatus is updated - if (event.detail.checked === this.eComInvStatus) return - event.detail.checked ? this.turnOnEComInv() : this.turnOffEComInv() + event.stopImmediatePropagation(); + + // Using `not` as the click event returns the current status of toggle, but on click we want to change the toggle status + const isChecked = !event.target.checked; + const header = isChecked ? 'Turn on eCom inventory for ' : 'Turn off eCom inventory for ' + const message = 'Are you sure you want to perform this action?' + + const alert = await alertController.create({ + header: this.$t(header, { facilityName: this.currentFacility.name }), + message: translate(message), + buttons: [{ + text: translate('Cancel'), + role: '' + }, { + text: translate('Save'), + role: 'success' + }], + }); + + await alert.present(); + + const { role } = await alert.onDidDismiss(); + + if(role) { + isChecked ? await this.addFacilityToGroup() : await this.updateFacilityToGroup() + } + }, async turnOnFulfillment() { const alert = await alertController.create({ @@ -518,44 +537,6 @@ export default defineComponent({ await alert.present(); }, - async turnOnEComInv() { - const alert = await alertController.create({ - header: this.$t('Turn on eCom inventory for ', { facilityName: this.currentFacility.name }), - message: translate('Are you sure you want to perform this action?'), - buttons: [{ - text: translate('Cancel'), - handler: () => { - this.isEComInvTurnedOn = this.eComInvStatus - } - }, { - text: translate('Save'), - handler: async () => { - await this.addFacilityToGroup() - } - }], - }); - - await alert.present(); - }, - async turnOffEComInv() { - const alert = await alertController.create({ - header: this.$t('Turn off eCom inventory for ', { facilityName: this.currentFacility.name }), - message: translate('Are you sure you want to perform this action?'), - buttons: [{ - text: translate('Cancel'), - handler: () => { - this.isEComInvTurnedOn = this.eComInvStatus - } - }, { - text: translate('Save'), - handler: async () => { - await this.updateFacilityToGroup() - } - }], - }); - - await alert.present(); - }, async setEComStore(event: any) { // not updating the ecomstore when the current value in vuex state and selected value are same // or when an empty value is given (on logout) From fd3271fc8c5eba6fc1564b3a18d01fba8be318e1 Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Fri, 1 Sep 2023 11:18:24 +0530 Subject: [PATCH 12/50] Fixed: variable names, translation entries and argument type (#241) --- src/locales/en.json | 9 +++++---- src/locales/es.json | 8 ++++---- src/views/OrderLimitPopover.vue | 21 +++++++++------------ src/views/Settings.vue | 7 +++---- 4 files changed, 21 insertions(+), 24 deletions(-) diff --git a/src/locales/en.json b/src/locales/en.json index 466af26e..04a39d91 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -109,6 +109,8 @@ "Map all fields": "Map all fields", "Mapping name": "Mapping name", "Mismatch": "Mismatch", + "Next day": "Next day", + "New mapping": "New mapping", "No data Found.": "No data Found.", "No capacity removes 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 removes 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. {space}To add a fulfillment capacity to this facility, use the custom option.", "No new file upload. Please try again": "No new file upload. Please try again", @@ -119,6 +121,8 @@ "No results found for . Try searching In Progress or Completed tab instead. If you still can't find what you're looking for, try switching stores.": "No results found for { searchedQuery }. Try searching In Progress or Completed tab instead.{ lineBreak } If you still can't find what you're looking for, try switching stores.", "No time zone found": "No time zone found", "Not in Stock": "Not in Stock", + "No Capacity": "No Capacity", + "No packed shipments to ship for these orders": "No packed shipments to ship for these orders", "order": "order", "of": "of", "Off": "Off", @@ -129,6 +133,7 @@ "Open": "Open", "orders allocated today": "{orderCount} orders allocated today", "orders in fulfillment queue": "{orderCount} orders in fulfillment queue", + "Order fulfillment capacity": "Order fulfillment capacity", "Order fulfillment capacity updated successfully": "Order fulfillment capacity updated successfully", "Ordered": "Ordered", "Order ID": "Order ID", @@ -140,10 +145,6 @@ "Order updated successfully": "Order updated successfully", "orders": "orders", "Out of stock": "Out of stock", - "New mapping": "New mapping", - "Next day": "Next day", - "No Capacity": "No Capacity", - "No packed shipments to ship for these orders": "No packed shipments to ship for these orders", "package": "package", "packages": "packages", "Pack": "Pack", diff --git a/src/locales/es.json b/src/locales/es.json index be6f6277..edd3ff96 100644 --- a/src/locales/es.json +++ b/src/locales/es.json @@ -109,7 +109,8 @@ "Map all fields": "Map all fields", "Mapping name": "Mapping name", "Mismatch": "Inconsistencia", - "No": "No", + "New mapping": "New mapping", + "Next day": "Día siguiente", "No Capacity": "No Capacity", "No capacity removes 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 removes 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. {space}To add a fulfillment capacity to this facility, use the custom option.", "No data Found.": "No data Found.", @@ -121,6 +122,7 @@ "No time zone found": "No se encontró zona horaria", "No fulfillment capacity": "No fulfillment capacity", "Not in Stock": "No en Stock", + "No packed shipments to ship for these orders": "No hay envíos empacados para estos pedidos", "order": "pedido", "orders allocated today": "{orderCount} orders allocated today", "orders in fulfillment queue": "{orderCount} orders in fulfillment queue", @@ -132,6 +134,7 @@ "Online Order Fulfillment": "Online Order Fulfillment", "Open": "Abierto", "Ordered": "Ordenado", + "Order fulfillment capacity": "Order fulfillment capacity", "Order fulfillment capacity updated successfully": "Order fulfillment capacity updated successfully", "Order ID": "ID del Pedido", "Order packed successfully": "Pedido empacado exitosamente", @@ -142,9 +145,6 @@ "Order updated successfully": "Pedido actualizado exitosamente", "orders": "pedidos", "Out of stock": "Agotado", - "New mapping": "New mapping", - "Next day": "Día siguiente", - "No packed shipments to ship for these orders": "No hay envíos empacados para estos pedidos", "package": "paquete", "packages": "paquetes", "Pack": "Empacar", diff --git a/src/views/OrderLimitPopover.vue b/src/views/OrderLimitPopover.vue index c0cc0ef4..a5877214 100644 --- a/src/views/OrderLimitPopover.vue +++ b/src/views/OrderLimitPopover.vue @@ -34,7 +34,7 @@ import { lockClosedOutline, lockOpenOutline } from 'ionicons/icons' import { translate } from '@/i18n'; import { showToast } from '@/utils'; export default defineComponent({ - name: "orderLimitPopver", + name: "OrderLimitPopver", components: { IonContent, IonIcon, @@ -55,24 +55,24 @@ export default defineComponent({ } }, methods: { - async updateOrderLimit(limit: any) { - if (limit === 'custom') { + async updateOrderLimit(capacity: string) { + if (capacity === 'custom') { this.showOrderLimitAlert("Custom fulfillment capacity", "", true) - } else if (limit === 'no-capacity') { + } else if (capacity === 'no-capacity') { this.setLimit = 0 this.showOrderLimitAlert("No fulfillment capacity", "No capacity removes 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.", false) - } else if (limit === 'unlimited') { + } else if (capacity === 'unlimited') { this.setLimit = "" this.showOrderLimitAlert("Unlimited fulfillment capacity", "Unlimited capacity removes the fulfillment capacity limit entirely. To add a fulfillment capacity to this facility, use the custom option.", false) } }, - async showOrderLimitAlert(header: any, message: any, showInput = false) { + async showOrderLimitAlert(header: any, message: any, showInput: boolean) { const alert = await alertController.create({ header: translate(header), message: translate(message, {space: '

'}), inputs: showInput ? [{ name: "setLimit", - placeholder: "Order fulfillment capacity", + placeholder: translate("Order fulfillment capacity"), type: "number", min: 0 }] : [], @@ -87,7 +87,7 @@ export default defineComponent({ showToast(translate('Provide a value greater than 0')) return; } - this.onDismiss(data.setLimit) + popoverController.dismiss(data.setLimit) } }] : [{ text: translate('Cancel'), @@ -95,14 +95,11 @@ export default defineComponent({ }, { text: translate('Apply'), handler: () => { - this.onDismiss(this.setLimit) + popoverController.dismiss(this.setLimit) } }] }) await alert.present() - }, - onDismiss(setLimit: any) { - popoverController.dismiss(setLimit); } } }); diff --git a/src/views/Settings.vue b/src/views/Settings.vue index 53eb3024..0affb177 100644 --- a/src/views/Settings.vue +++ b/src/views/Settings.vue @@ -382,11 +382,10 @@ export default defineComponent({ }); popover.present(); - const result = await popover.onDidDismiss(); - + const result = await popover.onDidDismiss(); + // Note: here result.data returns 0 in some cases that's why it is compared with 'undefined'. if(result.data != undefined && result.data !== this.fulfillmentOrderLimit){ - const resultData = result.data; - await this.updateFacility(resultData) + await this.updateFacility(result.data) this.updateOrderLimitMode() } }, From d10352e88021b7a52726b2183854e9b1eb48e348 Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Fri, 1 Sep 2023 15:50:12 +0530 Subject: [PATCH 13/50] Improved: changed the variable and function name, and fixed some issue (#241) --- src/views/OrderLimitPopover.vue | 14 ++++++------- src/views/Settings.vue | 35 +++++++++++++++++---------------- 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/src/views/OrderLimitPopover.vue b/src/views/OrderLimitPopover.vue index a5877214..67d050da 100644 --- a/src/views/OrderLimitPopover.vue +++ b/src/views/OrderLimitPopover.vue @@ -4,15 +4,15 @@ {{ $t("Fulfillment Capacity") }} - + {{ $t("Unlimited Capacity") }} - + {{ $t("No Capacity") }} - + {{ $t("Custom") }} @@ -55,13 +55,13 @@ export default defineComponent({ } }, methods: { - async updateOrderLimit(capacity: string) { - if (capacity === 'custom') { + async updateOrderLimitType(orderLimitType: string) { + if (orderLimitType === 'custom') { this.showOrderLimitAlert("Custom fulfillment capacity", "", true) - } else if (capacity === 'no-capacity') { + } else if (orderLimitType === 'no-capacity') { this.setLimit = 0 this.showOrderLimitAlert("No fulfillment capacity", "No capacity removes 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.", false) - } else if (capacity === 'unlimited') { + } else if (orderLimitType === 'unlimited') { this.setLimit = "" this.showOrderLimitAlert("Unlimited fulfillment capacity", "Unlimited capacity removes the fulfillment capacity limit entirely. To add a fulfillment capacity to this facility, use the custom option.", false) } diff --git a/src/views/Settings.vue b/src/views/Settings.vue index 0affb177..7694b524 100644 --- a/src/views/Settings.vue +++ b/src/views/Settings.vue @@ -106,16 +106,16 @@ {{ $t("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.") }} - + {{currentFacilityDetails?.orderCount}} {{currentFacilityDetails?.maximumOrderLimit}} - + {{ $t("orders allocated today", {orderCount: currentFacilityDetails?.orderCount}) }} {{ $t("Unlimited") }} - + {{ $t("orders in fulfillment queue", {orderCount: currentFacilityDetails?.orderCount}) }} {{ fulfillmentOrderLimit }} @@ -282,7 +282,7 @@ export default defineComponent({ appVersion: "", locales: process.env.VUE_APP_LOCALES ? JSON.parse(process.env.VUE_APP_LOCALES) : {"en": "English"}, currentFacilityDetails: {} as any, - orderLimitMode: 'custom', + orderLimitType: 'custom', fulfillmentOrderLimit: 0 }; }, @@ -306,6 +306,7 @@ export default defineComponent({ async ionViewWillEnter() { await this.getCurrentFacilityDetails() await this.getCurrentOrdersCount() + this.updateOrderLimitType() }, methods: { async getCurrentFacilityDetails() { @@ -330,8 +331,6 @@ export default defineComponent({ } } catch(err) { logger.error('Failed to fetch current facility details', err) - } finally { - this.updateOrderLimitMode() } }, async getCurrentOrdersCount() { @@ -343,7 +342,7 @@ export default defineComponent({ "facilityId": this.currentFacility.facilityId } }) - if(!hasError(resp) && resp.data.count) { + if (!hasError(resp) && resp.data.count) { this.currentFacilityDetails.orderCount = resp.data.count } else { throw resp.data @@ -352,14 +351,16 @@ export default defineComponent({ console.error("Failed to fetch total orders count", err); } }, - updateOrderLimitMode() { + updateOrderLimitType() { this.fulfillmentOrderLimit = this.currentFacilityDetails?.maximumOrderLimit - if(this.currentFacilityDetails?.maximumOrderLimit == 0){ - this.orderLimitMode = 'no-capacity' - }else if(this.currentFacilityDetails?.maximumOrderLimit == null || this.currentFacilityDetails?.maximumOrderLimit == ""){ - this.orderLimitMode = 'unlimited' - }else{ - this.orderLimitMode = 'custom' + if (this.currentFacilityDetails?.maximumOrderLimit === undefined) { + this.orderLimitType = 'unlimited' + } else if (this.currentFacilityDetails?.maximumOrderLimit === 0) { + this.orderLimitType = 'no-capacity' + } else if (this.currentFacilityDetails?.maximumOrderLimit === null || this.currentFacilityDetails?.maximumOrderLimit === "") { + this.orderLimitType = 'unlimited' + } else { + this.orderLimitType = 'custom' } }, logout () { @@ -386,7 +387,7 @@ export default defineComponent({ // Note: here result.data returns 0 in some cases that's why it is compared with 'undefined'. if(result.data != undefined && result.data !== this.fulfillmentOrderLimit){ await this.updateFacility(result.data) - this.updateOrderLimitMode() + this.updateOrderLimitType() } }, async setFacility (event: any) { @@ -410,13 +411,13 @@ export default defineComponent({ }); return timeZoneModal.present(); }, - async updateFacility(maximumOrderLimit: any) { + async updateFacility(maximumOrderLimit: number | string) { let resp; try { resp = await UserService.updateFacility({ "facilityId": this.currentFacility.facilityId, - maximumOrderLimit: maximumOrderLimit + maximumOrderLimit }) if(!hasError(resp)) { From 828e4058f9c5fe264ea6e1ec182a2265c56e901c Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Fri, 1 Sep 2023 16:10:14 +0530 Subject: [PATCH 14/50] Improved: condition for api call fail check (#241) --- src/views/Settings.vue | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/views/Settings.vue b/src/views/Settings.vue index 7694b524..11859eec 100644 --- a/src/views/Settings.vue +++ b/src/views/Settings.vue @@ -353,11 +353,9 @@ export default defineComponent({ }, updateOrderLimitType() { this.fulfillmentOrderLimit = this.currentFacilityDetails?.maximumOrderLimit - if (this.currentFacilityDetails?.maximumOrderLimit === undefined) { - this.orderLimitType = 'unlimited' - } else if (this.currentFacilityDetails?.maximumOrderLimit === 0) { + if (this.currentFacilityDetails?.maximumOrderLimit === 0) { this.orderLimitType = 'no-capacity' - } else if (this.currentFacilityDetails?.maximumOrderLimit === null || this.currentFacilityDetails?.maximumOrderLimit === "") { + } else if (this.currentFacilityDetails?.maximumOrderLimit === undefined || this.currentFacilityDetails?.maximumOrderLimit === null || this.currentFacilityDetails?.maximumOrderLimit === "") { this.orderLimitType = 'unlimited' } else { this.orderLimitType = 'custom' From cface96648a3a72140eff10f13ff2239d4b932b8 Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Fri, 1 Sep 2023 16:18:52 +0530 Subject: [PATCH 15/50] Improved: unused function updateFulfillmentStatus removed (#241) --- src/views/Settings.vue | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/views/Settings.vue b/src/views/Settings.vue index 11859eec..d3c7293e 100644 --- a/src/views/Settings.vue +++ b/src/views/Settings.vue @@ -429,11 +429,6 @@ export default defineComponent({ logger.error('Failed to update facility', err) } }, - async updateFulfillmentStatus(event: any) { - // condition to stop alert from re-popping as ionChange is triggered - // because isStoreFulfilmentTurnedOn is updated - if (event.detail.checked === this.fulfillmentStatus) return - }, async setEComStore(event: any) { // not updating the ecomstore when the current value in vuex state and selected value are same // or when an empty value is given (on logout) From 73a131ffe3fe985e3025f55378593366ad48ac95 Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Mon, 4 Sep 2023 11:49:53 +0530 Subject: [PATCH 16/50] Fixed: code for settings page and function names (#241) --- .../OrderLimitPopover.vue | 0 src/views/Settings.vue | 22 +++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) rename src/{views => components}/OrderLimitPopover.vue (100%) diff --git a/src/views/OrderLimitPopover.vue b/src/components/OrderLimitPopover.vue similarity index 100% rename from src/views/OrderLimitPopover.vue rename to src/components/OrderLimitPopover.vue diff --git a/src/views/Settings.vue b/src/views/Settings.vue index d3c7293e..3af8ba1e 100644 --- a/src/views/Settings.vue +++ b/src/views/Settings.vue @@ -246,7 +246,7 @@ import logger from '@/logger'; import { Actions, hasPermission } from '@/authorization' import { DateTime } from 'luxon'; import Image from '@/components/Image.vue'; -import OrderLimitPopover from '@/views/OrderLimitPopover.vue' +import OrderLimitPopover from '@/components/OrderLimitPopover.vue' export default defineComponent({ name: 'Settings', @@ -282,8 +282,8 @@ export default defineComponent({ appVersion: "", locales: process.env.VUE_APP_LOCALES ? JSON.parse(process.env.VUE_APP_LOCALES) : {"en": "English"}, currentFacilityDetails: {} as any, - orderLimitType: 'custom', - fulfillmentOrderLimit: 0 + orderLimitType: 'unlimited', + fulfillmentOrderLimit: "" as number | string }; }, computed: { @@ -305,15 +305,14 @@ export default defineComponent({ }, async ionViewWillEnter() { await this.getCurrentFacilityDetails() - await this.getCurrentOrdersCount() - this.updateOrderLimitType() + await this.getFacilityOrderCount() }, methods: { async getCurrentFacilityDetails() { let resp: any; try { this.currentFacilityDetails = {} - + resp = await UserService.getFacilityDetails({ "entityName": "Facility", "inputFields": { @@ -322,7 +321,7 @@ export default defineComponent({ "viewSize": 1, "fieldList": ["maximumOrderLimit", "facilityId"] }) - + if(!hasError(resp) && resp.data.count) { // using index 0 as we will only get a single record this.currentFacilityDetails = resp.data.docs[0] @@ -333,7 +332,7 @@ export default defineComponent({ logger.error('Failed to fetch current facility details', err) } }, - async getCurrentOrdersCount() { + async getFacilityOrderCount() { let resp: any; try { resp = await UserService.getCurrentOrdersCount({ @@ -344,18 +343,19 @@ export default defineComponent({ }) if (!hasError(resp) && resp.data.count) { this.currentFacilityDetails.orderCount = resp.data.count + this.updateOrderLimitType() } else { throw resp.data } } catch(err) { - console.error("Failed to fetch total orders count", err); + logger.error("Failed to fetch total orders count", err); } }, updateOrderLimitType() { this.fulfillmentOrderLimit = this.currentFacilityDetails?.maximumOrderLimit - if (this.currentFacilityDetails?.maximumOrderLimit === 0) { + if (this.fulfillmentOrderLimit === 0) { this.orderLimitType = 'no-capacity' - } else if (this.currentFacilityDetails?.maximumOrderLimit === undefined || this.currentFacilityDetails?.maximumOrderLimit === null || this.currentFacilityDetails?.maximumOrderLimit === "") { + } else if (this.fulfillmentOrderLimit === undefined || this.fulfillmentOrderLimit === null || this.fulfillmentOrderLimit === "") { this.orderLimitType = 'unlimited' } else { this.orderLimitType = 'custom' From d69cf34472a04429b528618ba03d8cae65c7691e Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Tue, 5 Sep 2023 12:22:49 +0530 Subject: [PATCH 17/50] Improved: code for orderCount api call, added a check for getting count of only today (#241) --- src/views/Settings.vue | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/src/views/Settings.vue b/src/views/Settings.vue index 3af8ba1e..adb81751 100644 --- a/src/views/Settings.vue +++ b/src/views/Settings.vue @@ -294,25 +294,19 @@ export default defineComponent({ currentEComStore: 'user/getCurrentEComStore', userPreference: 'user/getUserPreference', locale: 'user/getLocale' - }), - fulfillmentStatus() { - // considered that if facility details are not available then also fulfillment will be turned on - return this.currentFacilityDetails.maximumOrderLimit != 0 - } + }) }, mounted() { this.appVersion = this.appInfo.branch ? (this.appInfo.branch + "-" + this.appInfo.revision) : this.appInfo.tag; }, async ionViewWillEnter() { - await this.getCurrentFacilityDetails() - await this.getFacilityOrderCount() + this.getCurrentFacilityDetails() + this.getFacilityOrderCount() }, methods: { async getCurrentFacilityDetails() { let resp: any; - try { - this.currentFacilityDetails = {} - + try { resp = await UserService.getFacilityDetails({ "entityName": "Facility", "inputFields": { @@ -324,7 +318,11 @@ export default defineComponent({ if(!hasError(resp) && resp.data.count) { // using index 0 as we will only get a single record - this.currentFacilityDetails = resp.data.docs[0] + this.currentFacilityDetails = { + ...this.currentFacilityDetails, + ...resp.data.docs[0] + } + this.updateOrderLimitType() } else { throw resp.data } @@ -338,13 +336,17 @@ export default defineComponent({ resp = await UserService.getCurrentOrdersCount({ "entityName": "FacilityOrderCount", "inputFields": { - "facilityId": this.currentFacility.facilityId - } + "facilityId": this.currentFacility.facilityId, + "entryDate": DateTime.now().toMillis(), + }, + "viewSize": 1, + "fieldList": ["entryDate", "lastOrderCount"], }) - if (!hasError(resp) && resp.data.count) { - this.currentFacilityDetails.orderCount = resp.data.count - this.updateOrderLimitType() + if (!hasError(resp) && resp.data.count) { + // using index 0 as we will only get a single record + this.currentFacilityDetails.orderCount = resp.data.docs[0].lastOrderCount } else { + this.currentFacilityDetails.orderCount = 0 throw resp.data } } catch(err) { From 00868251d92c224846ee0535f9c673bd1ce878c1 Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Thu, 7 Sep 2023 12:18:15 +0530 Subject: [PATCH 18/50] Improved: code for calling api's parallely and removed cache from performfind.(#241) --- src/services/UserService.ts | 3 +-- src/views/Settings.vue | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/services/UserService.ts b/src/services/UserService.ts index 0ab48a12..1ecc5bb7 100644 --- a/src/services/UserService.ts +++ b/src/services/UserService.ts @@ -41,8 +41,7 @@ const getCurrentOrdersCount = async (payload: any): Promise => { return api({ url: "performFind", method: "get", - params: payload, - cached: true + params: payload }) } diff --git a/src/views/Settings.vue b/src/views/Settings.vue index adb81751..d78c95ed 100644 --- a/src/views/Settings.vue +++ b/src/views/Settings.vue @@ -300,8 +300,7 @@ export default defineComponent({ this.appVersion = this.appInfo.branch ? (this.appInfo.branch + "-" + this.appInfo.revision) : this.appInfo.tag; }, async ionViewWillEnter() { - this.getCurrentFacilityDetails() - this.getFacilityOrderCount() + Promise.all([this.getCurrentFacilityDetails(), this.getFacilityOrderCount()]); }, methods: { async getCurrentFacilityDetails() { From 5fcd2646c35e4746154e298f4b16c723fe3af698 Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Mon, 11 Sep 2023 11:51:52 +0530 Subject: [PATCH 19/50] Improved: code for store order limit (#241) --- src/components/OrderLimitPopover.vue | 16 ++++++++++++---- src/services/UserService.ts | 4 ++-- src/views/Settings.vue | 10 +++++----- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/components/OrderLimitPopover.vue b/src/components/OrderLimitPopover.vue index 67d050da..17d3575f 100644 --- a/src/components/OrderLimitPopover.vue +++ b/src/components/OrderLimitPopover.vue @@ -34,7 +34,7 @@ import { lockClosedOutline, lockOpenOutline } from 'ionicons/icons' import { translate } from '@/i18n'; import { showToast } from '@/utils'; export default defineComponent({ - name: "OrderLimitPopver", + name: "OrderLimitPopover", components: { IonContent, IonIcon, @@ -56,15 +56,23 @@ export default defineComponent({ }, methods: { async updateOrderLimitType(orderLimitType: string) { + let header = "Unlimited fulfillment capacity" + let message = "Unlimited capacity removes the fulfillment capacity limit entirely. To add a fulfillment capacity to this facility, use the custom option." + let showInput = false + if (orderLimitType === 'custom') { - this.showOrderLimitAlert("Custom fulfillment capacity", "", true) + header = "Custom fulfillment capacity" + message = "" + showInput = true } else if (orderLimitType === 'no-capacity') { this.setLimit = 0 - this.showOrderLimitAlert("No fulfillment capacity", "No capacity removes 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.", false) + header = "No fulfillment capacity" + message = "No capacity removes 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." } else if (orderLimitType === 'unlimited') { this.setLimit = "" - this.showOrderLimitAlert("Unlimited fulfillment capacity", "Unlimited capacity removes the fulfillment capacity limit entirely. To add a fulfillment capacity to this facility, use the custom option.", false) } + + this.showOrderLimitAlert(header, message, showInput) }, async showOrderLimitAlert(header: any, message: any, showInput: boolean) { const alert = await alertController.create({ diff --git a/src/services/UserService.ts b/src/services/UserService.ts index 1ecc5bb7..d204a7b2 100644 --- a/src/services/UserService.ts +++ b/src/services/UserService.ts @@ -37,7 +37,7 @@ const getFacilityDetails = async (payload: any): Promise => { }) } -const getCurrentOrdersCount = async (payload: any): Promise => { +const getFacilityOrderCount = async (payload: any): Promise => { return api({ url: "performFind", method: "get", @@ -284,6 +284,7 @@ export const UserService = { getAvailableTimeZones, getEComStores, getFacilityDetails, + getFacilityOrderCount, getFieldMappings, getUserProfile, getPreferredStore, @@ -294,5 +295,4 @@ export const UserService = { getUserPermissions, updateFacility, updateFieldMapping, - getCurrentOrdersCount } \ No newline at end of file diff --git a/src/views/Settings.vue b/src/views/Settings.vue index d78c95ed..0fafde10 100644 --- a/src/views/Settings.vue +++ b/src/views/Settings.vue @@ -332,7 +332,7 @@ export default defineComponent({ async getFacilityOrderCount() { let resp: any; try { - resp = await UserService.getCurrentOrdersCount({ + resp = await UserService.getFacilityOrderCount({ "entityName": "FacilityOrderCount", "inputFields": { "facilityId": this.currentFacility.facilityId, @@ -349,6 +349,7 @@ export default defineComponent({ throw resp.data } } catch(err) { + this.currentFacilityDetails.orderCount = 0 logger.error("Failed to fetch total orders count", err); } }, @@ -356,10 +357,10 @@ export default defineComponent({ this.fulfillmentOrderLimit = this.currentFacilityDetails?.maximumOrderLimit if (this.fulfillmentOrderLimit === 0) { this.orderLimitType = 'no-capacity' - } else if (this.fulfillmentOrderLimit === undefined || this.fulfillmentOrderLimit === null || this.fulfillmentOrderLimit === "") { - this.orderLimitType = 'unlimited' - } else { + } else if (this.fulfillmentOrderLimit) { this.orderLimitType = 'custom' + } else { + this.orderLimitType = 'unlimited' } }, logout () { @@ -376,7 +377,6 @@ export default defineComponent({ const popover = await popoverController.create({ component: OrderLimitPopover, event: ev, - translucent: true, showBackdrop: false, componentProps: {fulfillmentOrderLimit: this.fulfillmentOrderLimit} }); From 8eb82c688f40cbab20ebfce7de01eef93f63980c Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Mon, 11 Sep 2023 14:54:19 +0530 Subject: [PATCH 20/50] Improved: code for popover header and translation (#241) --- src/components/OrderLimitPopover.vue | 12 ++++++------ src/locales/en.json | 2 +- src/locales/es.json | 2 +- src/views/Settings.vue | 1 - 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/components/OrderLimitPopover.vue b/src/components/OrderLimitPopover.vue index 17d3575f..88bd8bb3 100644 --- a/src/components/OrderLimitPopover.vue +++ b/src/components/OrderLimitPopover.vue @@ -1,9 +1,9 @@