Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved rule condition generation template based on backend compatibility (#363) #364

Merged
merged 1 commit into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions src/components/RuleItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,41 +48,41 @@
<ion-label>{{ translate("Facilities") }}</ion-label>
</ion-item-divider>

<ion-item v-if="isRuleConditionAvailable('ENTCT_ATP_FAC_GROUPS', 'facilityGroupId', 'in')">
<ion-item v-if="isRuleConditionAvailable('ENTCT_ATP_FAC_GROUPS', 'facilityGroupId', 'contains')">
<ion-icon slot="start" :icon="checkmarkDoneCircleOutline"/>
<ion-label class="ion-text-wrap">{{ getRuleConditions("ENTCT_ATP_FAC_GROUPS", "facilityGroupId", "in") }}</ion-label>
<ion-label class="ion-text-wrap">{{ getRuleConditions("ENTCT_ATP_FAC_GROUPS", "facilityGroupId", "contains") }}</ion-label>
</ion-item>
<ion-item lines="full" v-if="isRuleConditionAvailable('ENTCT_ATP_FAC_GROUPS', 'facilityGroupId', 'not-in')">
<ion-item lines="full" v-if="isRuleConditionAvailable('ENTCT_ATP_FAC_GROUPS', 'facilityGroupId', 'not-contains')">
<ion-icon slot="start" :icon="closeCircleOutline"/>
<ion-label class="ion-text-wrap">{{ getRuleConditions("ENTCT_ATP_FAC_GROUPS", "facilityGroupId", "not-in") }}</ion-label>
<ion-label class="ion-text-wrap">{{ getRuleConditions("ENTCT_ATP_FAC_GROUPS", "facilityGroupId", "not-contains") }}</ion-label>
</ion-item>
</template>

<template v-if="areProductFiltersSelected()">
<ion-item-divider color="light" v-if="isRuleConditionAvailable('ENTCT_ATP_FILTER', 'tags', 'in') || isRuleConditionAvailable('ENTCT_ATP_FILTER', 'tags', 'not-in')">
<ion-item-divider color="light" v-if="isRuleConditionAvailable('ENTCT_ATP_FILTER', 'tags', 'contains') || isRuleConditionAvailable('ENTCT_ATP_FILTER', 'tags', 'not-contains')">
<ion-label>{{ translate("Product tags") }}</ion-label>
</ion-item-divider>

<ion-item v-if="isRuleConditionAvailable('ENTCT_ATP_FILTER', 'tags', 'in')" :lines="isRuleConditionAvailable('ENTCT_ATP_FILTER', 'tags', 'not-in') ? '' : 'full'">
<ion-item v-if="isRuleConditionAvailable('ENTCT_ATP_FILTER', 'tags', 'contains')" :lines="isRuleConditionAvailable('ENTCT_ATP_FILTER', 'tags', 'not-contains') ? '' : 'full'">
<ion-icon slot="start" :icon="checkmarkDoneCircleOutline"/>
<ion-label class="ion-text-wrap">{{ getRuleConditions("ENTCT_ATP_FILTER", "tags", "in") }}</ion-label>
<ion-label class="ion-text-wrap">{{ getRuleConditions("ENTCT_ATP_FILTER", "tags", "contains") }}</ion-label>
</ion-item>
<ion-item lines="full" v-if="isRuleConditionAvailable('ENTCT_ATP_FILTER', 'tags', 'not-in')">
<ion-item lines="full" v-if="isRuleConditionAvailable('ENTCT_ATP_FILTER', 'tags', 'not-contains')">
<ion-icon slot="start" :icon="closeCircleOutline"/>
<ion-label class="ion-text-wrap">{{ getRuleConditions("ENTCT_ATP_FILTER", "tags", "not-in") }}</ion-label>
<ion-label class="ion-text-wrap">{{ getRuleConditions("ENTCT_ATP_FILTER", "tags", "not-contains") }}</ion-label>
</ion-item>

<ion-item-divider color="light" v-if="isRuleConditionAvailable('ENTCT_ATP_FILTER', 'productFeatures', 'in') || isRuleConditionAvailable('ENTCT_ATP_FILTER', 'productFeatures', 'not-in')">
<ion-item-divider color="light" v-if="isRuleConditionAvailable('ENTCT_ATP_FILTER', 'productFeatures', 'contains') || isRuleConditionAvailable('ENTCT_ATP_FILTER', 'productFeatures', 'not-contains')">
<ion-label>{{ translate("Product features") }}</ion-label>
</ion-item-divider>

<ion-item v-if="isRuleConditionAvailable('ENTCT_ATP_FILTER', 'productFeatures', 'in')" :lines="isRuleConditionAvailable('ENTCT_ATP_FILTER', 'productFeatures', 'not-in') ? '' : 'full'">
<ion-item v-if="isRuleConditionAvailable('ENTCT_ATP_FILTER', 'productFeatures', 'contains')" :lines="isRuleConditionAvailable('ENTCT_ATP_FILTER', 'productFeatures', 'not-contains') ? '' : 'full'">
<ion-icon slot="start" :icon="checkmarkDoneCircleOutline"/>
<ion-label class="ion-text-wrap">{{ getRuleConditions("ENTCT_ATP_FILTER", "productFeatures", "in") }}</ion-label>
<ion-label class="ion-text-wrap">{{ getRuleConditions("ENTCT_ATP_FILTER", "productFeatures", "contains") }}</ion-label>
</ion-item>
<ion-item lines="full" v-if="isRuleConditionAvailable('ENTCT_ATP_FILTER', 'productFeatures', 'not-in')">
<ion-item lines="full" v-if="isRuleConditionAvailable('ENTCT_ATP_FILTER', 'productFeatures', 'not-contains')">
<ion-icon slot="start" :icon="closeCircleOutline"/>
<ion-label class="ion-text-wrap">{{ getRuleConditions("ENTCT_ATP_FILTER", "productFeatures", "not-in") }}</ion-label>
<ion-label class="ion-text-wrap">{{ getRuleConditions("ENTCT_ATP_FILTER", "productFeatures", "not-contains") }}</ion-label>
</ion-item>
</template>
<template v-else>
Expand Down
25 changes: 10 additions & 15 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,16 @@ const generateRuleConditions = (ruleId: string, conditionTypeEnumId: string, app
"ruleId": ruleId,
conditionTypeEnumId,
"fieldName": conditionTypeEnumId === "ENTCT_ATP_FACILITIES" ? "facilityId" : "facilityGroupId",
"operator": "in",
"fieldValue": "ALL",
"multiValued": "Y"
"operator": "contains",
"fieldValue": "ALL"
})
} else if(conditionTypeEnumId === "ENTCT_ATP_FACILITIES") {
conditions.push({
"ruleId": ruleId,
conditionTypeEnumId,
"fieldName": "facilityId",
"operator": "in",
"fieldValue": selectedFac.length ? selectedFac.join(",") : "",
"multiValued": "Y"
"operator": "contains",
"fieldValue": selectedFac.length ? selectedFac.join(",") : ""
})
} else {
const includedFacilityGroupIds = selectedFac.included.map((group: any) => group.facilityGroupId)
Expand All @@ -127,9 +125,8 @@ const generateRuleConditions = (ruleId: string, conditionTypeEnumId: string, app
"ruleId": ruleId,
"conditionTypeEnumId": "ENTCT_ATP_FAC_GROUPS",
"fieldName": "facilityGroupId",
"operator": "in",
"fieldValue": includedFacilityGroupIds.join(","),
"multiValued": "Y"
"operator": "contains",
"fieldValue": includedFacilityGroupIds.join(",")
})
}

