diff --git a/packages/core/client/src/modules/fields/component/Select/selectComponentFieldSettings.tsx b/packages/core/client/src/modules/fields/component/Select/selectComponentFieldSettings.tsx index b04ee55b1..4432d31a6 100644 --- a/packages/core/client/src/modules/fields/component/Select/selectComponentFieldSettings.tsx +++ b/packages/core/client/src/modules/fields/component/Select/selectComponentFieldSettings.tsx @@ -30,8 +30,6 @@ const enableLink = { type: 'switch', useVisible() { const field = useField(); - console.log(field); - console.log(useFieldSchema()); return field.readPretty; }, useComponentProps() { @@ -99,6 +97,10 @@ const titleField: any = { fieldSchema['x-component-props']['fieldNames'] = newFieldNames; schema['x-component-props'] = fieldSchema['x-component-props']; field.componentProps.fieldNames = fieldSchema['x-component-props'].fieldNames; + const path = field.path?.splice(field.path?.length - 1, 1); + field.form.query(`${path.concat(`*.` + fieldSchema.name)}`).forEach((f) => { + f.componentProps.fieldNames = fieldNames; + }); dn.emit('patch', { schema, }); diff --git a/packages/core/client/src/schema-component/antd/remote-select/RemoteSelect.tsx b/packages/core/client/src/schema-component/antd/remote-select/RemoteSelect.tsx index 2bb8be82c..03c0684e0 100644 --- a/packages/core/client/src/schema-component/antd/remote-select/RemoteSelect.tsx +++ b/packages/core/client/src/schema-component/antd/remote-select/RemoteSelect.tsx @@ -256,9 +256,9 @@ const InternalRemoteSelect = connect( ...props, fieldNames: { ...defaultFieldNames, + ...props.fieldNames, ...field.componentProps.fieldNames, ...fieldSchema['x-component-props']?.fieldNames, - ...props.fieldNames, }, suffixIcon: field?.['loading'] || field?.['validating'] ? : props.suffixIcon, }; diff --git a/packages/plugins/@nocobase/plugin-collection-manager/src/client/__e2e__/fields/manyToOne/schemaSettings.test.ts b/packages/plugins/@nocobase/plugin-collection-manager/src/client/__e2e__/fields/manyToOne/schemaSettings.test.ts index e258cc909..88d118338 100644 --- a/packages/plugins/@nocobase/plugin-collection-manager/src/client/__e2e__/fields/manyToOne/schemaSettings.test.ts +++ b/packages/plugins/@nocobase/plugin-collection-manager/src/client/__e2e__/fields/manyToOne/schemaSettings.test.ts @@ -7,6 +7,7 @@ import { test, } from '@nocobase/test/e2e'; import { createColumnItem, showSettingsMenu, testDefaultValue, testPattern } from '../../utils'; +import { T3377 } from './templatesOfBug'; test.describe('form item & create form', () => { test('supported options', async ({ page, mockPage, mockRecords }) => { @@ -661,3 +662,28 @@ test.describe('table column & table', () => { ).toBeVisible(); }); }); + +test.describe('table column & sub-table', () => { + // https://nocobase.height.app/T-3377 + test('title field', async ({ page, mockPage }) => { + await mockPage(T3377).goto(); + + await page.getByRole('button', { name: 'Add new' }).click(); + await page.getByTestId('select-object-multiple').click(); + + // 下拉列表中应该有值 + await expect(page.getByRole('option', { name: 'admin', exact: true })).toBeVisible(); + await expect(page.getByRole('option', { name: 'member', exact: true })).toBeVisible(); + + // 1. 切换 title field + await page.getByRole('button', { name: 'Roles', exact: true }).hover(); + await page.getByLabel('designer-schema-settings-TableV2.Column-fieldSettings:TableColumn-users').hover(); + await page.getByRole('menuitem', { name: 'Title field Role UID' }).click(); + await page.getByRole('option', { name: 'Role name' }).click(); + + // 2. 下拉列表的值会改变 + await page.getByTestId('select-object-multiple').click(); + await expect(page.getByRole('option', { name: 'Admin', exact: true })).toBeVisible(); + await expect(page.getByRole('option', { name: 'Member', exact: true })).toBeVisible(); + }); +}); diff --git a/packages/plugins/@nocobase/plugin-collection-manager/src/client/__e2e__/fields/manyToOne/templatesOfBug.ts b/packages/plugins/@nocobase/plugin-collection-manager/src/client/__e2e__/fields/manyToOne/templatesOfBug.ts new file mode 100644 index 000000000..1ddc7b732 --- /dev/null +++ b/packages/plugins/@nocobase/plugin-collection-manager/src/client/__e2e__/fields/manyToOne/templatesOfBug.ts @@ -0,0 +1,213 @@ +import { PageConfig, generalWithAssociation } from '@nocobase/test/e2e'; + +export const T3377: PageConfig = { + collections: generalWithAssociation, + pageSchema: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-component': 'Page', + properties: { + '9ceuqyw4ak4': { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-component': 'Grid', + 'x-initializer': 'BlockInitializers', + properties: { + dtuo84w9hyg: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-component': 'Grid.Row', + properties: { + '7uaaqswm95y': { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-component': 'Grid.Col', + properties: { + '1cfjo8r78he': { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-acl-action-props': { + skipScopeCheck: true, + }, + 'x-acl-action': 'general:create', + 'x-decorator': 'FormBlockProvider', + 'x-decorator-props': { + dataSource: 'main', + resource: 'general', + collection: 'general', + }, + 'x-toolbar': 'BlockSchemaToolbar', + 'x-settings': 'blockSettings:createForm', + 'x-component': 'CardItem', + 'x-component-props': {}, + properties: { + '8lwxiwoywg1': { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-component': 'FormV2', + 'x-component-props': { + useProps: '{{ useFormBlockProps }}', + }, + properties: { + grid: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-component': 'Grid', + 'x-initializer': 'FormItemInitializers', + properties: { + '729znsrntep': { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-component': 'Grid.Row', + properties: { + '5p86kmo6egw': { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-component': 'Grid.Col', + properties: { + oneToMany: { + 'x-uid': 'avqy27sb260', + _isJSONSchemaObject: true, + version: '2.0', + type: 'string', + 'x-toolbar': 'FormItemSchemaToolbar', + 'x-settings': 'fieldSettings:FormItem', + 'x-component': 'CollectionField', + 'x-decorator': 'FormItem', + 'x-collection-field': 'general.oneToMany', + 'x-component-props': { + fieldNames: { + label: 'id', + value: 'id', + }, + mode: 'SubTable', + }, + default: null, + properties: { + '8y7afx0j5th': { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-component': 'AssociationField.SubTable', + 'x-initializer': 'TableColumnInitializers', + 'x-initializer-props': { + action: false, + }, + 'x-index': 1, + properties: { + '142uprbj0nc': { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-decorator': 'TableV2.Column.Decorator', + 'x-toolbar': 'TableColumnSchemaToolbar', + 'x-settings': 'fieldSettings:TableColumn', + 'x-component': 'TableV2.Column', + properties: { + roles: { + 'x-uid': '8166uxmyjhx', + _isJSONSchemaObject: true, + version: '2.0', + 'x-collection-field': 'users.roles', + 'x-component': 'CollectionField', + 'x-component-props': { + fieldNames: { + label: 'name', + value: 'name', + }, + ellipsis: true, + size: 'small', + }, + 'x-decorator': 'FormItem', + 'x-decorator-props': { + labelStyle: { + display: 'none', + }, + }, + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': 'fzuzbc7eeez', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': 'siihawqjsjt', + 'x-async': false, + }, + }, + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': 'bwho4aaehk8', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': 's227w6yu1c8', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': 'kw0g1r7goe1', + 'x-async': false, + 'x-index': 1, + }, + lt5gxor0084: { + _isJSONSchemaObject: true, + version: '2.0', + type: 'void', + 'x-initializer': 'FormActionInitializers', + 'x-component': 'ActionBar', + 'x-component-props': { + layout: 'one-column', + style: { + marginTop: 24, + }, + }, + 'x-uid': 'zaerntg7pj3', + 'x-async': false, + 'x-index': 2, + }, + }, + 'x-uid': 'cpvzwnvfv5b', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': 'otvbtpe6k8t', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': '9fklx2ir6ps', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': 'cnlpg1c4tni', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': 'ne63abszen5', + 'x-async': false, + 'x-index': 1, + }, + }, + 'x-uid': 'yxsu4c1ag4d', + 'x-async': true, + 'x-index': 1, + }, +};