mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 03:46:08 +00:00
Merge branch 'main' into next
This commit is contained in:
commit
336c14748b
11
.github/pull_request_template.md
vendored
11
.github/pull_request_template.md
vendored
@ -21,11 +21,11 @@ mention any potential risks,
|
||||
and provide some testing suggestions.
|
||||
-->
|
||||
|
||||
### Related issues
|
||||
|
||||
### Showcase
|
||||
<!-- Including any screenshots of the changes. -->
|
||||
|
||||
### Related issues
|
||||
|
||||
### Changelog
|
||||
|
||||
| Language | Changelog |
|
||||
@ -33,6 +33,13 @@ and provide some testing suggestions.
|
||||
| 🇺🇸 English | |
|
||||
| 🇨🇳 Chinese | |
|
||||
|
||||
### Docs
|
||||
|
||||
| Language | Link |
|
||||
| ---------- | --------- |
|
||||
| 🇺🇸 English | <!-- [Title](link) --> |
|
||||
| 🇨🇳 Chinese | <!-- [标题](link) --> |
|
||||
|
||||
### Checklists
|
||||
- [ ] All changes have been self-tested and work as expected
|
||||
- [ ] Test cases are updated/provided or not needed
|
||||
|
@ -0,0 +1,104 @@
|
||||
/**
|
||||
* This file is part of the NocoBase (R) project.
|
||||
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
||||
* Authors: NocoBase Team.
|
||||
*
|
||||
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
||||
* For more information, please refer to: https://www.nocobase.com/agreement.
|
||||
*/
|
||||
|
||||
import { expect, test } from '@nocobase/test/e2e';
|
||||
import { ordinaryBlockTemplatesCannotBeUsedToCreateAssociationBlocksAndViceVersa } from './templatesOfBug';
|
||||
|
||||
test.describe('block template', () => {
|
||||
test('Ordinary block templates cannot be used to create association blocks, and vice versa', async ({
|
||||
page,
|
||||
mockPage,
|
||||
clearBlockTemplates,
|
||||
}) => {
|
||||
await mockPage(ordinaryBlockTemplatesCannotBeUsedToCreateAssociationBlocksAndViceVersa).goto();
|
||||
|
||||
// ensure the block templates are cleared at the end of the test
|
||||
await clearBlockTemplates();
|
||||
|
||||
// Save the table block on the page as a template -------------------------------------------
|
||||
await page.getByLabel('block-item-CardItem-roles-').hover();
|
||||
await page.getByLabel('designer-schema-settings-CardItem-blockSettings:table-roles').hover();
|
||||
await page.getByRole('menuitem', { name: 'Save as template' }).click();
|
||||
await page.getByRole('button', { name: 'OK', exact: true }).click();
|
||||
|
||||
// The template saved above cannot be used to create a association block.
|
||||
await page.getByLabel('action-Action.Link-View-view-').click();
|
||||
await page.getByLabel('schema-initializer-Grid-popup').hover();
|
||||
await page.getByRole('menuitem', { name: 'table Table right' }).hover();
|
||||
await page.getByRole('menuitem', { name: 'Associated records right' }).hover();
|
||||
|
||||
// The saved template should not be displayed (no arrow should be shown)
|
||||
await expect(page.getByRole('menuitem', { name: 'Roles' })).toBeVisible();
|
||||
await expect(page.getByRole('menuitem', { name: 'Roles right' })).not.toBeVisible();
|
||||
|
||||
// but can be used to create an other blocks by the "Other record" option
|
||||
await page.getByRole('menuitem', { name: 'Other records right' }).hover();
|
||||
await page.getByRole('menuitem', { name: 'Roles right' }).hover();
|
||||
await page.getByRole('menuitem', { name: 'Duplicate template right' }).hover();
|
||||
await expect(page.getByRole('menuitem', { name: 'Roles_Table' })).toBeVisible();
|
||||
await page.mouse.move(300, 0);
|
||||
|
||||
// Save the details block on the drawer as a template -------------------------------------------
|
||||
await page.getByLabel('block-item-CardItem-roles-details').hover();
|
||||
await page.getByLabel('designer-schema-settings-CardItem-blockSettings:detailsWithPagination-roles').hover();
|
||||
await page.getByRole('menuitem', { name: 'Save as template' }).click();
|
||||
await page.getByRole('button', { name: 'OK', exact: true }).click();
|
||||
await page.mouse.move(300, 0);
|
||||
// make more stable
|
||||
await page.waitForTimeout(500);
|
||||
|
||||
await page.getByLabel('schema-initializer-Grid-popup').hover();
|
||||
await page.getByRole('menuitem', { name: 'table Details right' }).hover();
|
||||
await page.getByRole('menuitem', { name: 'Associated records right' }).hover();
|
||||
await page.getByRole('menuitem', { name: 'Roles right' }).hover();
|
||||
await page.getByRole('menuitem', { name: 'Duplicate template right' }).hover();
|
||||
await expect(page.getByRole('menuitem', { name: 'Roles_Details' })).toBeVisible();
|
||||
await page.mouse.move(300, 0);
|
||||
|
||||
// Save the association block on the drawer as a template -------------------------------------------
|
||||
await page
|
||||
.getByTestId('drawer-Action.Container-users-View record')
|
||||
.getByLabel('block-item-CardItem-roles-table')
|
||||
.hover();
|
||||
await page
|
||||
.getByTestId('drawer-Action.Container-users-View record')
|
||||
.getByLabel('designer-schema-settings-CardItem-blockSettings:table-roles')
|
||||
.hover();
|
||||
await page.getByRole('menuitem', { name: 'Save as template' }).click();
|
||||
await page.getByLabel('Save as template').getByRole('textbox').fill('association_block');
|
||||
await page.getByRole('button', { name: 'OK', exact: true }).click();
|
||||
|
||||
// close the drawer
|
||||
await page.getByLabel('drawer-Action.Container-users-View record-mask').click();
|
||||
|
||||
// The template saved above cannot be used to create a non-association block.
|
||||
await page.getByLabel('schema-initializer-Grid-page:').hover();
|
||||
await page.getByRole('menuitem', { name: 'table Table right' }).hover();
|
||||
await page.getByRole('menuitem', { name: 'Roles right' }).hover();
|
||||
await page.getByRole('menuitem', { name: 'Duplicate template right' }).hover();
|
||||
await expect(page.getByRole('menuitem', { name: 'Roles_Table' })).toBeVisible();
|
||||
await expect(page.getByRole('menuitem', { name: 'association_block' })).not.toBeVisible();
|
||||
await page.mouse.move(300, 0);
|
||||
|
||||
// Click on the association field to open the drawer --------------------------------------
|
||||
await page.getByText('member').click();
|
||||
await page.getByLabel('block-item-CardItem-roles-details').hover();
|
||||
await page.getByLabel('designer-schema-settings-CardItem-blockSettings:details-roles').hover();
|
||||
await page.getByRole('menuitem', { name: 'Save as block template' }).click();
|
||||
await page.getByRole('textbox').fill('association_block_detail_item');
|
||||
await page.getByRole('button', { name: 'OK', exact: true }).click();
|
||||
|
||||
await page.getByLabel('schema-initializer-Grid-popup').hover();
|
||||
await page.getByRole('menuitem', { name: 'table Details right' }).hover();
|
||||
await page.getByRole('menuitem', { name: 'Current record right' }).hover();
|
||||
await page.getByRole('menuitem', { name: 'Duplicate template right' }).hover();
|
||||
await expect(page.getByRole('menuitem', { name: 'association_block_detail_item' })).toBeVisible();
|
||||
await page.mouse.move(300, 0);
|
||||
});
|
||||
});
|
@ -3830,6 +3830,789 @@ export const T4334 = {
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export const ordinaryBlockTemplatesCannotBeUsedToCreateAssociationBlocksAndViceVersa = {
|
||||
pageSchema: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Page',
|
||||
'x-app-version': '1.2.12-alpha',
|
||||
'x-index': 1,
|
||||
properties: {
|
||||
vp18xr4s94r: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid',
|
||||
'x-initializer': 'page:addBlock',
|
||||
'x-app-version': '1.2.12-alpha',
|
||||
'x-index': 1,
|
||||
properties: {
|
||||
'48xijrvwe7f': {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid.Row',
|
||||
'x-app-version': '1.2.12-alpha',
|
||||
'x-index': 1,
|
||||
properties: {
|
||||
a01jv0ma085: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid.Col',
|
||||
'x-app-version': '1.2.12-alpha',
|
||||
'x-index': 1,
|
||||
properties: {
|
||||
nkjq9mnwl3t: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-decorator': 'TableBlockProvider',
|
||||
'x-acl-action': 'users:list',
|
||||
'x-use-decorator-props': 'useTableBlockDecoratorProps',
|
||||
'x-decorator-props': {
|
||||
collection: 'users',
|
||||
dataSource: 'main',
|
||||
action: 'list',
|
||||
params: {
|
||||
pageSize: 20,
|
||||
},
|
||||
rowKey: 'id',
|
||||
showIndex: true,
|
||||
dragSort: false,
|
||||
},
|
||||
'x-toolbar': 'BlockSchemaToolbar',
|
||||
'x-settings': 'blockSettings:table',
|
||||
'x-component': 'CardItem',
|
||||
'x-filter-targets': [],
|
||||
'x-app-version': '1.2.12-alpha',
|
||||
'x-index': 1,
|
||||
properties: {
|
||||
actions: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-initializer': 'table:configureActions',
|
||||
'x-component': 'ActionBar',
|
||||
'x-component-props': {
|
||||
style: {
|
||||
marginBottom: 'var(--nb-spacing)',
|
||||
},
|
||||
},
|
||||
'x-app-version': '1.2.12-alpha',
|
||||
'x-index': 1,
|
||||
'x-uid': 'lo4ajp7tg96',
|
||||
'x-async': false,
|
||||
},
|
||||
r6045g8do83: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'array',
|
||||
'x-initializer': 'table:configureColumns',
|
||||
'x-component': 'TableV2',
|
||||
'x-use-component-props': 'useTableBlockProps',
|
||||
'x-component-props': {
|
||||
rowKey: 'id',
|
||||
rowSelection: {
|
||||
type: 'checkbox',
|
||||
},
|
||||
},
|
||||
'x-app-version': '1.2.12-alpha',
|
||||
'x-index': 2,
|
||||
properties: {
|
||||
actions: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
title: '{{ t("Actions") }}',
|
||||
'x-action-column': 'actions',
|
||||
'x-decorator': 'TableV2.Column.ActionBar',
|
||||
'x-component': 'TableV2.Column',
|
||||
'x-toolbar': 'TableColumnSchemaToolbar',
|
||||
'x-initializer': 'table:configureItemActions',
|
||||
'x-settings': 'fieldSettings:TableColumn',
|
||||
'x-toolbar-props': {
|
||||
initializer: 'table:configureItemActions',
|
||||
},
|
||||
'x-app-version': '1.2.12-alpha',
|
||||
'x-index': 1,
|
||||
properties: {
|
||||
kw1qyuhqrnx: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-decorator': 'DndContext',
|
||||
'x-component': 'Space',
|
||||
'x-component-props': {
|
||||
split: '|',
|
||||
},
|
||||
'x-app-version': '1.2.12-alpha',
|
||||
'x-index': 1,
|
||||
properties: {
|
||||
'53cdeamnxph': {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
title: '{{ t("View") }}',
|
||||
'x-action': 'view',
|
||||
'x-toolbar': 'ActionSchemaToolbar',
|
||||
'x-settings': 'actionSettings:view',
|
||||
'x-component': 'Action.Link',
|
||||
'x-component-props': {
|
||||
openMode: 'drawer',
|
||||
},
|
||||
'x-decorator': 'ACLActionProvider',
|
||||
'x-designer-props': {
|
||||
linkageAction: true,
|
||||
},
|
||||
'x-index': 1,
|
||||
properties: {
|
||||
drawer: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
title: '{{ t("View record") }}',
|
||||
'x-component': 'Action.Container',
|
||||
'x-component-props': {
|
||||
className: 'nb-action-popup',
|
||||
},
|
||||
'x-index': 1,
|
||||
properties: {
|
||||
tabs: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Tabs',
|
||||
'x-component-props': {},
|
||||
'x-initializer': 'popup:addTab',
|
||||
'x-index': 1,
|
||||
properties: {
|
||||
tab1: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
title: '{{t("Details")}}',
|
||||
'x-component': 'Tabs.TabPane',
|
||||
'x-designer': 'Tabs.Designer',
|
||||
'x-component-props': {},
|
||||
'x-index': 1,
|
||||
properties: {
|
||||
grid: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid',
|
||||
'x-initializer': 'popup:common:addBlock',
|
||||
'x-index': 1,
|
||||
properties: {
|
||||
'1pwkkpqufg4': {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid.Row',
|
||||
'x-app-version': '1.2.12-alpha',
|
||||
'x-index': 1,
|
||||
properties: {
|
||||
'410gicqpds5': {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid.Col',
|
||||
'x-app-version': '1.2.12-alpha',
|
||||
'x-index': 1,
|
||||
properties: {
|
||||
vbb6lo1bnqc: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-decorator': 'TableBlockProvider',
|
||||
'x-acl-action': 'users.roles:list',
|
||||
'x-use-decorator-props': 'useTableBlockDecoratorProps',
|
||||
'x-decorator-props': {
|
||||
association: 'users.roles',
|
||||
dataSource: 'main',
|
||||
action: 'list',
|
||||
params: {
|
||||
pageSize: 20,
|
||||
},
|
||||
rowKey: 'name',
|
||||
showIndex: true,
|
||||
dragSort: false,
|
||||
},
|
||||
'x-toolbar': 'BlockSchemaToolbar',
|
||||
'x-settings': 'blockSettings:table',
|
||||
'x-component': 'CardItem',
|
||||
'x-filter-targets': [],
|
||||
'x-app-version': '1.2.12-alpha',
|
||||
'x-component-props': {
|
||||
title: '关系区块的模板,不能用于创建普通区块',
|
||||
},
|
||||
'x-index': 1,
|
||||
properties: {
|
||||
actions: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-initializer': 'table:configureActions',
|
||||
'x-component': 'ActionBar',
|
||||
'x-component-props': {
|
||||
style: {
|
||||
marginBottom: 'var(--nb-spacing)',
|
||||
},
|
||||
},
|
||||
'x-app-version': '1.2.12-alpha',
|
||||
'x-index': 1,
|
||||
'x-uid': '89jsznsarlc',
|
||||
'x-async': false,
|
||||
},
|
||||
'5mevwu3x22a': {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'array',
|
||||
'x-initializer': 'table:configureColumns',
|
||||
'x-component': 'TableV2',
|
||||
'x-use-component-props': 'useTableBlockProps',
|
||||
'x-component-props': {
|
||||
rowKey: 'id',
|
||||
rowSelection: {
|
||||
type: 'checkbox',
|
||||
},
|
||||
},
|
||||
'x-app-version': '1.2.12-alpha',
|
||||
'x-index': 2,
|
||||
properties: {
|
||||
actions: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
title: '{{ t("Actions") }}',
|
||||
'x-action-column': 'actions',
|
||||
'x-decorator': 'TableV2.Column.ActionBar',
|
||||
'x-component': 'TableV2.Column',
|
||||
'x-toolbar': 'TableColumnSchemaToolbar',
|
||||
'x-initializer': 'table:configureItemActions',
|
||||
'x-settings': 'fieldSettings:TableColumn',
|
||||
'x-toolbar-props': {
|
||||
initializer: 'table:configureItemActions',
|
||||
},
|
||||
'x-app-version': '1.2.12-alpha',
|
||||
'x-index': 1,
|
||||
properties: {
|
||||
lobrzqzg75z: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-decorator': 'DndContext',
|
||||
'x-component': 'Space',
|
||||
'x-component-props': {
|
||||
split: '|',
|
||||
},
|
||||
'x-app-version': '1.2.12-alpha',
|
||||
'x-index': 1,
|
||||
'x-uid': 't9lq3pqh9h1',
|
||||
'x-async': false,
|
||||
},
|
||||
},
|
||||
'x-uid': '8aph6mvtbaw',
|
||||
'x-async': false,
|
||||
},
|
||||
},
|
||||
'x-uid': '55dwvglgnmi',
|
||||
'x-async': false,
|
||||
},
|
||||
},
|
||||
'x-uid': 'mwxf08z03rr',
|
||||
'x-async': false,
|
||||
},
|
||||
},
|
||||
'x-uid': '62g2wjaszmy',
|
||||
'x-async': false,
|
||||
},
|
||||
},
|
||||
'x-uid': '6g3vj6hb2lg',
|
||||
'x-async': false,
|
||||
},
|
||||
r3lzmtigz5q: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid.Row',
|
||||
'x-app-version': '1.2.12-alpha',
|
||||
'x-index': 2,
|
||||
properties: {
|
||||
rmopf61sxaz: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid.Col',
|
||||
'x-app-version': '1.2.12-alpha',
|
||||
'x-index': 1,
|
||||
properties: {
|
||||
'03ilzp6slqk': {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-acl-action': 'users.roles:view',
|
||||
'x-decorator': 'DetailsBlockProvider',
|
||||
'x-use-decorator-props':
|
||||
'useDetailsWithPaginationDecoratorProps',
|
||||
'x-decorator-props': {
|
||||
dataSource: 'main',
|
||||
association: 'users.roles',
|
||||
readPretty: true,
|
||||
action: 'list',
|
||||
params: {
|
||||
pageSize: 1,
|
||||
},
|
||||
},
|
||||
'x-toolbar': 'BlockSchemaToolbar',
|
||||
'x-settings': 'blockSettings:detailsWithPagination',
|
||||
'x-component': 'CardItem',
|
||||
'x-app-version': '1.2.12-alpha',
|
||||
'x-component-props': {
|
||||
title:
|
||||
'关系详情区块模板,应该显示在 Current record 不显示在 Other records',
|
||||
},
|
||||
'x-index': 1,
|
||||
properties: {
|
||||
cdskpgjl62l: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Details',
|
||||
'x-read-pretty': true,
|
||||
'x-use-component-props':
|
||||
'useDetailsWithPaginationProps',
|
||||
'x-app-version': '1.2.12-alpha',
|
||||
'x-index': 1,
|
||||
properties: {
|
||||
q8kra0mo3on: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-initializer': 'details:configureActions',
|
||||
'x-component': 'ActionBar',
|
||||
'x-component-props': {
|
||||
style: {
|
||||
marginBottom: 24,
|
||||
},
|
||||
},
|
||||
'x-app-version': '1.2.12-alpha',
|
||||
'x-index': 1,
|
||||
'x-uid': 'dbcwxoi2byj',
|
||||
'x-async': false,
|
||||
},
|
||||
grid: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid',
|
||||
'x-initializer': 'details:configureFields',
|
||||
'x-app-version': '1.2.12-alpha',
|
||||
'x-index': 2,
|
||||
'x-uid': 'gb7bawzlsa3',
|
||||
'x-async': false,
|
||||
},
|
||||
pagination: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Pagination',
|
||||
'x-use-component-props':
|
||||
'useDetailsPaginationProps',
|
||||
'x-app-version': '1.2.12-alpha',
|
||||
'x-index': 3,
|
||||
'x-uid': '97u0q2xu0py',
|
||||
'x-async': false,
|
||||
},
|
||||
},
|
||||
'x-uid': 'khwmfni4kxq',
|
||||
'x-async': false,
|
||||
},
|
||||
},
|
||||
'x-uid': 'siec695mn67',
|
||||
'x-async': false,
|
||||
},
|
||||
},
|
||||
'x-uid': 'vphskdrk6yl',
|
||||
'x-async': false,
|
||||
},
|
||||
},
|
||||
'x-uid': 'vgsps35j6we',
|
||||
'x-async': false,
|
||||
},
|
||||
},
|
||||
'x-uid': '0hvmphl4vke',
|
||||
'x-async': false,
|
||||
},
|
||||
},
|
||||
'x-uid': 'zmlej955vyh',
|
||||
'x-async': false,
|
||||
},
|
||||
},
|
||||
'x-uid': '0ljl5s1wrv4',
|
||||
'x-async': false,
|
||||
},
|
||||
},
|
||||
'x-uid': 'u9dly44dmb5',
|
||||
'x-async': false,
|
||||
},
|
||||
},
|
||||
'x-uid': 'fdfbyibqlt9',
|
||||
'x-async': false,
|
||||
},
|
||||
},
|
||||
'x-uid': 'dxqtinx68eu',
|
||||
'x-async': false,
|
||||
},
|
||||
},
|
||||
'x-uid': '8quw3whqnlu',
|
||||
'x-async': false,
|
||||
},
|
||||
iejl76kjob6: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-decorator': 'TableV2.Column.Decorator',
|
||||
'x-toolbar': 'TableColumnSchemaToolbar',
|
||||
'x-settings': 'fieldSettings:TableColumn',
|
||||
'x-component': 'TableV2.Column',
|
||||
'x-app-version': '1.2.12-alpha',
|
||||
properties: {
|
||||
roles: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
'x-collection-field': 'users.roles',
|
||||
'x-component': 'CollectionField',
|
||||
'x-component-props': {
|
||||
fieldNames: {
|
||||
value: 'name',
|
||||
label: 'name',
|
||||
},
|
||||
ellipsis: true,
|
||||
size: 'small',
|
||||
},
|
||||
'x-read-pretty': true,
|
||||
'x-decorator': null,
|
||||
'x-decorator-props': {
|
||||
labelStyle: {
|
||||
display: 'none',
|
||||
},
|
||||
},
|
||||
'x-app-version': '1.2.12-alpha',
|
||||
properties: {
|
||||
'1bvhtfs19vo': {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
title: '{{ t("View record") }}',
|
||||
'x-component': 'AssociationField.Viewer',
|
||||
'x-component-props': {
|
||||
className: 'nb-action-popup',
|
||||
},
|
||||
'x-index': 1,
|
||||
'x-app-version': '1.2.12-alpha',
|
||||
properties: {
|
||||
tabs: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Tabs',
|
||||
'x-component-props': {},
|
||||
'x-initializer': 'popup:addTab',
|
||||
'x-app-version': '1.2.12-alpha',
|
||||
properties: {
|
||||
tab1: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
title: '{{t("Details")}}',
|
||||
'x-component': 'Tabs.TabPane',
|
||||
'x-designer': 'Tabs.Designer',
|
||||
'x-component-props': {},
|
||||
'x-app-version': '1.2.12-alpha',
|
||||
properties: {
|
||||
grid: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid',
|
||||
'x-initializer': 'popup:common:addBlock',
|
||||
'x-app-version': '1.2.12-alpha',
|
||||
properties: {
|
||||
'7y164ln4t02': {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid.Row',
|
||||
'x-app-version': '1.2.12-alpha',
|
||||
properties: {
|
||||
xvah1ee6t1s: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid.Col',
|
||||
'x-app-version': '1.2.12-alpha',
|
||||
properties: {
|
||||
'9s7dkj8074h': {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-acl-action': 'users.roles:get',
|
||||
'x-decorator': 'DetailsBlockProvider',
|
||||
'x-use-decorator-props': 'useDetailsDecoratorProps',
|
||||
'x-decorator-props': {
|
||||
dataSource: 'main',
|
||||
association: 'users.roles',
|
||||
readPretty: true,
|
||||
action: 'get',
|
||||
},
|
||||
'x-toolbar': 'BlockSchemaToolbar',
|
||||
'x-settings': 'blockSettings:details',
|
||||
'x-component': 'CardItem',
|
||||
'x-is-current': true,
|
||||
'x-app-version': '1.2.12-alpha',
|
||||
properties: {
|
||||
'531zk0xnik4': {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Details',
|
||||
'x-read-pretty': true,
|
||||
'x-use-component-props': 'useDetailsProps',
|
||||
'x-app-version': '1.2.12-alpha',
|
||||
properties: {
|
||||
'3omnlflcggh': {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-initializer': 'details:configureActions',
|
||||
'x-component': 'ActionBar',
|
||||
'x-component-props': {
|
||||
style: {
|
||||
marginBottom: 24,
|
||||
},
|
||||
},
|
||||
'x-app-version': '1.2.12-alpha',
|
||||
'x-uid': 'ym6lh2x98dj',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
grid: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid',
|
||||
'x-initializer': 'details:configureFields',
|
||||
'x-app-version': '1.2.12-alpha',
|
||||
'x-uid': 'qqtgr6x5ymn',
|
||||
'x-async': false,
|
||||
'x-index': 2,
|
||||
},
|
||||
},
|
||||
'x-uid': 'rb5nttjwcvw',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': 'vl2i6hfkkl8',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': 'r02zci8a2b9',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': 'h7944lifss1',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': 'folxpxboig0',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': 'lj3p0oeb0mp',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': '0tl5555ulg9',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': 'layx1foi3xz',
|
||||
'x-async': false,
|
||||
},
|
||||
},
|
||||
'x-uid': '084q5ucj2hg',
|
||||
'x-async': false,
|
||||
'x-index': 1,
|
||||
},
|
||||
},
|
||||
'x-uid': 'uag0rx0s4j3',
|
||||
'x-async': false,
|
||||
'x-index': 2,
|
||||
},
|
||||
},
|
||||
'x-uid': 'rf2ulrqfw0r',
|
||||
'x-async': false,
|
||||
},
|
||||
},
|
||||
'x-uid': 'd7c6p0kxuga',
|
||||
'x-async': false,
|
||||
},
|
||||
},
|
||||
'x-uid': 'ufl6l2izdx8',
|
||||
'x-async': false,
|
||||
},
|
||||
},
|
||||
'x-uid': 'o2nc3g5be81',
|
||||
'x-async': false,
|
||||
},
|
||||
maf7gojs1zc: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid.Row',
|
||||
'x-app-version': '1.2.12-alpha',
|
||||
'x-index': 2,
|
||||
properties: {
|
||||
'6trihtcvyik': {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-component': 'Grid.Col',
|
||||
'x-app-version': '1.2.12-alpha',
|
||||
'x-index': 1,
|
||||
properties: {
|
||||
wjj8dg4gupk: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-decorator': 'TableBlockProvider',
|
||||
'x-acl-action': 'roles:list',
|
||||
'x-use-decorator-props': 'useTableBlockDecoratorProps',
|
||||
'x-decorator-props': {
|
||||
collection: 'roles',
|
||||
dataSource: 'main',
|
||||
action: 'list',
|
||||
params: {
|
||||
pageSize: 20,
|
||||
},
|
||||
rowKey: 'name',
|
||||
showIndex: true,
|
||||
dragSort: false,
|
||||
},
|
||||
'x-toolbar': 'BlockSchemaToolbar',
|
||||
'x-settings': 'blockSettings:table',
|
||||
'x-component': 'CardItem',
|
||||
'x-filter-targets': [],
|
||||
'x-app-version': '1.2.12-alpha',
|
||||
'x-component-props': {
|
||||
title: '普通区块的模板,不能用于创建关系区块',
|
||||
},
|
||||
'x-index': 1,
|
||||
properties: {
|
||||
actions: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-initializer': 'table:configureActions',
|
||||
'x-component': 'ActionBar',
|
||||
'x-component-props': {
|
||||
style: {
|
||||
marginBottom: 'var(--nb-spacing)',
|
||||
},
|
||||
},
|
||||
'x-app-version': '1.2.12-alpha',
|
||||
'x-index': 1,
|
||||
'x-uid': '93zayim5y7t',
|
||||
'x-async': false,
|
||||
},
|
||||
'1uuqwvjlji9': {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'array',
|
||||
'x-initializer': 'table:configureColumns',
|
||||
'x-component': 'TableV2',
|
||||
'x-use-component-props': 'useTableBlockProps',
|
||||
'x-component-props': {
|
||||
rowKey: 'id',
|
||||
rowSelection: {
|
||||
type: 'checkbox',
|
||||
},
|
||||
},
|
||||
'x-app-version': '1.2.12-alpha',
|
||||
'x-index': 2,
|
||||
properties: {
|
||||
actions: {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
title: '{{ t("Actions") }}',
|
||||
'x-action-column': 'actions',
|
||||
'x-decorator': 'TableV2.Column.ActionBar',
|
||||
'x-component': 'TableV2.Column',
|
||||
'x-toolbar': 'TableColumnSchemaToolbar',
|
||||
'x-initializer': 'table:configureItemActions',
|
||||
'x-settings': 'fieldSettings:TableColumn',
|
||||
'x-toolbar-props': {
|
||||
initializer: 'table:configureItemActions',
|
||||
},
|
||||
'x-app-version': '1.2.12-alpha',
|
||||
'x-index': 1,
|
||||
properties: {
|
||||
'5n2lezgtg4q': {
|
||||
_isJSONSchemaObject: true,
|
||||
version: '2.0',
|
||||
type: 'void',
|
||||
'x-decorator': 'DndContext',
|
||||
'x-component': 'Space',
|
||||
'x-component-props': {
|
||||
split: '|',
|
||||
},
|
||||
'x-app-version': '1.2.12-alpha',
|
||||
'x-index': 1,
|
||||
'x-uid': 't9o0l4b3jjf',
|
||||
'x-async': false,
|
||||
},
|
||||
},
|
||||
'x-uid': '834ecrjnrz7',
|
||||
'x-async': false,
|
||||
},
|
||||
},
|
||||
'x-uid': '9argmfxe42w',
|
||||
'x-async': false,
|
||||
},
|
||||
},
|
||||
'x-uid': 'bakwhqmelgh',
|
||||
'x-async': false,
|
||||
},
|
||||
},
|
||||
'x-uid': 't5tifk4xmwz',
|
||||
'x-async': false,
|
||||
},
|
||||
},
|
||||
'x-uid': 'g8r6sibh2yq',
|
||||
'x-async': false,
|
||||
},
|
||||
},
|
||||
'x-uid': 'j0lfty8wr99',
|
||||
'x-async': false,
|
||||
},
|
||||
},
|
||||
'x-uid': 'mratid7w4zu',
|
||||
'x-async': true,
|
||||
},
|
||||
};
|
||||
|
||||
export const testingWithPageMode = {
|
||||
pageSchema: {
|
||||
_isJSONSchemaObject: true,
|
||||
@ -5759,6 +6542,7 @@ export const testingWithPageMode = {
|
||||
'x-index': 1,
|
||||
},
|
||||
};
|
||||
|
||||
export const testingOfOpenModeForAddChild = {
|
||||
collections: tree,
|
||||
pageSchema: {
|
||||
@ -6357,6 +7141,7 @@ export const testingOfOpenModeForAddChild = {
|
||||
'x-async': true,
|
||||
},
|
||||
};
|
||||
|
||||
export const differentURL_DifferentPopupContent = {
|
||||
pageSchema: {
|
||||
_isJSONSchemaObject: true,
|
||||
|
@ -357,6 +357,7 @@ export const DataBlockInitializer: FC<DataBlockInitializerProps> = (props) => {
|
||||
itemsFromProps ||
|
||||
// eslint-disable-next-line react-hooks/rules-of-hooks
|
||||
useCollectionDataSourceItems({
|
||||
name,
|
||||
componentName: componentType,
|
||||
filter,
|
||||
filterDataSource,
|
||||
|
@ -17,6 +17,7 @@ import {
|
||||
DataBlockInitializer,
|
||||
DataSource,
|
||||
SchemaInitializerItemType,
|
||||
useAssociationName,
|
||||
useCollection,
|
||||
useCollectionManager,
|
||||
useDataSourceKey,
|
||||
@ -842,6 +843,7 @@ export const useRecordCollectionDataSourceItems = (
|
||||
};
|
||||
|
||||
export const useCollectionDataSourceItems = ({
|
||||
name,
|
||||
componentName,
|
||||
filter = () => true,
|
||||
onlyCurrentDataSource = false,
|
||||
@ -854,7 +856,8 @@ export const useCollectionDataSourceItems = ({
|
||||
currentText,
|
||||
otherText,
|
||||
}: {
|
||||
componentName;
|
||||
name: string;
|
||||
componentName: string;
|
||||
filter?: (options: { collection?: Collection; associationField?: CollectionFieldOptions }) => boolean;
|
||||
onlyCurrentDataSource?: boolean;
|
||||
showAssociationFields?: boolean;
|
||||
@ -877,6 +880,7 @@ export const useCollectionDataSourceItems = ({
|
||||
const dataSourceKey = useDataSourceKey();
|
||||
const collection = useCollection();
|
||||
const associationFields = useAssociationFields({ componentName, filterCollections: filter, showAssociationFields });
|
||||
const association = useAssociationName();
|
||||
|
||||
let allCollections = dm.getAllCollections({
|
||||
filterCollection: (collection) => {
|
||||
@ -900,6 +904,8 @@ export const useCollectionDataSourceItems = ({
|
||||
type: 'subMenu',
|
||||
children: [
|
||||
...getChildren({
|
||||
name,
|
||||
association,
|
||||
collections,
|
||||
componentName,
|
||||
searchValue: '',
|
||||
@ -1383,6 +1389,8 @@ export const createTableBlockSchema = (options) => {
|
||||
};
|
||||
|
||||
const getChildren = ({
|
||||
name,
|
||||
association,
|
||||
collections,
|
||||
dataSource,
|
||||
componentName,
|
||||
@ -1390,6 +1398,8 @@ const getChildren = ({
|
||||
getTemplatesByCollection,
|
||||
t,
|
||||
}: {
|
||||
name: string;
|
||||
association: string;
|
||||
collections: any[];
|
||||
componentName: string;
|
||||
searchValue: string;
|
||||
@ -1422,13 +1432,21 @@ const getChildren = ({
|
||||
?.map((item, index) => {
|
||||
const title = item.title || item.tableName || item.label;
|
||||
const templates = getTemplatesByCollection(dataSource, item.name).filter((template) => {
|
||||
return (
|
||||
componentName &&
|
||||
template.componentName === componentName &&
|
||||
(['FormItem', 'ReadPrettyFormItem'].includes(componentName) ||
|
||||
!template.resourceName ||
|
||||
template.resourceName === item.name)
|
||||
);
|
||||
// 弹窗中的 Current record 选项
|
||||
const isCurrentRecordOption = name !== 'otherRecords' && association;
|
||||
|
||||
if (isCurrentRecordOption) {
|
||||
if (template.resourceName !== association) {
|
||||
return false;
|
||||
}
|
||||
return componentName && template.componentName === componentName;
|
||||
}
|
||||
|
||||
if (!isCurrentRecordOption && template?.resourceName?.includes('.')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return componentName && template.componentName === componentName;
|
||||
});
|
||||
if (!templates.length) {
|
||||
return {
|
||||
@ -1539,6 +1557,10 @@ function useAssociationFields({
|
||||
.map((field, index) => {
|
||||
const title = compile(field.uiSchema.title || field.name);
|
||||
const templates = getTemplatesByCollection(dataSource, field.target).filter((template) => {
|
||||
if (template.resourceName !== `${field.collectionName}.${field.name}`) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 针对弹窗中的详情区块
|
||||
if (componentName === 'ReadPrettyFormItem') {
|
||||
if (['hasOne', 'belongsTo'].includes(field.type)) {
|
||||
@ -1548,13 +1570,7 @@ function useAssociationFields({
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
componentName &&
|
||||
template.componentName === componentName &&
|
||||
(['FormItem', 'ReadPrettyFormItem'].includes(componentName) ||
|
||||
!template.resourceName ||
|
||||
template.resourceName === `${field.collectionName}.${field.name}`)
|
||||
);
|
||||
return template.componentName === componentName;
|
||||
});
|
||||
if (!templates.length) {
|
||||
return {
|
||||
|
Loading…
Reference in New Issue
Block a user