Expand All @@ -139,9 +136,8 @@ const generateRuleConditions = (ruleId: string, conditionTypeEnumId: string, app
"ruleId": ruleId,
"conditionTypeEnumId": "ENTCT_ATP_FAC_GROUPS",
"fieldName": "facilityGroupId",
"operator": "not-in",
"fieldValue": excludedFacilityGroupIds.join(","),
"multiValued": "Y"
"operator": "not-contains",
"fieldValue": excludedFacilityGroupIds.join(",")
})
}
}
Expand All @@ -153,9 +149,8 @@ const generateRuleConditions = (ruleId: string, conditionTypeEnumId: string, app
"ruleId": ruleId,
"conditionTypeEnumId": "ENTCT_ATP_FILTER",
"fieldName": filter,
"operator": type === "included" ? "in" : "not-in",
"fieldValue": value.join(","),
"multiValued": "Y"
"operator": type === "included" ? "contains" : "not-contains",
"fieldValue": value.join(",")
})
}
})
Expand Down
6 changes: 3 additions & 3 deletions src/views/CreateUpdateSafetyStockRule.vue
Original file line number Diff line number Diff line change
Expand Up @@ -139,21 +139,21 @@ onIonViewDidEnter(async () => {
formData.value.ruleName = currentRule.value.ruleName;
formData.value.safetyStock = currentRule.value.ruleActions[0]?.fieldValue ? currentRule.value.ruleActions[0].fieldValue : ''

const includedGroups = currentRule.value.ruleConditions.find((condition: any) => condition.conditionTypeEnumId === "ENTCT_ATP_FAC_GROUPS" && condition.operator === "in")
const includedGroups = currentRule.value.ruleConditions.find((condition: any) => condition.conditionTypeEnumId === "ENTCT_ATP_FAC_GROUPS" && condition.operator === "contains")
if(includedGroups?.fieldValue === "ALL") formData.value.areAllFacilitiesSelected = true;
else {
const includedGroupIds = includedGroups?.fieldValue ? includedGroups.fieldValue.split(",") : []
formData.value.selectedFacilityGroups.included = facilityGroups.value.filter((group: any) => includedGroupIds.includes(group.facilityGroupId));

const excludedGroups = currentRule.value.ruleConditions.find((condition: any) => condition.conditionTypeEnumId === "ENTCT_ATP_FAC_GROUPS" && condition.operator === "not-in")
const excludedGroups = currentRule.value.ruleConditions.find((condition: any) => condition.conditionTypeEnumId === "ENTCT_ATP_FAC_GROUPS" && condition.operator === "not-contains")
const excludedGroupIds = excludedGroups?.fieldValue ? excludedGroups.fieldValue.split(",") : []
formData.value.selectedFacilityGroups.excluded = facilityGroups.value.filter((group: any) => excludedGroupIds.includes(group.facilityGroupId));
}

const currentAppliedFilters = JSON.parse(JSON.stringify(appliedFilters.value))
currentRule.value.ruleConditions.map((condition: any) => {
if(condition.conditionTypeEnumId === "ENTCT_ATP_FILTER") {
if(condition.operator === "in") {
if(condition.operator === "contains") {
currentAppliedFilters["included"][condition.fieldName] = condition.fieldValue ? condition.fieldValue.split(",") : []
} else {
currentAppliedFilters["excluded"][condition.fieldName] = condition.fieldValue ? condition.fieldValue.split(",") : []
Expand Down
6 changes: 3 additions & 3 deletions src/views/CreateUpdateShippingRule.vue
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,13 @@ onIonViewDidEnter(async () => {
formData.value.isBrokeringAllowed = currentRule.value.ruleActions[0]?.fieldValue === "Y" ? true : false;

if(selectedSegment.value === "RG_SHIPPING_FACILITY") {
const includedGroups = currentRule.value.ruleConditions.find((condition: any) => condition.conditionTypeEnumId === "ENTCT_ATP_FAC_GROUPS" && condition.operator === "in")
const includedGroups = currentRule.value.ruleConditions.find((condition: any) => condition.conditionTypeEnumId === "ENTCT_ATP_FAC_GROUPS" && condition.operator === "contains")
if(includedGroups?.fieldValue === "ALL") formData.value.areAllSelected = true
else {
const includedGroupIds = includedGroups?.fieldValue ? includedGroups.fieldValue.split(",") : []
formData.value.selectedFacilityGroups.included = facilityGroups.value.filter((group: any) => includedGroupIds.includes(group.facilityGroupId));

const excludedGroups = currentRule.value.ruleConditions.find((condition: any) => condition.conditionTypeEnumId === "ENTCT_ATP_FAC_GROUPS" && condition.operator === "not-in")
const excludedGroups = currentRule.value.ruleConditions.find((condition: any) => condition.conditionTypeEnumId === "ENTCT_ATP_FAC_GROUPS" && condition.operator === "not-contains")
const excludedGroupIds = excludedGroups?.fieldValue ? excludedGroups.fieldValue.split(",") : []
formData.value.selectedFacilityGroups.excluded = facilityGroups.value.filter((group: any) => excludedGroupIds.includes(group.facilityGroupId));
}
Expand All @@ -181,7 +181,7 @@ onIonViewDidEnter(async () => {
const currentAppliedFilters = JSON.parse(JSON.stringify(appliedFilters.value))
currentRule.value.ruleConditions.map((condition: any) => {
if(condition.conditionTypeEnumId === "ENTCT_ATP_FILTER") {
if(condition.operator === "in") {
if(condition.operator === "contains") {
currentAppliedFilters["included"][condition.fieldName] = condition.fieldValue ? condition.fieldValue.split(",") : []
} else {
currentAppliedFilters["excluded"][condition.fieldName] = condition.fieldValue ? condition.fieldValue.split(",") : []
Expand Down
6 changes: 3 additions & 3 deletions src/views/CreateUpdateStorePickupRule.vue
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,13 @@ onIonViewDidEnter(async () => {
formData.value.isPickupAllowed = currentRule.value.ruleActions[0]?.fieldValue === "Y" ? true : false;

if(selectedSegment.value === "RG_PICKUP_FACILITY") {
const includedGroups = currentRule.value.ruleConditions.find((condition: any) => condition.conditionTypeEnumId === "ENTCT_ATP_FAC_GROUPS" && condition.operator === "in")
const includedGroups = currentRule.value.ruleConditions.find((condition: any) => condition.conditionTypeEnumId === "ENTCT_ATP_FAC_GROUPS" && condition.operator === "contains")
if(includedGroups?.fieldValue === "ALL") formData.value.areAllSelected = true
else {
const includedGroupIds = includedGroups?.fieldValue ? includedGroups.fieldValue.split(",") : []
formData.value.selectedFacilityGroups.included = facilityGroups.value.filter((group: any) => includedGroupIds.includes(group.facilityGroupId));

const excludedGroups = currentRule.value.ruleConditions.find((condition: any) => condition.conditionTypeEnumId === "ENTCT_ATP_FAC_GROUPS" && condition.operator === "not-in")
const excludedGroups = currentRule.value.ruleConditions.find((condition: any) => condition.conditionTypeEnumId === "ENTCT_ATP_FAC_GROUPS" && condition.operator === "not-contains")
const excludedGroupIds = excludedGroups?.fieldValue ? excludedGroups.fieldValue.split(",") : []
formData.value.selectedFacilityGroups.excluded = facilityGroups.value.filter((group: any) => excludedGroupIds.includes(group.facilityGroupId));
}
Expand All @@ -182,7 +182,7 @@ onIonViewDidEnter(async () => {
const currentAppliedFilters = JSON.parse(JSON.stringify(appliedFilters.value))
currentRule.value.ruleConditions.map((condition: any) => {
if(condition.conditionTypeEnumId === "ENTCT_ATP_FILTER") {
if(condition.operator === "in") {
if(condition.operator === "contains") {
currentAppliedFilters["included"][condition.fieldName] = condition.fieldValue ? condition.fieldValue.split(",") : []
} else {
currentAppliedFilters["excluded"][condition.fieldName] = condition.fieldValue ? condition.fieldValue.split(",") : []
Expand Down
2 changes: 1 addition & 1 deletion src/views/CreateUpdateThresholdRule.vue
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ onIonViewDidEnter(async () => {
const currentAppliedFilters = JSON.parse(JSON.stringify(appliedFilters.value))
currentRule.value.ruleConditions.map((condition: any) => {
if(condition.conditionTypeEnumId === "ENTCT_ATP_FILTER") {
if(condition.operator === "in") {
if(condition.operator === "contains") {
currentAppliedFilters["included"][condition.fieldName] = condition.fieldValue ? condition.fieldValue.split(",") : []
} else {
currentAppliedFilters["excluded"][condition.fieldName] = condition.fieldValue ? condition.fieldValue.split(",") : []
Expand Down
Loading