mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 11:26:55 +00:00
fix(Calendar): ensur to get correct gridInitializer when adding a new… (#1425)
* fix(Calendar): ensur to get correct gridInitializer when adding a new tab (#1241) * perf: use useMemo
This commit is contained in:
parent
c68caf105e
commit
9ada0e37d6
@ -1,5 +1,5 @@
|
|||||||
import { useForm } from '@formily/react';
|
import { useForm } from '@formily/react';
|
||||||
import React from 'react';
|
import React, { useMemo } from 'react';
|
||||||
import { SchemaComponent, useActionContext, useDesignable, useRecordIndex } from '../..';
|
import { SchemaComponent, useActionContext, useDesignable, useRecordIndex } from '../..';
|
||||||
|
|
||||||
export const TabPaneInitializers = (props?: any) => {
|
export const TabPaneInitializers = (props?: any) => {
|
||||||
@ -46,69 +46,67 @@ export const TabPaneInitializers = (props?: any) => {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
return (
|
const schema = useMemo(() => {
|
||||||
<SchemaComponent
|
return {
|
||||||
schema={{
|
type: 'void',
|
||||||
type: 'void',
|
properties: {
|
||||||
properties: {
|
action1: {
|
||||||
action1: {
|
type: 'void',
|
||||||
type: 'void',
|
'x-component': 'Action',
|
||||||
'x-component': 'Action',
|
'x-component-props': {
|
||||||
'x-component-props': {
|
icon: 'PlusOutlined',
|
||||||
icon: 'PlusOutlined',
|
style: {
|
||||||
style: {
|
borderColor: 'rgb(241, 139, 98)',
|
||||||
borderColor: 'rgb(241, 139, 98)',
|
color: 'rgb(241, 139, 98)',
|
||||||
color: 'rgb(241, 139, 98)',
|
|
||||||
},
|
|
||||||
type: 'dashed',
|
|
||||||
},
|
},
|
||||||
title: '{{t("Add tab")}}',
|
type: 'dashed',
|
||||||
properties: {
|
},
|
||||||
drawer1: {
|
title: '{{t("Add tab")}}',
|
||||||
'x-decorator': 'Form',
|
properties: {
|
||||||
'x-component': 'Action.Modal',
|
drawer1: {
|
||||||
'x-component-props': {
|
'x-decorator': 'Form',
|
||||||
width: 520,
|
'x-component': 'Action.Modal',
|
||||||
|
'x-component-props': {
|
||||||
|
width: 520,
|
||||||
|
},
|
||||||
|
type: 'void',
|
||||||
|
title: '{{t("Add tab")}}',
|
||||||
|
properties: {
|
||||||
|
title: {
|
||||||
|
title: '{{t("Tab name")}}',
|
||||||
|
required: true,
|
||||||
|
'x-component': 'Input',
|
||||||
|
'x-decorator': 'FormItem',
|
||||||
},
|
},
|
||||||
type: 'void',
|
icon: {
|
||||||
title: '{{t("Add tab")}}',
|
title: '{{t("Icon")}}',
|
||||||
properties: {
|
'x-component': 'IconPicker',
|
||||||
title: {
|
'x-decorator': 'FormItem',
|
||||||
title: '{{t("Tab name")}}',
|
},
|
||||||
required: true,
|
footer: {
|
||||||
'x-component': 'Input',
|
'x-component': 'Action.Modal.Footer',
|
||||||
'x-decorator': 'FormItem',
|
type: 'void',
|
||||||
},
|
properties: {
|
||||||
icon: {
|
cancel: {
|
||||||
title: '{{t("Icon")}}',
|
title: '{{t("Cancel")}}',
|
||||||
'x-component': 'IconPicker',
|
'x-component': 'Action',
|
||||||
'x-decorator': 'FormItem',
|
'x-component-props': {
|
||||||
},
|
useAction: () => {
|
||||||
footer: {
|
const ctx = useActionContext();
|
||||||
'x-component': 'Action.Modal.Footer',
|
return {
|
||||||
type: 'void',
|
async run() {
|
||||||
properties: {
|
ctx.setVisible(false);
|
||||||
cancel: {
|
},
|
||||||
title: '{{t("Cancel")}}',
|
};
|
||||||
'x-component': 'Action',
|
|
||||||
'x-component-props': {
|
|
||||||
useAction: () => {
|
|
||||||
const ctx = useActionContext();
|
|
||||||
return {
|
|
||||||
async run() {
|
|
||||||
ctx.setVisible(false);
|
|
||||||
},
|
|
||||||
};
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
submit: {
|
},
|
||||||
title: '{{t("Submit")}}',
|
submit: {
|
||||||
'x-component': 'Action',
|
title: '{{t("Submit")}}',
|
||||||
'x-component-props': {
|
'x-component': 'Action',
|
||||||
type: 'primary',
|
'x-component-props': {
|
||||||
useAction: useSubmitAction,
|
type: 'primary',
|
||||||
},
|
useAction: useSubmitAction,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -117,9 +115,10 @@ export const TabPaneInitializers = (props?: any) => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}}
|
},
|
||||||
/>
|
};
|
||||||
);
|
}, []);
|
||||||
|
return <SchemaComponent schema={schema} />;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const TabPaneInitializersForCreateFormBlock = (props) => {
|
export const TabPaneInitializersForCreateFormBlock = (props) => {
|
||||||
|
@ -1008,6 +1008,9 @@ export const createCalendarBlockSchema = (options) => {
|
|||||||
'x-component': 'Tabs',
|
'x-component': 'Tabs',
|
||||||
'x-component-props': {},
|
'x-component-props': {},
|
||||||
'x-initializer': 'TabPaneInitializers',
|
'x-initializer': 'TabPaneInitializers',
|
||||||
|
'x-initializer-props': {
|
||||||
|
gridInitializer: 'RecordBlockInitializers',
|
||||||
|
},
|
||||||
properties: {
|
properties: {
|
||||||
tab1: {
|
tab1: {
|
||||||
type: 'void',
|
type: 'void',
|
||||||
|
Loading…
Reference in New Issue
Block a user