(nodeData, inputParam, displayType, index)
| 1192 | } |
| 1193 | |
| 1194 | const _showHideOperation = (nodeData, inputParam, displayType, index) => { |
| 1195 | const displayOptions = inputParam[displayType] |
| 1196 | /* For example: |
| 1197 | show: { |
| 1198 | enableMemory: true |
| 1199 | } |
| 1200 | */ |
| 1201 | Object.keys(displayOptions).forEach((path) => { |
| 1202 | const comparisonValue = displayOptions[path] |
| 1203 | if (path.includes('$index')) { |
| 1204 | path = path.replace('$index', index) |
| 1205 | } |
| 1206 | let groundValue = get(nodeData.inputs, path, '') |
| 1207 | if (groundValue && typeof groundValue === 'string' && groundValue.startsWith('[') && groundValue.endsWith(']')) { |
| 1208 | groundValue = JSON.parse(groundValue) |
| 1209 | } |
| 1210 | |
| 1211 | // Handle case where groundValue is an array |
| 1212 | if (Array.isArray(groundValue)) { |
| 1213 | if (Array.isArray(comparisonValue)) { |
| 1214 | // Both are arrays - check if there's any intersection |
| 1215 | const hasIntersection = comparisonValue.some((val) => groundValue.includes(val)) |
| 1216 | if (displayType === 'show' && !hasIntersection) { |
| 1217 | inputParam.display = false |
| 1218 | } |
| 1219 | if (displayType === 'hide' && hasIntersection) { |
| 1220 | inputParam.display = false |
| 1221 | } |
| 1222 | } else if (typeof comparisonValue === 'string') { |
| 1223 | // comparisonValue is string, groundValue is array - check if array contains the string |
| 1224 | const matchFound = groundValue.some((val) => comparisonValue === val || new RegExp(comparisonValue).test(val)) |
| 1225 | if (displayType === 'show' && !matchFound) { |
| 1226 | inputParam.display = false |
| 1227 | } |
| 1228 | if (displayType === 'hide' && matchFound) { |
| 1229 | inputParam.display = false |
| 1230 | } |
| 1231 | } else if (typeof comparisonValue === 'boolean' || typeof comparisonValue === 'number') { |
| 1232 | // For boolean/number comparison with array, check if array contains the value |
| 1233 | const matchFound = groundValue.includes(comparisonValue) |
| 1234 | if (displayType === 'show' && !matchFound) { |
| 1235 | inputParam.display = false |
| 1236 | } |
| 1237 | if (displayType === 'hide' && matchFound) { |
| 1238 | inputParam.display = false |
| 1239 | } |
| 1240 | } else if (typeof comparisonValue === 'object') { |
| 1241 | // For object comparison with array, use deep equality check |
| 1242 | const matchFound = groundValue.some((val) => isEqual(comparisonValue, val)) |
| 1243 | if (displayType === 'show' && !matchFound) { |
| 1244 | inputParam.display = false |
| 1245 | } |
| 1246 | if (displayType === 'hide' && matchFound) { |
| 1247 | inputParam.display = false |
| 1248 | } |
| 1249 | } |
| 1250 | } else { |
| 1251 | // Original logic for non-array groundValue |
no test coverage detected