Skip to content

Commit

Permalink
Merge branch 'main' into hotwax#199
Browse files Browse the repository at this point in the history
  • Loading branch information
ymaheshwari1 committed Aug 9, 2024
2 parents a701c89 + 097f9d8 commit b7249fb
Show file tree
Hide file tree
Showing 32 changed files with 1,635 additions and 388 deletions.
7 changes: 4 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ VUE_APP_CACHE_MAX_AGE=3600
VUE_APP_VIEW_SIZE=10
VUE_APP_PERMISSION_ID=
VUE_APP_DEFAULT_LOG_LEVEL="error"
VUE_APP_RULE_ENUMS={"QUEUE":{"id":"OIP_QUEUE","code":"facilityId"},"SHIPPING_METHOD":{"id":"OIP_SHIP_METH_TYPE","code":"shipmentMethodTypeId"},"PRIORITY":{"id":"OIP_PRIORITY","code":"priority"},"PROMISE_DATE":{"id":"OIP_PROMISE_DATE","code":"promiseDaysCutoff"},"SALES_CHANNEL":{"id":"OIP_SALES_CHANNEL","code":"salesChannelEnumId"},"SHIP_BY":{"id":"OSP_SHIP_BY","code":"shipBeforeDate"},"SHIP_AFTER":{"id":"OSP_SHIP_AFTER","code":"shipAfterDate"},"ORDER_DATE":{"id":"OSP_ORDER_DATE","code":"orderDate"},"SHIPPING_METHOD_SORT":{"id":"OSP_SHIP_METH","code":"deliveryDays"}}
VUE_APP_RULE_FILTER_ENUMS={"FACILITY_GROUP":{"id":"IIP_FACILITY_GROUP","code":"facilityGroupId"},"PROXIMITY":{"id":"IIP_PROXIMITY","code":"distance"},"BRK_SAFETY_STOCK":{"id":"IIP_BRK_SFTY_STOCK","code":"brokeringSafetyStock"},"MEASUREMENT_SYSTEM":{"id":"IIP_MSMNT_SYSTEM","code":"measurementSystem"}}
VUE_APP_RULE_ENUMS={"QUEUE":{"id":"OIP_QUEUE","code":"facilityId"},"SHIPPING_METHOD":{"id":"OIP_SHIP_METH_TYPE","code":"shipmentMethodTypeId"},"PRIORITY":{"id":"OIP_PRIORITY","code":"priority"},"PROMISE_DATE":{"id":"OIP_PROMISE_DATE","code":"promiseDaysCutoff"},"SALES_CHANNEL":{"id":"OIP_SALES_CHANNEL","code":"salesChannelEnumId"},"ORIGIN_FACILITY_GROUP":{"id":"OIP_ORIGIN_FAC_GRP","code":"originFacilityGroupId"},"SHIP_BY":{"id":"OSP_SHIP_BY","code":"shipBeforeDate"},"SHIP_AFTER":{"id":"OSP_SHIP_AFTER","code":"shipAfterDate"},"ORDER_DATE":{"id":"OSP_ORDER_DATE","code":"orderDate"},"SHIPPING_METHOD_SORT":{"id":"OSP_SHIP_METH","code":"deliveryDays"},"SORT_PRIORITY":{"id":"OSP_PRIORITY","code":"priority"}}
VUE_APP_RULE_FILTER_ENUMS={"FACILITY_GROUP":{"id":"IIP_FACILITY_GROUP","code":"facilityGroupId"},"PROXIMITY":{"id":"IIP_PROXIMITY","code":"distance"},"BRK_SAFETY_STOCK":{"id":"IIP_BRK_SFTY_STOCK","code":"brokeringSafetyStock"},"MEASUREMENT_SYSTEM":{"id":"IIP_MSMNT_SYSTEM","code":"measurementSystem"},"SPLIT_ITEM_GROUP":{"id":"IIP_SPLIT_ITEM_GROUP","code":"splitOrderItemGroup"}}
VUE_APP_RULE_SORT_ENUMS={"PROXIMITY":{"id":"ISP_PROXIMITY","code":"distance"},"INV_BALANCE":{"id":"ISP_INV_BAL","code":"inventoryForAllocation"},"CUSTOMER_SEQ":{"id":"ISP_CUST_SEQ","code":"facilitySequence"}}
VUE_APP_RULE_ACTION_ENUMS={"RM_AUTO_CANCEL_DATE":{"id":"ORA_RM_CANCEL_DATE","code":"RM_AUTO_CANCEL_DATE"},"AUTO_CANCEL_DAYS":{"id":"ORA_AUTO_CANCEL_DAYS","code":"ADD_AUTO_CANCEL_DATE"},"NEXT_RULE":{"id":"ORA_NEXT_RULE","code":"NEXT_RULE"},"MOVE_TO_QUEUE":{"id":"ORA_MV_TO_QUEUE","code":"MOVE_TO_QUEUE"}}
VUE_APP_CRON_EXPRESSIONS={"Every 5 minutes":"0 */5 * ? * *","Every 15 minutes":"0 */15 * ? * *","Every 30 minutes":"0 */30 * ? * *","Hourly":"0 0 * ? * *","Every six hours":"0 0 */6 ? * *","Every day at midnight":"0 0 0 * * ?"}
VUE_APP_CRON_EXPRESSIONS={"Every 5 minutes":"0 */5 * ? * *","Every 15 minutes":"0 */15 * ? * *","Every 15 minutes(8am - 2pm)":"0 */15 8-14 ? * *","Every 30 minutes":"0 */30 * ? * *","Every 30 minutes(8am - 2pm)":"0 */30 8-14 ? * *","Hourly":"0 0 * ? * *","Every six hours":"0 0 */6 ? * *","Every day at midnight":"0 0 0 * * ?"}
VUE_APP_LOGIN_URL="https://launchpad.hotwax.io/login"
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
### Related Issues
<!-- Put related issue number which this PR is closing. For example #123 -->

