Skip to content

Commit

Permalink
Implemented: support to exclude order filters from route(#248)
Browse files Browse the repository at this point in the history
  • Loading branch information
ymaheshwari1 committed Aug 29, 2024
1 parent dcab823 commit a090796
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 9 deletions.
13 changes: 12 additions & 1 deletion src/components/AddOrderRouteFilterOptions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@
</ion-toolbar>
</ion-header>
<ion-content>
<ion-segment v-model="segmentSelected" v-if="conditionTypeEnumId === 'ENTCT_FILTER'">
<ion-segment-button value="included">
<ion-label>{{ translate("Include") }}</ion-label>
</ion-segment-button>
<ion-segment-button value="excluded">
<ion-label>{{ translate("Exclude") }}</ion-label>
</ion-segment-button>
</ion-segment>

<div v-if="!enums[props.parentEnumId]" class="empty-state">
<p>{{ translate(`Failed to fetch ${$props.label?.toLowerCase()} options`) }}</p>
</div>
Expand All @@ -31,7 +40,7 @@
</template>

<script setup lang="ts">
import { IonButton, IonButtons, IonCheckbox, IonContent, IonFab, IonFabButton, IonHeader, IonIcon, IonItem, IonList, IonPage, IonTitle, IonToolbar, modalController } from "@ionic/vue";
import { IonButton, IonButtons, IonCheckbox, IonContent, IonFab, IonFabButton, IonHeader, IonIcon, IonItem, IonLabel, IonList, IonPage, IonSegment, IonSegmentButton, IonTitle, IonToolbar, modalController } from "@ionic/vue";
import { useStore } from "vuex";
import { computed, defineProps, onMounted, ref } from "vue";
import { saveOutline } from "ionicons/icons";
Expand Down Expand Up @@ -64,6 +73,7 @@ const props = defineProps({
})
let routingFilters = ref({}) as any
let areFiltersUpdated = ref(false)
let segmentSelected = ref("included")
onMounted(() => {
routingFilters.value = props.orderRoutingFilters ? JSON.parse(JSON.stringify(props.orderRoutingFilters)) : {}
Expand Down Expand Up @@ -115,6 +125,7 @@ function isSortOptionSelected(code: string) {
}
function closeModal(action = "close") {
console.log('routingFilters.value',routingFilters.value)
modalController.dismiss({ dismissed: true, filters: routingFilters.value }, action)
}
</script>
10 changes: 9 additions & 1 deletion src/components/GroupActionsPopover.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,23 @@ const props = defineProps(["group"])
const isOmsConnectionExist = computed(() => store.getters["util/isOmsConnectionExist"])
async function updateGroupStatus(paused: string) {
console.log(props.group)
let routingGroups = [];
const payload = {
routingGroupId: props.group.routingGroupId,
paused
paused,
cronExpression: props.group.schedule?.cronExpression || "0 0 0 * * ?"
}
try {
const resp = await OrderRoutingService.scheduleBrokering(payload)
console.log('resp', resp, hasError(resp))
if(!hasError(resp)){
props.group.schedule = {
...props.group.schedule,
cronExpression: payload.cronExpression,
cronDescription:
}
showToast(translate("Group status updated"))
routingGroups = await store.dispatch("orderRouting/updateGroupStatus", { routingGroupId: props.group.routingGroupId, value: paused })
} else {
Expand Down
16 changes: 16 additions & 0 deletions src/store/modules/util/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,22 @@ const actions: ActionTree<UtilState, RootState> = {
return enumerations
}, enums)

console.log('enums', enums)

if(enums["ORD_FILTER_PRM_TYPE"]) {
Object.values(enums["ORD_FILTER_PRM_TYPE"]).reduce((filters: any, filter: any) => {
filters[filter.enumId + "_EXCLUDED"] = {
"enumId": filter.enumId + "_EXCLUDED",
"enumTypeId": filter.enumTypeId,
"enumCode": filter.enumCode + "_excluded",
"sequenceNum": 5,
"description": filter.description
}

return filters;
}, enums["ORD_FILTER_PRM_TYPE"])
}

if(enums["INV_FILTER_PRM_TYPE"] && enums["INV_FILTER_PRM_TYPE"]["IIP_FACILITY_GROUP"]) {
enums["INV_FILTER_PRM_TYPE"]["IIP_FACILITY_GROUP_EXCLUDED"] = {
"enumId": "IIP_FACILITY_GROUP_EXCLUDED",
Expand Down
69 changes: 62 additions & 7 deletions src/views/BrokeringQuery.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,34 +65,87 @@
<ion-select-option v-for="(facility, facilityId) in facilities" :key="facilityId" :value="facilityId">{{ facility.facilityName || facilityId }}</ion-select-option>
</ion-select>
</ion-item>
<ion-item v-if="getFilterValue(orderRoutingFilterOptions, ruleEnums, 'QUEUE_EXCLUDED')">
<ion-select multiple :placeholder="translate('queue')" interface="popover" :selected-text="getSelectedValue(orderRoutingFilterOptions, ruleEnums, 'QUEUE_EXCLUDED')" :value="getFilterValue(orderRoutingFilterOptions, ruleEnums, 'QUEUE_EXCLUDED').fieldValue?.split(',')" @ionChange="updateOrderFilterValue($event, 'QUEUE_EXCLUDED', true)">
<div slot="label">
<ion-label>{{ translate("Queue") }}</ion-label>
<ion-note color="danger">{{ translate("Excluded") }}</ion-note>
</div>
<ion-select-option v-for="(facility, facilityId) in facilities" :key="facilityId" :value="facilityId">{{ facility.facilityName || facilityId }}</ion-select-option>
</ion-select>
</ion-item>
<ion-item v-if="getFilterValue(orderRoutingFilterOptions, ruleEnums, 'SHIPPING_METHOD')">
<ion-select multiple :placeholder="translate('shipping method')" interface="popover" :label="translate('Shipping method')" :selected-text="getSelectedValue(orderRoutingFilterOptions, ruleEnums, 'SHIPPING_METHOD')" :value="getFilterValue(orderRoutingFilterOptions, ruleEnums, 'SHIPPING_METHOD').fieldValue?.split(',')" @ionChange="updateOrderFilterValue($event, 'SHIPPING_METHOD', true)">
<ion-select-option v-for="(shippingMethod, shippingMethodId) in shippingMethods" :key="shippingMethodId" :value="shippingMethodId">{{ shippingMethod.description || shippingMethodId }}</ion-select-option>
</ion-select>
</ion-item>
<ion-item v-if="getFilterValue(orderRoutingFilterOptions, ruleEnums, 'SHIPPING_METHOD_EXCLUDED')">
<ion-select multiple :placeholder="translate('shipping method')" interface="popover" :selected-text="getSelectedValue(orderRoutingFilterOptions, ruleEnums, 'SHIPPING_METHOD_EXCLUDED')" :value="getFilterValue(orderRoutingFilterOptions, ruleEnums, 'SHIPPING_METHOD_EXCLUDED').fieldValue?.split(',')" @ionChange="updateOrderFilterValue($event, 'SHIPPING_METHOD_EXCLUDED', true)">
<div slot="label">
<ion-label>{{ translate('Shipping method') }}</ion-label>
<ion-note color="danger">{{ translate("Excluded") }}</ion-note>
</div>
<ion-select-option v-for="(shippingMethod, shippingMethodId) in shippingMethods" :key="shippingMethodId" :value="shippingMethodId">{{ shippingMethod.description || shippingMethodId }}</ion-select-option>
</ion-select>
</ion-item>
<ion-item v-if="getFilterValue(orderRoutingFilterOptions, ruleEnums, 'PRIORITY')">
<ion-select :placeholder="translate('priority')" interface="popover" :label="translate('Order priority')" :value="getFilterValue(orderRoutingFilterOptions, ruleEnums, 'PRIORITY').fieldValue" @ionChange="updateOrderFilterValue($event, 'PRIORITY')">
<ion-select-option value="HIGH">{{ translate("High") }}</ion-select-option>
<ion-select-option value="MEDIUM">{{ translate("Medium") }}</ion-select-option>
<ion-select-option value="Low">{{ translate("Low") }}</ion-select-option>
</ion-select>
</ion-item>
<ion-item v-if="getFilterValue(orderRoutingFilterOptions, ruleEnums, 'PRIORITY_EXCLUDED')">
<ion-select :placeholder="translate('priority')" interface="popover" :value="getFilterValue(orderRoutingFilterOptions, ruleEnums, 'PRIORITY_EXCLUDED').fieldValue" @ionChange="updateOrderFilterValue($event, 'PRIORITY_EXCLUDED')">
<div slot="label">
<ion-label>{{ translate('Order priority') }}</ion-label>
<ion-note color="danger">{{ translate("Excluded") }}</ion-note>
</div>
<ion-select-option value="HIGH">{{ translate("High") }}</ion-select-option>
<ion-select-option value="MEDIUM">{{ translate("Medium") }}</ion-select-option>
<ion-select-option value="Low">{{ translate("Low") }}</ion-select-option>
</ion-select>
</ion-item>
<ion-item v-if="getFilterValue(orderRoutingFilterOptions, ruleEnums, 'PROMISE_DATE')">
<ion-label>{{ translate("Promise date") }}</ion-label>
<ion-chip outline @click="selectPromiseFilterValue($event)">
{{ getPromiseDateValue() }}
</ion-chip>
</ion-item>
<ion-item v-if="getFilterValue(orderRoutingFilterOptions, ruleEnums, 'PROMISE_DATE_EXCLUDED')">
<ion-label>{{ translate("Promise date") }}</ion-label>
<ion-chip outline @click="selectPromiseFilterValue($event, excluded)">
{{ getPromiseDateValue() }}
</ion-chip>
</ion-item>
<ion-item v-if="getFilterValue(orderRoutingFilterOptions, ruleEnums, 'SALES_CHANNEL')">
<ion-select multiple :placeholder="translate('sales channel')" :label="translate('Sales Channel')" interface="popover" :selected-text="getSelectedValue(orderRoutingFilterOptions, ruleEnums, 'SALES_CHANNEL')" :value="getFilterValue(orderRoutingFilterOptions, ruleEnums, 'SALES_CHANNEL').fieldValue?.split(',')" @ionChange="updateOrderFilterValue($event, 'SALES_CHANNEL', true)">
<ion-select-option v-for="(enumInfo, enumId) in enums['ORDER_SALES_CHANNEL']" :key="enumId" :value="enumId">{{ enumInfo.description || enumInfo.enumId }}</ion-select-option>
</ion-select>
</ion-item>
<ion-item v-if="getFilterValue(orderRoutingFilterOptions, ruleEnums, 'SALES_CHANNEL_EXCLUDED')">
<ion-select multiple :placeholder="translate('sales channel')" interface="popover" :selected-text="getSelectedValue(orderRoutingFilterOptions, ruleEnums, 'SALES_CHANNEL_EXCLUDED')" :value="getFilterValue(orderRoutingFilterOptions, ruleEnums, 'SALES_CHANNEL_EXCLUDED').fieldValue?.split(',')" @ionChange="updateOrderFilterValue($event, 'SALES_CHANNEL_EXCLUDED', true)">
<div slot="label">
<ion-label>{{ translate('Sales Channel') }}</ion-label>
<ion-note color="danger">{{ translate("Excluded") }}</ion-note>
</div>
<ion-select-option v-for="(enumInfo, enumId) in enums['ORDER_SALES_CHANNEL']" :key="enumId" :value="enumId">{{ enumInfo.description || enumInfo.enumId }}</ion-select-option>
</ion-select>
</ion-item>
<ion-item v-if="getFilterValue(orderRoutingFilterOptions, ruleEnums, 'ORIGIN_FACILITY_GROUP')">
<ion-select multiple :placeholder="translate('facility group')" :label="translate('Origin Facility Group')" interface="popover" :selected-text="getSelectedValue(orderRoutingFilterOptions, ruleEnums, 'ORIGIN_FACILITY_GROUP')" :value="getFilterValue(orderRoutingFilterOptions, ruleEnums, 'ORIGIN_FACILITY_GROUP').fieldValue?.split(',')" @ionChange="updateOrderFilterValue($event, 'ORIGIN_FACILITY_GROUP', true)">
<ion-select-option v-for="(facilityGroup, facilityGroupId) in facilityGroups" :key="facilityGroupId" :value="facilityGroupId">{{ facilityGroup.facilityGroupName || facilityGroupId }}</ion-select-option>
</ion-select>
</ion-item>
<ion-item v-if="getFilterValue(orderRoutingFilterOptions, ruleEnums, 'ORIGIN_FACILITY_GROUP_EXCLUDED')">
<ion-select multiple :placeholder="translate('facility group')" interface="popover" :selected-text="getSelectedValue(orderRoutingFilterOptions, ruleEnums, 'ORIGIN_FACILITY_GROUP_EXCLUDED')" :value="getFilterValue(orderRoutingFilterOptions, ruleEnums, 'ORIGIN_FACILITY_GROUP_EXCLUDED').fieldValue?.split(',')" @ionChange="updateOrderFilterValue($event, 'ORIGIN_FACILITY_GROUP_EXCLUDED', true)">
<div slot="label">
<ion-label>{{ translate('Origin Facility Group') }}</ion-label>
<ion-note color="danger">{{ translate("Excluded") }}</ion-note>
</div>
<ion-select-option v-for="(facilityGroup, facilityGroupId) in facilityGroups" :key="facilityGroupId" :value="facilityGroupId">{{ facilityGroup.facilityGroupName || facilityGroupId }}</ion-select-option>
</ion-select>
</ion-item>
</ion-item-group>
<ion-item-group>
<ion-item-divider color="light">
Expand Down Expand Up @@ -269,7 +322,6 @@
{{ translate("Select if partial allocation should be allowed in this inventory rule") }}
</ion-card-content>
<ion-item lines="none">
<!-- When selecting promiseDate route filter we will show the partial allocation option as checked on UI, but will not update its value on backend. Discussed with Aditya Sir -->
<ion-toggle :disabled="isPromiseDateFilterApplied()" :checked="selectedRoutingRule.assignmentEnumId === 'ORA_MULTI' || isPromiseDateFilterApplied()" @ionChange="updatePartialAllocation($event.detail.checked)">{{ translate("Allow partial allocation") }}</ion-toggle>
</ion-item>
<ion-item v-show="isPromiseDateFilterApplied()" lines="none">
Expand Down Expand Up @@ -880,12 +932,12 @@ function getLabel(parentType: string, code: string) {
return enumInfo?.description
}
async function selectPromiseFilterValue(ev: CustomEvent) {
async function selectPromiseFilterValue(ev: CustomEvent, type = "included") {
const popover = await popoverController
.create({
component: PromiseFilterPopover,
componentProps: {
value: getFilterValue(orderRoutingFilterOptions.value, ruleEnums, "PROMISE_DATE").fieldValue
value: getFilterValue(orderRoutingFilterOptions.value, ruleEnums, type === "excluded" ? "PROMISE_DATE_EXCLUDED" : "PROMISE_DATE").fieldValue
},
event: ev,
translucent: true,
Expand All @@ -894,10 +946,12 @@ async function selectPromiseFilterValue(ev: CustomEvent) {
popover.onDidDismiss().then((result: any) => {
if(result.data?.duration || result.data?.duration == 0) {
getFilterValue(orderRoutingFilterOptions.value, ruleEnums, "PROMISE_DATE").fieldValue = result.data?.isPastDuration ? `-${result.data?.duration}` : result.data?.duration
getFilterValue(orderRoutingFilterOptions.value, ruleEnums, type === "excluded" ? "PROMISE_DATE_EXCLUDED" : "PROMISE_DATE").fieldValue = result.data?.isPastDuration ? `-${result.data?.duration}` : result.data?.duration
// Making partial allocation value to `MULTI` when applying promise date filter
updatePartialAllocation(true);
hasUnsavedChanges.value = true
}
getFilterValue(orderRoutingFilterOptions.value, ruleEnums, "PROMISE_DATE").operator = "less-equals"
getFilterValue(orderRoutingFilterOptions.value, ruleEnums, type === "excluded" ? "PROMISE_DATE_EXCLUDED" : "PROMISE_DATE").operator = "less-equals"
})
return popover.present();
Expand Down Expand Up @@ -941,12 +995,13 @@ function updateOperator(event: CustomEvent) {
}
function updateOrderFilterValue(event: CustomEvent, id: string, multi = false) {
console.log('id', id)
let value = event.detail.value
let operator = "equals"
let operator = id.includes("_EXCLUDED") ? "not-equals" : "equals"
// When the filter has multiple selection support then we will receive an array in the event value and thus creating a string before updating the same as the fieldValue supports a string as value
if(multi && value.length > 1) {
value = value.join(',')
operator = "in"
operator = id.includes("_EXCLUDED") ? "not-in" : "in"
} else if(multi) {
// When filter is having a single option selected with multiple selection enabled, we will receive an array with single value, but as we need to pass a string, so fetching the 0th index from the array
value = value[0]
Expand Down

0 comments on commit a090796

Please sign in to comment.