### What problem does this PR solve? feat: Build the edges of Switch by form data #1739 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import { DSLComponents } from '@/interfaces/database/flow';
|
||||
import { removeUselessFieldsFromValues } from '@/utils/form';
|
||||
import { FormInstance, FormListFieldData } from 'antd';
|
||||
import { humanId } from 'human-id';
|
||||
import { curry, intersectionWith, isEqual, sample } from 'lodash';
|
||||
import { curry, get, intersectionWith, isEqual, sample } from 'lodash';
|
||||
import pipe from 'lodash/fp/pipe';
|
||||
import isObject from 'lodash/isObject';
|
||||
import { Edge, Node, Position } from 'reactflow';
|
||||
@@ -209,3 +210,27 @@ export const buildNewPositionMap = (
|
||||
export const isKeysEqual = (currentKeys: string[], previousKeys: string[]) => {
|
||||
return isEqual(currentKeys.sort(), previousKeys.sort());
|
||||
};
|
||||
|
||||
export const getOperatorIndex = (handleTitle: string) => {
|
||||
return handleTitle.split(' ').at(-1);
|
||||
};
|
||||
|
||||
// Get the value of other forms except itself
|
||||
export const getOtherFieldValues = (
|
||||
form: FormInstance,
|
||||
formListName: string = 'items',
|
||||
field: FormListFieldData,
|
||||
latestField: string,
|
||||
) =>
|
||||
(form.getFieldValue([formListName]) ?? [])
|
||||
.map((x: any) => {
|
||||
return get(x, latestField);
|
||||
})
|
||||
.filter(
|
||||
(x: string) =>
|
||||
x !== form.getFieldValue([formListName, field.name, latestField]),
|
||||
);
|
||||
|
||||
export const generateSwitchHandleText = (idx: number) => {
|
||||
return `Item ${idx + 1}`;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user