Skip to content

Commit

Permalink
Merge pull request #43 from ymaheshwari1/#24-updated
Browse files Browse the repository at this point in the history
Implemented support to perform actions on the rules page in bulk and removed the unused code(#24 updated)
  • Loading branch information
ymaheshwari1 authored Jan 28, 2024
2 parents 67d0cdb + b2d4098 commit f9c611a
Show file tree
Hide file tree
Showing 12 changed files with 538 additions and 488 deletions.
6 changes: 3 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ 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_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={"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_ROUTE_STATUS_ENUMS={"ROUTING_DRAFT":{"id":"ROUTING_DRAFT","desc":"Draft","code":"DRAFT","color":"medium"},"ROUTING_ACTIVE":{"id":"ROUTING_ACTIVE","desc":"Active","code":"ACTIVE","color":"success"},"ROUTING_ARCHIVED":{"id":"ROUTING_ARCHIVED","desc":"Archived","code":"ARCHIVED","color":"warning"}}
VUE_APP_CRON_EXPRESSIONS={"Every 30 minutes":"0 */30 * ? * *","Hourly":"0 0 * ? * *","Every six hours":"0 0 */6 ? * *","Every day at midnight":"0 0 0 * * ?"}
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_STATUS_ENUMS={"ROUTING_DRAFT":{"id":"ROUTING_DRAFT","desc":"Draft","code":"DRAFT","color":"medium"},"ROUTING_ACTIVE":{"id":"ROUTING_ACTIVE","desc":"Active","code":"ACTIVE","color":"success"},"ROUTING_ARCHIVED":{"id":"ROUTING_ARCHIVED","desc":"Archived","code":"ARCHIVED","color":"warning"},"RULE_DRAFT":{"id":"RULE_DRAFT","desc":"Draft","code":"DRAFT","color":"medium"},"RULE_ACTIVE":{"id":"RULE_ACTIVE","desc":"Active","code":"ACTIVE","color":"success"},"RULE_ARCHIVED":{"id":"RULE_ARCHIVED","desc":"Acrhived","code":"ARCHIVED","color":"warning"}}
VUE_APP_CRON_EXPRESSIONS={"Every 30 minutes":"0 */30 * ? * *","Hourly":"0 0 * ? * *","Every six hours":"0 0 */6 ? * *","Every day at midnight":"0 0 0 * * ?"}
39 changes: 16 additions & 23 deletions src/components/AddInventoryFilterOptionsModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { IonButton, IonButtons, IonCheckbox, IonContent, IonFab, IonFabButton, I
import { useStore } from "vuex";
import { computed, defineProps, onMounted, ref } from "vue";
import { saveOutline } from "ionicons/icons";
import { DateTime } from "luxon";
const store = useStore();
const enums = computed(() => store.getters["util/getEnums"])
Expand Down Expand Up @@ -70,54 +71,46 @@ function addConditionOption(condition: any) {
const associatedEnum = enums.value[props.parentEnumId][associatedOptions[condition.enumId]]
if(isConditionOptionAlreadyApplied) {
delete inventoryRuleConditions.value[props.conditionTypeEnumId][condition.enumCode]
delete inventoryRuleConditions.value[condition.enumCode]
// When removing a condition, also remove its associated option if available
associatedEnum && delete inventoryRuleConditions.value[props.conditionTypeEnumId][associatedEnum.enumCode]
associatedEnum && delete inventoryRuleConditions.value[associatedEnum.enumCode]
} else {
// checking unchecking an option and then checking it again, we need to use the same values
if(props.ruleConditions[props.conditionTypeEnumId]?.[condition.enumCode]) {
inventoryRuleConditions.value[props.conditionTypeEnumId][condition.enumCode] = props.ruleConditions[props.conditionTypeEnumId][condition.enumCode]
associatedEnum && (inventoryRuleConditions.value[props.conditionTypeEnumId][associatedEnum.enumCode] = props.ruleConditions[props.conditionTypeEnumId][associatedEnum.enumCode])
if(props.ruleConditions?.[condition.enumCode]) {
inventoryRuleConditions.value[condition.enumCode] = props.ruleConditions[condition.enumCode]
associatedEnum && (inventoryRuleConditions.value[associatedEnum.enumCode] = props.ruleConditions[associatedEnum.enumCode])
} else {
// when adding a new value, we don't need to pass conditionSeqId
// Added check that whether the filters for the conditionType exists or not, if not then create a new value for conditionType
inventoryRuleConditions.value[props.conditionTypeEnumId] ? inventoryRuleConditions.value[props.conditionTypeEnumId][condition.enumCode] = {
inventoryRuleConditions.value[condition.enumCode] = {
routingRuleId: props.routingRuleId,
conditionTypeEnumId: props.conditionTypeEnumId,
fieldName: condition.enumCode,
sequenceNum: Object.keys(inventoryRuleConditions.value[props.conditionTypeEnumId]).length && inventoryRuleConditions.value[props.conditionTypeEnumId][Object.keys(inventoryRuleConditions.value[props.conditionTypeEnumId])[Object.keys(inventoryRuleConditions.value[props.conditionTypeEnumId]).length - 1]]?.sequenceNum >= 0 ? inventoryRuleConditions.value[props.conditionTypeEnumId][Object.keys(inventoryRuleConditions.value[props.conditionTypeEnumId])[Object.keys(inventoryRuleConditions.value[props.conditionTypeEnumId]).length - 1]].sequenceNum + 5 : 0, // added check for `>= 0` as sequenceNum can be 0 which will result in again setting the new seqNum to 0
} : inventoryRuleConditions.value = {
...inventoryRuleConditions.value,
[props.conditionTypeEnumId]: {
[condition.enumCode]: {
routingRuleId: props.routingRuleId,
conditionTypeEnumId: props.conditionTypeEnumId,
fieldName: condition.enumCode,
sequenceNum: 0
}
}
sequenceNum: Object.keys(inventoryRuleConditions.value).length && inventoryRuleConditions.value[Object.keys(inventoryRuleConditions.value)[Object.keys(inventoryRuleConditions.value).length - 1]]?.sequenceNum >= 0 ? inventoryRuleConditions.value[Object.keys(inventoryRuleConditions.value)[Object.keys(inventoryRuleConditions.value).length - 1]].sequenceNum + 5 : 0, // added check for `>= 0` as sequenceNum can be 0 which will result in again setting the new seqNum to 0
createdDate: DateTime.now().toMillis()
}
// Adding associatedEnum out of ternary, as we will always get the conditionTypeEnumId, as the filter will already handle that
associatedEnum && (inventoryRuleConditions.value[props.conditionTypeEnumId][associatedEnum.enumCode] = {
associatedEnum && (inventoryRuleConditions.value[associatedEnum.enumCode] = {
routingRuleId: props.routingRuleId,
conditionTypeEnumId: props.conditionTypeEnumId,
fieldName: associatedEnum.enumCode,
sequenceNum: Object.keys(inventoryRuleConditions.value[props.conditionTypeEnumId]).length && inventoryRuleConditions.value[props.conditionTypeEnumId][Object.keys(inventoryRuleConditions.value[props.conditionTypeEnumId])[Object.keys(inventoryRuleConditions.value[props.conditionTypeEnumId]).length - 1]]?.sequenceNum >= 0 ? inventoryRuleConditions.value[props.conditionTypeEnumId][Object.keys(inventoryRuleConditions.value[props.conditionTypeEnumId])[Object.keys(inventoryRuleConditions.value[props.conditionTypeEnumId]).length - 1]].sequenceNum + 5 : 0, // added check for `>= 0` as sequenceNum can be 0 which will result in again setting the new seqNum to 0
sequenceNum: Object.keys(inventoryRuleConditions.value).length && inventoryRuleConditions.value[Object.keys(inventoryRuleConditions.value)[Object.keys(inventoryRuleConditions.value).length - 1]]?.sequenceNum >= 0 ? inventoryRuleConditions.value[Object.keys(inventoryRuleConditions.value)[Object.keys(inventoryRuleConditions.value).length - 1]].sequenceNum + 5 : 0, // added check for `>= 0` as sequenceNum can be 0 which will result in again setting the new seqNum to 0
createdDate: DateTime.now().toMillis()
})
}
}
}
function saveConditionOptions() {
closeModal(inventoryRuleConditions.value, 'save');
closeModal('save');
}
function isConditionOptionSelected(code: string) {
return inventoryRuleConditions.value[props.conditionTypeEnumId]?.[code]
return inventoryRuleConditions.value?.[code]
}
function closeModal(filters = {}, action = 'close') {
modalController.dismiss({ dismissed: true, filters }, action)
function closeModal(action = 'close') {
modalController.dismiss({ dismissed: true, filters: inventoryRuleConditions.value }, action)
}
</script>
32 changes: 12 additions & 20 deletions src/components/AddOrderRouteFilterOptions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { IonButton, IonButtons, IonCheckbox, IonContent, IonFab, IonFabButton, I
import { useStore } from "vuex";
import { computed, defineProps, onMounted, ref } from "vue";
import { saveOutline } from "ionicons/icons";
import { DateTime } from "luxon";
const store = useStore();
const enums = computed(() => store.getters["util/getEnums"])
Expand Down Expand Up @@ -64,43 +65,34 @@ function addSortOption(sort: any) {
const isSortOptionAlreadyApplied = isSortOptionSelected(sort.enumCode)?.fieldName
if(isSortOptionAlreadyApplied) {
delete routingFilters.value[props.conditionTypeEnumId][sort.enumCode]
delete routingFilters.value[sort.enumCode]
} else {
// checking unchecking an option and then checking it again, we need to use the same values
if(props.orderRoutingFilters[props.conditionTypeEnumId]?.[sort.enumCode]) {
routingFilters.value[props.conditionTypeEnumId][sort.enumCode] = props.orderRoutingFilters[props.conditionTypeEnumId][sort.enumCode]
// TODO: check for a unique case that what if we add a new option, reorder the filters and then remove the old option and then add it again, this case result in duplicate seqNum which should not happen
if(props.orderRoutingFilters?.[sort.enumCode]) {
routingFilters.value[sort.enumCode] = props.orderRoutingFilters[sort.enumCode]
} else {
// when adding a new value, we don't need to pass conditionSeqId
// Added check that whether the filters for the conditionType exists or not, if not then create a new value for conditionType
routingFilters.value[props.conditionTypeEnumId] ? routingFilters.value[props.conditionTypeEnumId][sort.enumCode] = {
routingFilters.value[sort.enumCode] = {
orderRoutingId: props.orderRoutingId,
conditionTypeEnumId: props.conditionTypeEnumId,
fieldName: sort.enumCode,
sequenceNum: Object.keys(routingFilters.value[props.conditionTypeEnumId]).length && routingFilters.value[props.conditionTypeEnumId][Object.keys(routingFilters.value[props.conditionTypeEnumId])[Object.keys(routingFilters.value[props.conditionTypeEnumId]).length - 1]]?.sequenceNum >= 0 ? routingFilters.value[props.conditionTypeEnumId][Object.keys(routingFilters.value[props.conditionTypeEnumId])[Object.keys(routingFilters.value[props.conditionTypeEnumId]).length - 1]].sequenceNum + 5 : 0, // added check for `>= 0` as sequenceNum can be 0 which will result in again setting the new seqNum to 0
} : routingFilters.value = {
...routingFilters.value,
[props.conditionTypeEnumId]: {
[sort.enumCode]: {
orderRoutingId: props.orderRoutingId,
conditionTypeEnumId: props.conditionTypeEnumId,
fieldName: sort.enumCode,
sequenceNum: 0
}
}
sequenceNum: Object.keys(routingFilters.value).length && routingFilters.value[Object.keys(routingFilters.value)[Object.keys(routingFilters.value).length - 1]]?.sequenceNum >= 0 ? routingFilters.value[Object.keys(routingFilters.value)[Object.keys(routingFilters.value).length - 1]].sequenceNum + 5 : 0, // added check for `>= 0` as sequenceNum can be 0 which will result in again setting the new seqNum to 0
createdDate: DateTime.now().toMillis() // TODO: need to create createdDate object when clicking save button, as adding it here will have difference between creation time when having multiple filters to create
}
}
}
}
function saveSortOptions() {
closeModal(routingFilters.value, 'save');
closeModal('save');
}
function isSortOptionSelected(code: string) {
return routingFilters.value[props.conditionTypeEnumId]?.[code]
return routingFilters.value?.[code]
}
function closeModal(filters = {}, action = 'close') {
modalController.dismiss({ dismissed: true, filters }, action)
function closeModal(action = 'close') {
modalController.dismiss({ dismissed: true, filters: routingFilters.value }, action)
}
</script>
51 changes: 25 additions & 26 deletions src/services/RoutingService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,9 @@ const fetchRoutingRules = async (payload: any): Promise<any> => {
});
}

const fetchRoutingFilters = async (payload: any): Promise<any> => {
const updateRouting = async (payload: any): Promise<any> => {
return api({
url: `routings/${payload.orderRoutingId}/orderFilters`,
method: "GET",
query: payload
});
}

const updateRoutingFilter = async (payload: any): Promise<any> => {
return api({
url: `routings/${payload.orderRoutingId}/orderFilters`,
url: `routings/${payload.orderRoutingId}`,
method: "POST",
data: payload
});
Expand All @@ -94,14 +86,6 @@ const deleteRoutingFilter = async (payload: any): Promise<any> => {
});
}

const fetchRuleConditions = async (payload: any): Promise<any> => {
return api({
url: `rules/${payload.routingRuleId}/inventoryFilters`,
method: "GET",
query: payload
});
}

const createRuleCondition = async (payload: any): Promise<any> => {
return api({
url: `rules/${payload.routingRuleId}/inventoryFilters`,
Expand All @@ -118,11 +102,26 @@ const deleteRuleCondition = async (payload: any): Promise<any> => {
});
}

const fetchRuleActions = async (payload: any): Promise<any> => {
const deleteRuleAction = async (payload: any): Promise<any> => {
return api({
url: `rules/${payload.routingRuleId}/actions`,
method: "GET",
query: payload
method: "DELETE",
data: payload
});
}

const fetchRule = async (routingRuleId: string): Promise<any> => {
return api({
url: `rules/${routingRuleId}`,
method: "GET"
});
}

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

Expand All @@ -140,16 +139,16 @@ export const OrderRoutingService = {
createRoutingRule,
createRuleCondition,
deleteRoutingFilter,
deleteRuleAction,
deleteRuleCondition,
fetchOrderRouting,
fetchRoutingFilters,
fetchRoutingGroupInformation,
fetchRoutingGroups,
fetchRoutingRules,
fetchRuleActions,
fetchRuleConditions,
fetchRule,
scheduleBrokering,
updateOrderRouting,
updateRoutingFilter,
updateRoutingGroup
updateRouting,
updateRoutingGroup,
updateRule
}
12 changes: 1 addition & 11 deletions src/store/modules/orderRouting/OrderRoutingState.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
import { Group, RouteFilter } from "@/types";

export default interface OrderRoutingState {
groups: Array<any>; // runs
routes: Array<any>;
rules: Array<any>;
rules: any;
currentGroup: any;
currentRoute: any;
currentRouteFilters: {
[key: string]: { // conditionTypeEnumId as key
[key: string]: RouteFilter // enumCode/fieldName as key
}
};
ruleConditions: {};
ruleActions: {}
}
Loading

0 comments on commit f9c611a

Please sign in to comment.