Closes #
#

### Short Description and Why It's Useful
<!-- Describe in a few words what is this Pull Request changing and why it's useful -->
Expand Down
1,243 changes: 1,147 additions & 96 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "order-routing-rules",
"version": "1.1.0",
"version": "1.4.0",
"private": true,
"description": "An Ionic project",
"scripts": {
Expand All @@ -16,6 +16,8 @@
"@capacitor/core": "^2.4.7",
"@hotwax/app-version-info": "^1.0.0",
"@hotwax/apps-theme": "^1.2.6",
"@hotwax/dxp-components": "^1.14.0",
"@hotwax/oms-api": "^1.14.0",
"@ionic/core": "^7.6.0",
"@ionic/vue": "^7.6.0",
"@ionic/vue-router": "^7.6.0",
Expand Down
Binary file modified public/assets/icon/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 22 additions & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,28 @@ import emitter from "@/event-bus"
import { Settings } from 'luxon'
import store from "./store";
import { translate } from "@/i18n"
import { initialise, resetConfig } from '@/adapter'
const loader = ref(null) as any
const userProfile = computed(() => store.getters["user/getUserProfile"])
const userToken = computed(() => store.getters["user/getUserToken"])
const instanceUrl = computed(() => store.getters["user/getInstanceUrl"])
const loader = ref(null) as any
const maxAge = process.env.VUE_APP_CACHE_MAX_AGE ? parseInt(process.env.VUE_APP_CACHE_MAX_AGE) : 0
initialise({
token: userToken.value,
instanceUrl: instanceUrl.value,
cacheMaxAge: maxAge,
events: {
responseError: () => {
setTimeout(() => dismissLoader(), 100);
},
queueTask: (payload: any) => {
emitter.emit("queueTask", payload);
}
}
})
async function presentLoader(options = { message: "Click the backdrop to dismiss.", backdropDismiss: true }) {
// When having a custom message remove already existing loader, if not removed it takes into account the already existing loader
Expand Down Expand Up @@ -56,5 +75,7 @@ onMounted(async () => {
onUnmounted(() => {
emitter.off("presentLoader", presentLoader);
emitter.off("dismissLoader", dismissLoader);
resetConfig()
})
</script>
15 changes: 15 additions & 0 deletions src/adapter/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { api, client, getConfig, getProductIdentificationPref, getUserFacilities, initialise, logout, resetConfig, setProductIdentificationPref, updateInstanceUrl, updateToken } from '@hotwax/oms-api'

export {
api,
client,
getConfig,
getProductIdentificationPref,
getUserFacilities,
initialise,
logout,
resetConfig,
setProductIdentificationPref,
updateInstanceUrl,
updateToken
}
4 changes: 3 additions & 1 deletion src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ axios.interceptors.response.use(function (response) {
const { status } = error.response;
if (status === StatusCodes.UNAUTHORIZED) {
store.dispatch("user/logout");
router.push("/login")
const redirectUrl = window.location.origin + '/login';
// Explicitly passing isLoggedOut as in case of maarg apps we need to call the logout api in launchpad
window.location.href = `${process.env.VUE_APP_LOGIN_URL}?redirectUrl=${redirectUrl}&isLoggedOut=true`;
}
}
// Any status codes that falls outside the range of 2xx cause this function to trigger
Expand Down
9 changes: 6 additions & 3 deletions src/components/AddInventoryFilterOptionsModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
</ion-toolbar>
</ion-header>
<ion-content>
<ion-list>
<div v-if="!enumerations.length" class="empty-state">
<p>{{ translate(`Failed to fetch ${props.label?.toLowerCase()} options`) }}</p>
</div>
<ion-list v-else>
<ion-item v-for="condition in enumerations" :key="condition.enumId">
<ion-checkbox :checked="isConditionOptionSelected(condition.enumCode)" @ionChange="addConditionOption(condition)">{{ condition.description || condition.enumCode }}</ion-checkbox>
</ion-item>
Expand Down Expand Up @@ -60,13 +63,13 @@ let inventoryRuleConditions = ref({}) as any
let enumerations = ref([]) as any
let areFiltersUpdated = ref(false)
const hiddenOptions = ["IIP_MSMNT_SYSTEM"]
const hiddenOptions = ["IIP_MSMNT_SYSTEM", "IIP_SPLIT_ITEM_GROUP"]
// managing this object, as we have some filters for which we need to have its associated filter, like in this case when we have PROXIMITY we also need to add MEASUREMENT_SYSTEM(this is not available on UI for selection and included in hiddenOptions)
const associatedOptions = { IIP_PROXIMITY: { enum: "IIP_MSMNT_SYSTEM", defaultValue: "IMPERIAL" }} as any
onMounted(() => {
inventoryRuleConditions.value = props.ruleConditions ? JSON.parse(JSON.stringify(props.ruleConditions)) : {}
enumerations.value = Object.values(enums.value[props.parentEnumId]).filter((enumeration: any) => !hiddenOptions.includes(enumeration.enumId))
enumerations.value = enums.value[props.parentEnumId] ? Object.values(enums.value[props.parentEnumId]).filter((enumeration: any) => !hiddenOptions.includes(enumeration.enumId)) : []
})
function checkFilters() {
Expand Down
14 changes: 10 additions & 4 deletions src/components/AddOrderRouteFilterOptions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,16 @@
</ion-toolbar>
</ion-header>
<ion-content>
<ion-list>
<ion-item v-for="sort in Object.values(enums[props.parentEnumId] ? enums[props.parentEnumId] : {})" :key="sort.enumId">
<ion-checkbox :checked="isSortOptionSelected(sort.enumCode)" @ionChange="addSortOption(sort)">{{ sort.description || sort.enumCode }}</ion-checkbox>
</ion-item>
<div v-if="!enums[props.parentEnumId]" class="empty-state">
<p>{{ translate(`Failed to fetch ${$props.label?.toLowerCase()} options`) }}</p>
</div>
<ion-list v-else>
<!-- Added this div as we need to hide ProductCategory option from filters, need to remove this once we add support for ProductCategory filter-->
<div v-for="sort in Object.values(enums[props.parentEnumId])" :key="sort.enumId">
<ion-item v-if="sort.enumId !== 'OIP_PROD_CATEGORY'">
<ion-checkbox :checked="isSortOptionSelected(sort.enumCode)" @ionChange="addSortOption(sort)">{{ sort.description || sort.enumCode }}</ion-checkbox>
</ion-item>
</div>
</ion-list>

<ion-fab vertical="bottom" horizontal="end" slot="fixed">
Expand Down
2 changes: 1 addition & 1 deletion src/components/ArchivedRoutingModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,6 @@ async function updateOrderRouting(routing: Route, fieldToUpdate: string, value:
props.saveRoutings([{
...routing,
[fieldToUpdate]: value
}])
}, ...routings.value])
}
</script>
8 changes: 7 additions & 1 deletion src/components/PromiseFilterPopover.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,13 @@ async function updatePromiseDate(header = '', isPastDuration = false) {
placeholder: translate("duration"),
min: 0,
type: "number",
value: props.value?.replace("-", "")
value: props.value > 0 && !isPastDuration ? props.value : props.value < 0 && isPastDuration ? props.value?.replace("-", "") : '', // Prefill the value only when the previously selected option and current selection matches
attributes: {
// Added check to not allow mainly .(period) and other special characters to be entered in the alert input
onkeydown: ($event: any) => {
if(/[`!@#$%^&*()_+\-=\\|,.<>?~]/.test($event.key)) $event.preventDefault();
}
}
}]
})
Expand Down
10 changes: 10 additions & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"auto cancel days": "auto cancel days",
"Brokering": "Brokering",
"Brokering Runs": "Brokering Runs",
"Brokering run cloned": "Brokering run cloned",
"Brokering run created": "Brokering run created",
"Brokering safety stock": "Brokering safety stock",
"Built:": "Built: ",
Expand All @@ -44,10 +45,14 @@
"Enter a valid value": "Enter a valid value",
"Error getting user profile": "Error getting user profile",
"Execution history": "Execution history",
"Failed to clone brokering run": "Failed to clone brokering run",
"Failed to clone rule": "Failed to clone rule",
"Failed to clone the rule": "Failed to clone the rule",
"Failed to create brokering run": "Failed to create brokering run",
"Failed to create inventory rule": "Failed to create inventory rule",
"Failed to create order routing": "Failed to create order routing",
"Failed to fetch filters options": "Failed to fetch filters options",
"Failed to fetch sort options": "Failed to fetch sort options",
"Failed to update group information": "Failed to update group information",
"Failed to update group status": "Failed to update group status",
"Failed to schedule service": "Failed to schedule service",
Expand All @@ -60,6 +65,7 @@
"Group": "Group",
"Group history": "Group history",
"Group status updated": "Group status updated",
"Go to Launchpad": "Go to Launchpad",
"Go to OMS": "Go to OMS",
"greater": "greater",
"greater than or equal to": "greater than or equal to",
Expand All @@ -71,6 +77,7 @@
"kms": "kms",
"Last run": "Last run",
"Logging in...": "Logging in...",
"Logging out": "Logging out",
"Login": "Login",
"Logout": "Logout",
"Low": "Low",
Expand All @@ -96,9 +103,12 @@
"Order priority": "Order priority",
"Order Rule Filters": "Order Rule Filters",
"Order Rule Sort": "Order Rule Sort",
"Order routing information updated": "Order routing information updated",
"Orders will be brokered based on order date if no sorting is specified.": "Orders will be brokered based on order date if no sorting is specified.",
"Origin Facility Group": "Origin Facility Group",
"operator": "operator",
"Partial allocation cannot be disabled. Orders are filtered by item when filtering by promise date.": "Partial allocation cannot be disabled. Orders are filtered by item when filtering by promise date.",
"Partially allocate grouped items": "Partially allocate grouped items",
"Partially available": "Partially available",
"Passed duration": "Passed duration",
"Password": "Password",
Expand Down
15 changes: 14 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ import "@ionic/vue/css/display.css";
import "./theme/variables.css";
import "@hotwax/apps-theme";

import { dxpComponents } from "@hotwax/dxp-components"
import { login, logout, loader } from "@/user-utils";
import { getConfig, initialise } from '@/adapter';

import i18n from "./i18n"
import store from "./store"
import { DateTime } from "luxon";
Expand All @@ -39,7 +43,16 @@ const app = createApp(App)
})
.use(router)
.use(i18n)
.use(store);
.use(store)
.use(dxpComponents, {
defaultImgUrl: require("@/assets/images/defaultImage.png"),
login,
logout,
loader,
appLoginUrl: process.env.VUE_APP_LOGIN_URL as string,
getConfig,
initialise
});

// Filters are removed in Vue 3 and global filter introduced https://v3.vuejs.org/guide/migration/filters.html#global-filters
app.config.globalProperties.$filters = {
Expand Down
27 changes: 16 additions & 11 deletions src/router/index.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
import { createRouter, createWebHistory } from "@ionic/vue-router";
import { RouteRecordRaw } from "vue-router";
import Login from "@/views/Login.vue"
import store from "@/store"
import Tabs from "@/views/Tabs.vue"
import { DxpLogin, useAuthStore } from '@hotwax/dxp-components';
import { loader } from '@/user-utils';

const authGuard = (to: any, from: any, next: any) => {
if (store.getters["user/isAuthenticated"]) {
next()
} else {
next("/login")
const authGuard = async (to: any, from: any, next: any) => {
const authStore = useAuthStore()
if (!authStore.isAuthenticated || !store.getters['user/isAuthenticated']) {
await loader.present('Authenticating')
// TODO use authenticate() when support is there
const redirectUrl = window.location.origin + '/login'
window.location.href = `${process.env.VUE_APP_LOGIN_URL}?redirectUrl=${redirectUrl}`
loader.dismiss()
}
next()
};

const loginGuard = (to: any, from: any, next: any) => {
if (!store.getters["user/isAuthenticated"]) {
next()
} else {
next("/")
const authStore = useAuthStore()
if (authStore.isAuthenticated && !to.query?.token && !to.query?.oms) {
next('/')
}
next();
};

const routes: Array<RouteRecordRaw> = [
Expand Down Expand Up @@ -57,7 +62,7 @@ const routes: Array<RouteRecordRaw> = [
{
path: "/login",
name: "Login",
component: Login,
component: DxpLogin,
beforeEnter: loginGuard
},
]
Expand Down
37 changes: 33 additions & 4 deletions src/services/RoutingService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,19 @@ const fetchRoutingScheduleInformation = async (routingGroupId: string): Promise<
});
}

const fetchRoutingHistory = async (routingGroupId: string): Promise<any> => {
const fetchRoutingHistory = async (routingGroupId: string, params: any): Promise<any> => {
return api({
url: `groups/${routingGroupId}/routingRuns`,
method: "GET"
method: "GET",
params
});
}

const fetchGroupHistory = async (jobName: string): Promise<any> => {
const fetchGroupHistory = async (jobName: string, params: any): Promise<any> => {
return api({
url: `serviceJobRuns/${jobName}`,
method: "GET"
method: "GET",
params
});
}

Expand All @@ -52,6 +54,14 @@ const updateRoutingGroup = async (payload: any): Promise<any> => {
})
}

const cloneGroup = async (payload: any): Promise<any> => {
return api({
url: `groups/${payload.routingGroupId}/clone`,
method: "POST",
data: payload
})
}

const fetchOrderRouting = async (orderRoutingId: string): Promise<any> => {
return api({
url: `routings/${orderRoutingId}`,
Expand All @@ -75,6 +85,14 @@ const createOrderRouting = async (payload: any): Promise<any> => {
})
}

const cloneRouting = async (payload: any): Promise<any> => {
return await api({
url: `routings/${payload.orderRoutingId}/clone`,
method: "POST",
data: payload
})
}

const updateRouting = async (payload: any): Promise<any> => {
return api({
url: `routings/${payload.orderRoutingId}`,
Expand Down Expand Up @@ -114,6 +132,14 @@ const fetchRule = async (routingRuleId: string): Promise<any> => {
});
}

const cloneRule = async (payload: any): Promise<any> => {
return await api({
url: `rules/${payload.routingRuleId}/clone`,
method: "POST",
data: payload
})
}

const updateRule = async (payload: any): Promise<any> => {
return api({
url: `rules/${payload.routingRuleId}`,
Expand All @@ -138,7 +164,10 @@ const runNow = async (routingGroupId: string): Promise<any> => {
}

export const OrderRoutingService = {
cloneGroup,
createOrderRouting,
cloneRouting,
cloneRule,
createRoutingGroup,
createRoutingRule,
deleteRoutingFilter,
Expand Down
Loading

0 comments on commit b7249fb

Please sign in to comment.