Skip to content

Commit

Permalink
Improved: operator to be used in rule condition for facilities select…
Browse files Browse the repository at this point in the history
…ion (#371)
  • Loading branch information
amansinghbais committed Sep 2, 2024
1 parent b9eb606 commit 8ff154f
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions src/components/RuleItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@
<ion-label>{{ translate("Facilities") }}</ion-label>
</ion-item-divider>

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

Expand Down
8 changes: 4 additions & 4 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,15 @@ const generateRuleConditions = (ruleId: string, conditionTypeEnumId: string, app
"ruleId": ruleId,
conditionTypeEnumId,
"fieldName": conditionTypeEnumId === "ENTCT_ATP_FACILITIES" ? "facilityId" : "facilityGroupId",
"operator": "contains",
"operator": "in",
"fieldValue": "ALL"
})
} else if(conditionTypeEnumId === "ENTCT_ATP_FACILITIES") {
conditions.push({
"ruleId": ruleId,
conditionTypeEnumId,
"fieldName": "facilityId",
"operator": "contains",
"operator": "in",
"fieldValue": selectedFac.length ? selectedFac.join(",") : ""
})
} else {
Expand All @@ -127,7 +127,7 @@ const generateRuleConditions = (ruleId: string, conditionTypeEnumId: string, app
"ruleId": ruleId,
"conditionTypeEnumId": "ENTCT_ATP_FAC_GROUPS",
"fieldName": "facilityGroupId",
"operator": "contains",
"operator": "in",
"fieldValue": includedFacilityGroupIds.join(",")
})
}
Expand All @@ -138,7 +138,7 @@ const generateRuleConditions = (ruleId: string, conditionTypeEnumId: string, app
"ruleId": ruleId,
"conditionTypeEnumId": "ENTCT_ATP_FAC_GROUPS",
"fieldName": "facilityGroupId",
"operator": "not-contains",
"operator": "not-in",
"fieldValue": excludedFacilityGroupIds.join(",")
})
}
Expand Down
4 changes: 2 additions & 2 deletions src/views/CreateUpdateSafetyStockRule.vue
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,13 @@ 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 === "contains")
const includedGroups = currentRule.value.ruleConditions.find((condition: any) => condition.conditionTypeEnumId === "ENTCT_ATP_FAC_GROUPS" && condition.operator === "in")
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-contains")
const excludedGroups = currentRule.value.ruleConditions.find((condition: any) => condition.conditionTypeEnumId === "ENTCT_ATP_FAC_GROUPS" && condition.operator === "not-in")
const excludedGroupIds = excludedGroups?.fieldValue ? excludedGroups.fieldValue.split(",") : []
formData.value.selectedFacilityGroups.excluded = facilityGroups.value.filter((group: any) => excludedGroupIds.includes(group.facilityGroupId));
}
Expand Down
4 changes: 2 additions & 2 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 === "contains")
const includedGroups = currentRule.value.ruleConditions.find((condition: any) => condition.conditionTypeEnumId === "ENTCT_ATP_FAC_GROUPS" && condition.operator === "in")
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-contains")
const excludedGroups = currentRule.value.ruleConditions.find((condition: any) => condition.conditionTypeEnumId === "ENTCT_ATP_FAC_GROUPS" && condition.operator === "not-in")
const excludedGroupIds = excludedGroups?.fieldValue ? excludedGroups.fieldValue.split(",") : []
formData.value.selectedFacilityGroups.excluded = facilityGroups.value.filter((group: any) => excludedGroupIds.includes(group.facilityGroupId));
}
Expand Down
4 changes: 2 additions & 2 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 === "contains")
const includedGroups = currentRule.value.ruleConditions.find((condition: any) => condition.conditionTypeEnumId === "ENTCT_ATP_FAC_GROUPS" && condition.operator === "in")
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-contains")
const excludedGroups = currentRule.value.ruleConditions.find((condition: any) => condition.conditionTypeEnumId === "ENTCT_ATP_FAC_GROUPS" && condition.operator === "not-in")
const excludedGroupIds = excludedGroups?.fieldValue ? excludedGroups.fieldValue.split(",") : []
formData.value.selectedFacilityGroups.excluded = facilityGroups.value.filter((group: any) => excludedGroupIds.includes(group.facilityGroupId));
}
Expand Down

0 comments on commit 8ff154f

Please sign in to comment.