Merge pull request 'refactor: remove x-compoent-custom' (#490) from fix_name_error into @hera/dev
Reviewed-on: daoyoucloud/tachycode#490
This commit is contained in:
commit
629b334422
@ -1,14 +1,11 @@
|
||||
import React, { useMemo } from 'react';
|
||||
import { Cascader } from 'antd';
|
||||
import { connect, useFieldSchema } from '@formily/react';
|
||||
import { connect } from '@formily/react';
|
||||
import { useCollectionManager, useRequest } from '@nocobase/client';
|
||||
import _ from 'lodash';
|
||||
|
||||
const AssociationCascader = connect((props) => {
|
||||
const { fieldNames } = props;
|
||||
const fieldSchema = useFieldSchema();
|
||||
const collection = fieldSchema['collectionName'];
|
||||
const associationField = props.associationField;
|
||||
const { fieldNames, collection, associationField } = props;
|
||||
const cm = useCollectionManager();
|
||||
const titleField = cm.getCollection(collection).titleField;
|
||||
const joinTitleField = cm.getCollection(collection + '.' + associationField).titleField;
|
||||
|
@ -1,14 +1,13 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { AutoComplete as AntdAutoComplete } from 'antd';
|
||||
import { connect, useFieldSchema, useForm } from '@formily/react';
|
||||
import { useAPIClient, useDesigner, useRequest } from '@nocobase/client';
|
||||
import { connect, useFieldSchema } from '@formily/react';
|
||||
import { useAPIClient } from '@nocobase/client';
|
||||
import { useAsyncEffect } from 'ahooks';
|
||||
import { fuzzysearch } from '../../utils';
|
||||
|
||||
export const AutoComplete = connect((props) => {
|
||||
const { fieldNames, params: fieldFilter } = props;
|
||||
const fieldSchema = useFieldSchema();
|
||||
const fieldNames = props.fieldNames || fieldSchema['x-component-props'].fieldNames;
|
||||
const fieldFilter = props.params;
|
||||
const [defultValue, setDefultValue] = useState([]);
|
||||
const api = useAPIClient();
|
||||
const [options, setOptions] = useState([]);
|
||||
|
@ -143,9 +143,8 @@ const useLabelOptions = (others) => {
|
||||
const fieldSchema = useFieldSchema();
|
||||
const { getField } = useCollection_deprecated();
|
||||
const collectionField = useMemo(() => getField(fieldSchema.name), [fieldSchema.name]);
|
||||
const collectionName = fieldSchema['x-compoent-custom'] ? fieldSchema['name'].toString().slice(7) : '';
|
||||
const request = {
|
||||
resource: collectionField ? collectionField?.target : collectionName,
|
||||
resource: collectionField?.target,
|
||||
action: 'list',
|
||||
params: {
|
||||
pageSize: 99999,
|
||||
@ -208,9 +207,8 @@ const InternalSelect = connect(
|
||||
if (mode && !['multiple', 'tags'].includes(mode)) {
|
||||
mode = undefined;
|
||||
}
|
||||
const fieldSchema = useFieldSchema();
|
||||
const modifiedProps = useLabelOptions(others);
|
||||
if (objectValue || fieldSchema['x-compoent-custom']) {
|
||||
if (objectValue) {
|
||||
return (
|
||||
<ObjectSelect
|
||||
rawOptions={rawOptions}
|
||||
|
@ -298,8 +298,8 @@ export const FilterCustomItemInitializer: React.FC<{
|
||||
value: 'name',
|
||||
},
|
||||
associationField,
|
||||
collection,
|
||||
},
|
||||
'x-compoent-custom': true,
|
||||
collectionName: collection,
|
||||
}),
|
||||
);
|
||||
@ -350,7 +350,6 @@ export const FilterItemCustomDesigner: React.FC = () => {
|
||||
{component === 'Select' || component === 'AutoComplete' ? <SchemaSettingCollection /> : null}
|
||||
{component === 'Select' || component === 'AutoComplete' ? <SchemaSettingComponent /> : null}
|
||||
{component === 'Select' || component === 'AutoComplete' ? <EditTitleField /> : null}
|
||||
{component === 'Select' || component === 'AutoComplete' ? <EditFormulaTitleField /> : null}
|
||||
<EditDefaultValue />
|
||||
<SchemaSettingsDivider />
|
||||
<SchemaSettingsRemove
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { Field } from '@formily/core';
|
||||
import { ISchema, useField, useFieldSchema, useForm } from '@formily/react';
|
||||
import { ISchema, useField, useFieldSchema } from '@formily/react';
|
||||
import {
|
||||
getShouldChange,
|
||||
SchemaComponent,
|
||||
@ -24,24 +24,21 @@ import {
|
||||
VariableScopeProvider,
|
||||
} from '@nocobase/client';
|
||||
import _ from 'lodash';
|
||||
import React, { useCallback, useContext, useEffect, useMemo } from 'react';
|
||||
import React, { useCallback, useEffect, useMemo } from 'react';
|
||||
import { useTranslation } from '../locale';
|
||||
import { FormFilterScope } from '../components/filter-form/FormFilterScope';
|
||||
import { useFieldComponents } from '../schema-initializer';
|
||||
import { useMemoizedFn } from 'ahooks';
|
||||
import { fieldsCollection } from '@nocobase/plugin-collection-manager';
|
||||
|
||||
export const useFormulaTitleOptions = () => {
|
||||
const compile = useCompile();
|
||||
const { getCollectionJoinField, getCollectionFields } = useCollectionManager_deprecated();
|
||||
const { getField } = useCollection_deprecated();
|
||||
const fieldSchema = useFieldSchema();
|
||||
const { t } = useTranslation();
|
||||
const { dn } = useDesignable();
|
||||
const collectionManage = useCollectionManager_deprecated();
|
||||
const collectionManageField = fieldSchema['x-compoent-custom']
|
||||
? collectionManage.collections.filter((value) => value.name === fieldSchema['x-decorator-props'])[0]
|
||||
: {};
|
||||
const collectionManageField = collectionManage.collections.filter(
|
||||
(value) => value.name === fieldSchema['x-decorator-props'],
|
||||
)[0];
|
||||
const collectionField = getField(fieldSchema['name']) || getCollectionJoinField(fieldSchema['x-collection-field']);
|
||||
let fields = [];
|
||||
if (collectionField) {
|
||||
@ -82,10 +79,9 @@ export const useFormulaTitleVisible = () => {
|
||||
// FIXME 这里现在只有当设置为 select,默认为 select 的时候看不到
|
||||
return (
|
||||
options.length > 0 &&
|
||||
((fieldSchema['x-component-props']?.mode === 'Select' &&
|
||||
fieldSchema['x-component-props']?.fieldNames?.value !== undefined &&
|
||||
fieldSchema['x-component'] === 'CollectionField') ||
|
||||
fieldSchema['x-compoent-custom'])
|
||||
fieldSchema['x-component-props']?.mode === 'Select' &&
|
||||
fieldSchema['x-component-props']?.fieldNames?.value !== undefined &&
|
||||
fieldSchema['x-component'] === 'CollectionField'
|
||||
);
|
||||
};
|
||||
|
||||
@ -305,7 +301,8 @@ export const EditTitleField = () => {
|
||||
const { dn } = useDesignable();
|
||||
const compile = useCompile();
|
||||
const collectionManage = useCollectionManager_deprecated();
|
||||
const collectionManageField = fieldSchema['x-compoent-custom']
|
||||
const isCustomFilterItem = ((fieldSchema?.name as string) ?? '').startsWith('custom.');
|
||||
const collectionManageField = isCustomFilterItem
|
||||
? collectionManage.collections.filter((value) => value.name === fieldSchema['x-decorator-props'])[0]
|
||||
: {};
|
||||
const collectionField = getField(fieldSchema['name']) || getCollectionJoinField(fieldSchema['x-collection-field']);
|
||||
@ -324,8 +321,7 @@ export const EditTitleField = () => {
|
||||
label: compile(field?.uiSchema?.title) || field?.name,
|
||||
}));
|
||||
|
||||
return options.length > 0 &&
|
||||
(fieldSchema['x-component'] === 'CollectionField' || fieldSchema['x-compoent-custom']) ? (
|
||||
return options.length > 0 && (fieldSchema['x-component'] === 'CollectionField' || isCustomFilterItem) ? (
|
||||
<SchemaSettingsSelectItem
|
||||
key="title-field"
|
||||
title={t('Title field')}
|
||||
|
Loading…
Reference in New Issue
Block a user