Browse Source

fix: can't compare empty value

Ahmad Kholid 3 years ago
parent
commit
a4698abff5
1 changed files with 7 additions and 7 deletions
  1. 7 7
      src/utils/test-conditions.js

+ 7 - 7
src/utils/test-conditions.js

@@ -35,7 +35,7 @@ export default async function (conditionsArr, workflowData) {
         workflowData.refData
       );
 
-      copyData[key] = value;
+      copyData[key] = value ?? '';
       Object.assign(result.replacedValue, list);
     });
 
@@ -66,11 +66,11 @@ export default async function (conditionsArr, workflowData) {
       if (!conditionResult) return conditionResult;
 
       if (category === 'compare') {
-        const isNeedValue = conditionBuilder.compareTypes.find(
+        const { needValue } = conditionBuilder.compareTypes.find(
           ({ id }) => id === type
-        ).needValue;
+        );
 
-        if (!isNeedValue) {
+        if (!needValue) {
           conditionResult = comparisons[type](condition.value);
 
           return conditionResult;
@@ -79,11 +79,11 @@ export default async function (conditionsArr, workflowData) {
         condition.operator = type;
       } else if (category === 'value') {
         const conditionValue = await getConditionItemValue({ data, type });
-        const isCompareable = conditionBuilder.valueTypes.find(
+        const { compareable } = conditionBuilder.valueTypes.find(
           ({ id }) => id === type
-        ).compareable;
+        );
 
-        if (!isCompareable) {
+        if (!compareable) {
           conditionResult = conditionValue;
         } else if (condition.operator) {
           conditionResult = comparisons[condition.operator](