fix(subTable): fix changing title field invalid (#3625)
* test: add e2e * fix: fieldNames change in sub-table should take effect in real time * fix: fieldNames change in sub-table should take effect in real time --------- Co-authored-by: katherinehhh <katherine_15995@163.com>
This commit is contained in:
parent
202fcef17c
commit
d56268730b
@ -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,
|
||||
});
|
||||
|
@ -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'] ? <LoadingOutlined /> : props.suffixIcon,
|
||||
};
|
||||
|
@ -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();
|
||||
});
|
||||
});
|
||||
|
@ -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,
|
||||
},
|
||||
};
|
Loading…
Reference in New Issue
Block a user