From 3204b027661f06708ade5567e8247d8a773776bc Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Thu, 24 Aug 2023 10:22:35 +0530 Subject: [PATCH 01/15] 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 02/15] 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 8e28f5dce36d416b7a1856de20f03b56264fea8a Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Thu, 31 Aug 2023 14:33:28 +0530 Subject: [PATCH 03/15] 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 fd3271fc8c5eba6fc1564b3a18d01fba8be318e1 Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Fri, 1 Sep 2023 11:18:24 +0530 Subject: [PATCH 04/15] 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 05/15] 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 06/15] 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 07/15] 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 08/15] 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 09/15] 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 10/15] 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 11/15] 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 12/15] 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 @@