mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-07-02 03:02:19 +08:00
fix: save as template not working if fields containing nest properties (#6543)
* fix: save as template not working if fields containing nest properties * fix: hide old blocks save as template * fix: unit tests failing * fix: unit tests for hiding old save template option * fix: unit test failing for save as template
This commit is contained in:
parent
befdd5366c
commit
aa51c693d6
@ -50,7 +50,7 @@ describe('CollectionSelect', () => {
|
|||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
aria-label="block-item-demo title"
|
aria-label="block-item-demo title"
|
||||||
class="nb-block-item nb-form-item css-9qorhu ant-nb-block-item css-dev-only-do-not-override-11aiz3o"
|
class="nb-block-item nb-form-item css-9qorhu ant-nb-block-item css-dev-only-do-not-override-1rquknz"
|
||||||
role="button"
|
role="button"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
@ -191,7 +191,7 @@ describe('CollectionSelect', () => {
|
|||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
aria-label="block-item-demo title"
|
aria-label="block-item-demo title"
|
||||||
class="nb-block-item nb-form-item css-9qorhu ant-nb-block-item css-dev-only-do-not-override-11aiz3o"
|
class="nb-block-item nb-form-item css-9qorhu ant-nb-block-item css-dev-only-do-not-override-1rquknz"
|
||||||
role="button"
|
role="button"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
|
@ -343,14 +343,14 @@ export const TableBlockDesigner = () => {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<SchemaSettingsConnectDataBlocks type={FilterBlockType.TABLE} emptyDescription={t('No blocks to connect')} />
|
<SchemaSettingsConnectDataBlocks type={FilterBlockType.TABLE} emptyDescription={t('No blocks to connect')} />
|
||||||
{supportTemplate && <SchemaSettingsDivider />}
|
{/* {supportTemplate && <SchemaSettingsDivider />}
|
||||||
{supportTemplate && (
|
{supportTemplate && (
|
||||||
<SchemaSettingsTemplate
|
<SchemaSettingsTemplate
|
||||||
componentName={`${componentNamePrefix}Table`}
|
componentName={`${componentNamePrefix}Table`}
|
||||||
collectionName={name}
|
collectionName={name}
|
||||||
resourceName={defaultResource}
|
resourceName={defaultResource}
|
||||||
/>
|
/>
|
||||||
)}
|
)} */}
|
||||||
<SchemaSettingsDivider />
|
<SchemaSettingsDivider />
|
||||||
<SchemaSettingsRemove
|
<SchemaSettingsRemove
|
||||||
removeParentsIfNoChildren
|
removeParentsIfNoChildren
|
||||||
|
@ -233,10 +233,10 @@ describe('Table.settings', () => {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
// {
|
||||||
title: 'Save as template',
|
// title: 'Save as template',
|
||||||
type: 'modal',
|
// type: 'modal',
|
||||||
},
|
// },
|
||||||
{
|
{
|
||||||
title: 'Delete',
|
title: 'Delete',
|
||||||
type: 'delete',
|
type: 'delete',
|
||||||
@ -299,7 +299,12 @@ describe('Table.settings', () => {
|
|||||||
|
|
||||||
test('menu list', async () => {
|
test('menu list', async () => {
|
||||||
await renderSettings(getRenderSettingsOptions());
|
await renderSettings(getRenderSettingsOptions());
|
||||||
await checkTableSettings();
|
await checkTableSettings([
|
||||||
|
{
|
||||||
|
title: 'Save as template',
|
||||||
|
type: 'modal',
|
||||||
|
},
|
||||||
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('old schema', async () => {
|
test('old schema', async () => {
|
||||||
|
@ -23,7 +23,7 @@ import { useLocation } from 'react-router-dom';
|
|||||||
|
|
||||||
const blockDecoratorMenuMaps = {
|
const blockDecoratorMenuMaps = {
|
||||||
TableBlockProvider: ['Table', 'table'],
|
TableBlockProvider: ['Table', 'table'],
|
||||||
FormBlockProvider: ['Form', 'form'],
|
FormBlockProvider: ['FormItem', 'form'],
|
||||||
DetailsBlockProvider: ['Details', 'details'],
|
DetailsBlockProvider: ['Details', 'details'],
|
||||||
'List.Decorator': ['List', 'list'],
|
'List.Decorator': ['List', 'list'],
|
||||||
'GridCard.Decorator': ['GridCard', 'gridCard'],
|
'GridCard.Decorator': ['GridCard', 'gridCard'],
|
||||||
@ -281,6 +281,7 @@ function getTemplateSchemaFromPage(schema: ISchema) {
|
|||||||
if (s['x-template-root-uid']) {
|
if (s['x-template-root-uid']) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
t = t || {};
|
||||||
_.merge(t, _.omit(s, ['x-uid', 'properties']));
|
_.merge(t, _.omit(s, ['x-uid', 'properties']));
|
||||||
t['x-uid'] = uid();
|
t['x-uid'] = uid();
|
||||||
if (s.properties) {
|
if (s.properties) {
|
||||||
@ -288,7 +289,7 @@ function getTemplateSchemaFromPage(schema: ISchema) {
|
|||||||
if (s.properties[key]['x-template-root-uid']) {
|
if (s.properties[key]['x-template-root-uid']) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
_.set(t, `properties.${key}`, {});
|
_.set(t, `properties.['${key}']`, {});
|
||||||
traverseSchema(s.properties[key], t.properties[key]);
|
traverseSchema(s.properties[key], t.properties[key]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -169,6 +169,9 @@ export class PluginBlockTemplateClient extends Plugin {
|
|||||||
'blockSettings:createForm',
|
'blockSettings:createForm',
|
||||||
'blockSettings:details',
|
'blockSettings:details',
|
||||||
'blockSettings:detailsWithPagination',
|
'blockSettings:detailsWithPagination',
|
||||||
|
'blockSettings:multiDataDetails',
|
||||||
|
'blockSettings:singleDataDetails',
|
||||||
|
'blockSettings:stepsForm',
|
||||||
'blockSettings:filterCollapse',
|
'blockSettings:filterCollapse',
|
||||||
'blockSettings:filterForm',
|
'blockSettings:filterForm',
|
||||||
'blockSettings:gantt',
|
'blockSettings:gantt',
|
||||||
@ -176,6 +179,13 @@ export class PluginBlockTemplateClient extends Plugin {
|
|||||||
'blockSettings:kanban',
|
'blockSettings:kanban',
|
||||||
'blockSettings:list',
|
'blockSettings:list',
|
||||||
'blockSettings:table',
|
'blockSettings:table',
|
||||||
|
'blockSettings:tree',
|
||||||
|
'ReadPrettyFormSettings',
|
||||||
|
'GanttBlockSettings',
|
||||||
|
'FormV1Settings',
|
||||||
|
'FormSettings',
|
||||||
|
'FormItemSettings',
|
||||||
|
'FormDetailsSettings',
|
||||||
];
|
];
|
||||||
if (blockSettings.includes(key)) {
|
if (blockSettings.includes(key)) {
|
||||||
// schemaSetting.add('template-saveAsTemplateItem', saveAsTemplateSetting);
|
// schemaSetting.add('template-saveAsTemplateItem', saveAsTemplateSetting);
|
||||||
|
@ -154,8 +154,12 @@ export function formSchemaPatch(currentSchema: ISchema, options?: any) {
|
|||||||
return key !== 'grid';
|
return key !== 'grid';
|
||||||
});
|
});
|
||||||
if (actionKey) {
|
if (actionKey) {
|
||||||
_.set(currentSchema, `properties.${comKey}.x-use-component-props`, 'useEditFormBlockProps');
|
_.set(currentSchema, `properties.['${comKey}'].x-use-component-props`, 'useEditFormBlockProps');
|
||||||
_.set(currentSchema, `properties.${comKey}.properties.${actionKey}.x-initializer`, 'editForm:configureActions');
|
_.set(
|
||||||
|
currentSchema,
|
||||||
|
`properties.['${comKey}'].properties.['${actionKey}'].x-initializer`,
|
||||||
|
'editForm:configureActions',
|
||||||
|
);
|
||||||
|
|
||||||
const actionBarSchema = _.get(currentSchema, `properties.${comKey}.properties.${actionKey}.properties`, {});
|
const actionBarSchema = _.get(currentSchema, `properties.${comKey}.properties.${actionKey}.properties`, {});
|
||||||
for (const key in actionBarSchema) {
|
for (const key in actionBarSchema) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user