fix(select): fieldNames are missing the value parameter

This commit is contained in:
chenos 2024-03-05 23:58:56 +08:00
parent 516619bb04
commit e82179ff61
3 changed files with 20 additions and 15 deletions

View File

@ -165,6 +165,8 @@ export const filterCollapseItemFieldSettings = new SchemaSettings({
['x-uid']: fieldSchema['x-uid'], ['x-uid']: fieldSchema['x-uid'],
}; };
const fieldNames = { const fieldNames = {
...collectionField?.uiSchema?.['x-component-props']?.['fieldNames'],
...fieldSchema['x-component-props']?.['fieldNames'],
label, label,
}; };
fieldSchema['x-component-props'] = fieldSchema['x-component-props'] || {}; fieldSchema['x-component-props'] = fieldSchema['x-component-props'] || {};

View File

@ -5,7 +5,8 @@ import React from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { SchemaSettings } from '../../../../application/schema-settings/SchemaSettings'; import { SchemaSettings } from '../../../../application/schema-settings/SchemaSettings';
import { useFormBlockContext } from '../../../../block-provider'; import { useFormBlockContext } from '../../../../block-provider';
import { useCollection_deprecated, useCollectionManager_deprecated } from '../../../../collection-manager'; import { useCollectionManager_deprecated, useCollection_deprecated } from '../../../../collection-manager';
import { useFieldComponentName } from '../../../../common/useFieldComponentName';
import { useRecord } from '../../../../record-provider'; import { useRecord } from '../../../../record-provider';
import { removeNullCondition, useDesignable, useFieldModeOptions, useIsAddNewForm } from '../../../../schema-component'; import { removeNullCondition, useDesignable, useFieldModeOptions, useIsAddNewForm } from '../../../../schema-component';
import { isSubMode } from '../../../../schema-component/antd/association-field/util'; import { isSubMode } from '../../../../schema-component/antd/association-field/util';
@ -16,14 +17,13 @@ import {
useIsSelectFieldMode, useIsSelectFieldMode,
useTitleFieldOptions, useTitleFieldOptions,
} from '../../../../schema-component/antd/form-item/FormItem.Settings'; } from '../../../../schema-component/antd/form-item/FormItem.Settings';
import { VariableInput, getShouldChange } from '../../../../schema-settings';
import { useIsShowMultipleSwitch } from '../../../../schema-settings/hooks/useIsShowMultipleSwitch';
import { useColumnSchema } from '../../../../schema-component/antd/table-v2/Table.Column.Decorator'; import { useColumnSchema } from '../../../../schema-component/antd/table-v2/Table.Column.Decorator';
import { VariableInput, getShouldChange } from '../../../../schema-settings';
import { SchemaSettingsDataScope } from '../../../../schema-settings/SchemaSettingsDataScope';
import { SchemaSettingsSortingRule } from '../../../../schema-settings/SchemaSettingsSortingRule';
import { useIsShowMultipleSwitch } from '../../../../schema-settings/hooks/useIsShowMultipleSwitch';
import { useLocalVariables, useVariables } from '../../../../variables'; import { useLocalVariables, useVariables } from '../../../../variables';
import { useCollectionField } from '../utils'; import { useCollectionField } from '../utils';
import { useFieldComponentName } from '../../../../common/useFieldComponentName';
import { SchemaSettingsSortingRule } from '../../../../schema-settings/SchemaSettingsSortingRule';
import { SchemaSettingsDataScope } from '../../../../schema-settings/SchemaSettingsDataScope';
const enableLink = { const enableLink = {
name: 'enableLink', name: 'enableLink',
@ -77,10 +77,11 @@ const titleField: any = {
const fieldSchema = tableColumnSchema || schema; const fieldSchema = tableColumnSchema || schema;
const targetCollectionField = useCollectionField(); const targetCollectionField = useCollectionField();
const collectionField = tableColumnField || targetCollectionField; const collectionField = tableColumnField || targetCollectionField;
const fieldNames = const fieldNames = {
field?.componentProps?.fieldNames || ...collectionField?.uiSchema?.['x-component-props']?.['fieldNames'],
fieldSchema?.['x-component-props']?.['fieldNames'] || ...field?.componentProps?.fieldNames,
uiSchema?.['x-component-props']?.['fieldNames']; ...fieldSchema?.['x-component-props']?.['fieldNames'],
};
return { return {
title: t('Title field'), title: t('Title field'),
options, options,
@ -89,13 +90,13 @@ const titleField: any = {
const schema = { const schema = {
['x-uid']: fieldSchema['x-uid'], ['x-uid']: fieldSchema['x-uid'],
}; };
const fieldNames = { const newFieldNames = {
...collectionField?.uiSchema?.['x-component-props']?.['fieldNames'], ...collectionField?.uiSchema?.['x-component-props']?.['fieldNames'],
...field.componentProps.fieldNames, ...fieldSchema['x-component-props']?.['fieldNames'],
label, label,
}; };
fieldSchema['x-component-props'] = fieldSchema['x-component-props'] || {}; fieldSchema['x-component-props'] = fieldSchema['x-component-props'] || {};
fieldSchema['x-component-props']['fieldNames'] = fieldNames; fieldSchema['x-component-props']['fieldNames'] = newFieldNames;
schema['x-component-props'] = fieldSchema['x-component-props']; schema['x-component-props'] = fieldSchema['x-component-props'];
field.componentProps.fieldNames = fieldSchema['x-component-props'].fieldNames; field.componentProps.fieldNames = fieldSchema['x-component-props'].fieldNames;
dn.emit('patch', { dn.emit('patch', {

View File

@ -3,7 +3,7 @@ import _ from 'lodash';
import React from 'react'; import React from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { useFormBlockContext } from '../../../block-provider'; import { useFormBlockContext } from '../../../block-provider';
import { useCollection_deprecated, useCollectionManager_deprecated } from '../../../collection-manager'; import { useCollectionManager_deprecated, useCollection_deprecated } from '../../../collection-manager';
import { import {
GeneralSchemaDesigner, GeneralSchemaDesigner,
SchemaSettingsDefaultSortingRules, SchemaSettingsDefaultSortingRules,
@ -12,8 +12,8 @@ import {
SchemaSettingsSelectItem, SchemaSettingsSelectItem,
SchemaSettingsSwitchItem, SchemaSettingsSwitchItem,
} from '../../../schema-settings'; } from '../../../schema-settings';
import { useCompile, useDesignable } from '../../hooks';
import { SchemaSettingsDataScope } from '../../../schema-settings/SchemaSettingsDataScope'; import { SchemaSettingsDataScope } from '../../../schema-settings/SchemaSettingsDataScope';
import { useCompile, useDesignable } from '../../hooks';
export const AssociationFilterItemDesigner = (props) => { export const AssociationFilterItemDesigner = (props) => {
const fieldSchema = useFieldSchema(); const fieldSchema = useFieldSchema();
@ -44,6 +44,8 @@ export const AssociationFilterItemDesigner = (props) => {
['x-uid']: fieldSchema['x-uid'], ['x-uid']: fieldSchema['x-uid'],
}; };
const fieldNames = { const fieldNames = {
...collectionField?.uiSchema?.['x-component-props']?.['fieldNames'],
...fieldSchema['x-component-props']?.['fieldNames'],
label, label,
}; };
fieldSchema['x-component-props'] = fieldSchema['x-component-props'] || {}; fieldSchema['x-component-props'] = fieldSchema['x-component-props'] || {};