diff --git a/packages/core/client/src/schema-component/antd/filter/useValues.ts b/packages/core/client/src/schema-component/antd/filter/useValues.ts index 9079ea1cc..3ba233230 100644 --- a/packages/core/client/src/schema-component/antd/filter/useValues.ts +++ b/packages/core/client/src/schema-component/antd/filter/useValues.ts @@ -46,7 +46,6 @@ export const useValues = () => { field.data.operator = operator; field.data.schema = merge(option?.schema, operator?.schema); field.data.value = get(field.value, `${fieldPath}.$${operatorValue}`); - console.log('option', operator, field.data.value); }; useEffect(() => { value2data(); diff --git a/packages/plugins/workflow/src/client/components/CollectionFieldset.tsx b/packages/plugins/workflow/src/client/components/CollectionFieldset.tsx new file mode 100644 index 000000000..a04d1f0d1 --- /dev/null +++ b/packages/plugins/workflow/src/client/components/CollectionFieldset.tsx @@ -0,0 +1,157 @@ +import React from "react"; +import { observer, useForm, useField } from "@formily/react"; +import { Input, Button, Dropdown, Menu, Form } from "antd"; +import { PlusOutlined, CloseCircleOutlined } from '@ant-design/icons'; +import { useTranslation } from "react-i18next"; +import { css } from "@emotion/css"; + +import { CollectionField, CollectionProvider, SchemaComponent, useCollectionManager, useCompile } from "@nocobase/client"; +import { Operand, parseStringValue, VariableTypes, VariableTypesContext } from "../calculators"; + +function AssociationInput(props) { + const { getCollectionFields } = useCollectionManager(); + const { path } = useField(); + const fieldName = path.segments[path.segments.length - 1] as string; + const { values: data } = useForm(); + const fields = getCollectionFields(data?.config?.collection); + const { type } = fields.find(item => item.name === fieldName); + + const value = Array.isArray(props.value) ? props.value.join(',') : props.value; + function onChange(ev) { + const trimed = ev.target.value.trim(); + props.onChange(['belongsTo', 'hasOne'].includes(type) ? trimed : trimed.split(/[,\s]+/)); + } + return ( + + ); +} + +// NOTE: observer for watching useProps +export default observer(({ value, onChange }: any) => { + const { t } = useTranslation(); + const compile = useCompile(); + const { getCollection, getCollectionFields } = useCollectionManager(); + const { values: data } = useForm(); + const collectionName = data?.config?.collection; + const fields = getCollectionFields(collectionName) + .filter(field => ( + !field.hidden + && (field.uiSchema ? !field.uiSchema['x-read-pretty'] : false) + // && (!['linkTo', 'hasMany', 'hasOne', 'belongsToMany'].includes(field.type)) + )); + + return ( +
+ ); +});