Commit 969b9ee7 authored by MARCO Jonathan's avatar MARCO Jonathan
Browse files

馃悰 Add use case check for condition to fix array checking

parent c47210cd
Pipeline #63887 passed with stage
in 14 seconds
import {ConditionItemTranslated, ConditionTranslated} from '#form-plugin/models/form';
import {isPlainObject, isString} from 'lodash/fp';
import {isPlainObject, isString, isArray} from 'lodash/fp';
import store from '@form-plugin/store';
export const check = (conditions: ConditionTranslated[] | undefined): boolean => {
......@@ -84,10 +84,24 @@ export function fieldCheck(condition: ConditionItemTranslated, conditions: Condi
} else {
const linkedInputValue = store.getters['submission/getValue'](store.getters['form/getFieldById'](condition.id).name);
if (isString(condition.value) && isPlainObject(linkedInputValue) && isString(linkedInputValue.value)) {
if (isArray(condition?.value) && isPlainObject(linkedInputValue) && isArray(linkedInputValue?.value)) {
return linkedInputValue.value.some((value: string) => {
return condition.value.includes(value)
})
}
if (isArray(condition?.value) && isPlainObject(linkedInputValue) && isString(linkedInputValue?.value)) {
return condition.value.includes(linkedInputValue.value)
}
if (isArray(condition?.value) && isString(linkedInputValue)) {
return condition.value.includes(linkedInputValue)
}
if (isString(condition?.value) && isPlainObject(linkedInputValue) && isString(linkedInputValue?.value)) {
return condition.value === linkedInputValue.value;
}
if (isString(condition.value)) {
if (isString(condition?.value)) {
return condition.value === String(linkedInputValue);
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment