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: operator to be used in rule condition for facilities / channels selection (#371) #372

Merged
merged 1 commit into from
Sep 2, 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
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
Loading