Add IN operator support for forms' hidden fields (#2939)

This commit is contained in:
Shrikant Sharat Kandula 2021-02-10 11:27:21 +05:30 committed by GitHub
parent c78a578247
commit c5df149ba8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 29 additions and 2 deletions

View File

@ -13,7 +13,9 @@ export type ComparisonOperations =
| "EQUALS"
| "NOT_EQUALS"
| "LESSER"
| "GREATER";
| "GREATER"
| "IN"
| "NOT_IN";
export type HiddenType =
| boolean

View File

@ -54,6 +54,22 @@ describe("isHidden test", () => {
comparison: "NOT_EQUALS",
},
},
{
values: { name: "Name", config: { type: "Different BODY" } },
hidden: {
path: "config.type",
value: ["EMAIL", "BODY"],
comparison: "IN",
},
},
{
values: { name: "Name", config: { type: "BODY" } },
hidden: {
path: "config.type",
value: ["EMAIL", "BODY"],
comparison: "NOT_IN",
},
},
{
values: undefined,
hidden: false,

View File

@ -15,6 +15,10 @@ export const isHidden = (values: any, hiddenConfig?: HiddenType) => {
return valueAtPath > value;
case "LESSER":
return valueAtPath < value;
case "IN":
return Array.isArray(value) && value.includes(valueAtPath);
case "NOT_IN":
return Array.isArray(value) && !value.includes(valueAtPath);
default:
return true;
}

View File

@ -188,7 +188,12 @@
{
"label": "Body",
"configProperty": "actionConfiguration.body",
"controlType": "QUERY_DYNAMIC_TEXT"
"controlType": "QUERY_DYNAMIC_TEXT",
"hidden": {
"path": "actionConfiguration.pluginSpecifiedTemplates[0].value",
"comparison": "IN",
"value": ["GET_DOCUMENT", "GET_COLLECTION", "DELETE_DOCUMENT"]
}
}
]
}