mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-26 00:41:40 +08:00
### What problem does this PR solve? Feat: Construct a dynamic variable assignment form #10427 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
@ -1,14 +1,18 @@
|
||||
import { JSONSchema } from '@/components/jsonjoy-builder';
|
||||
import { get, isPlainObject } from 'lodash';
|
||||
import { get, isPlainObject, toLower } from 'lodash';
|
||||
import { JsonSchemaDataType } from '../constant';
|
||||
|
||||
function predicate(types: string[], type: string) {
|
||||
return types.some((x) => toLower(x) === toLower(type));
|
||||
}
|
||||
|
||||
export function hasSpecificTypeChild(
|
||||
data: Record<string, any> | Array<any>,
|
||||
types: string[] = [],
|
||||
) {
|
||||
if (Array.isArray(data)) {
|
||||
for (const value of data) {
|
||||
if (isPlainObject(value) && types.some((x) => x === value.type)) {
|
||||
if (isPlainObject(value) && predicate(types, value.type)) {
|
||||
return true;
|
||||
}
|
||||
if (hasSpecificTypeChild(value, types)) {
|
||||
@ -19,7 +23,7 @@ export function hasSpecificTypeChild(
|
||||
|
||||
if (isPlainObject(data)) {
|
||||
for (const value of Object.values(data)) {
|
||||
if (isPlainObject(value) && types.some((x) => x === value.type)) {
|
||||
if (isPlainObject(value) && predicate(types, value.type)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user