fix(client): tab pane initializers for create form block
This commit is contained in:
parent
ca2a6fecf0
commit
929a4f848a
@ -1,8 +1,8 @@
|
|||||||
import { useForm } from '@formily/react';
|
import { useForm } from '@formily/react';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { SchemaComponent, useActionContext, useDesignable } from '../..';
|
import { SchemaComponent, useActionContext, useDesignable, useRecordIndex } from '../..';
|
||||||
|
|
||||||
export const TabPaneInitializers = () => {
|
export const TabPaneInitializers = (props?: any) => {
|
||||||
const { designable, insertBeforeEnd } = useDesignable();
|
const { designable, insertBeforeEnd } = useDesignable();
|
||||||
if (!designable) {
|
if (!designable) {
|
||||||
return null;
|
return null;
|
||||||
@ -10,6 +10,7 @@ export const TabPaneInitializers = () => {
|
|||||||
const useSubmitAction = () => {
|
const useSubmitAction = () => {
|
||||||
const form = useForm();
|
const form = useForm();
|
||||||
const ctx = useActionContext();
|
const ctx = useActionContext();
|
||||||
|
const index = useRecordIndex();
|
||||||
return {
|
return {
|
||||||
async run() {
|
async run() {
|
||||||
await form.submit();
|
await form.submit();
|
||||||
@ -26,7 +27,8 @@ export const TabPaneInitializers = () => {
|
|||||||
grid: {
|
grid: {
|
||||||
type: 'void',
|
type: 'void',
|
||||||
'x-component': 'Grid',
|
'x-component': 'Grid',
|
||||||
'x-initializer': 'RecordBlockInitializers',
|
'x-initializer':
|
||||||
|
props.isCreate || index === null ? 'CreateFormBlockInitializers' : 'RecordBlockInitializers',
|
||||||
properties: {},
|
properties: {},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -111,3 +113,7 @@ export const TabPaneInitializers = () => {
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const TabPaneInitializersForCreateFormBlock = () => {
|
||||||
|
return <TabPaneInitializers isCreate />;
|
||||||
|
};
|
||||||
|
@ -16,3 +16,4 @@ export * from './TableActionInitializers';
|
|||||||
export * from './TableColumnInitializers';
|
export * from './TableColumnInitializers';
|
||||||
export * from './TableSelectorInitializers';
|
export * from './TableSelectorInitializers';
|
||||||
export * from './TabPaneInitializers';
|
export * from './TabPaneInitializers';
|
||||||
|
|
||||||
|
@ -1,46 +1,45 @@
|
|||||||
import React from "react";
|
import React from 'react';
|
||||||
import { ActionInitializer } from "./ActionInitializer";
|
import { ActionInitializer } from './ActionInitializer';
|
||||||
|
|
||||||
export const CreateActionInitializer = (props) => {
|
export const CreateActionInitializer = (props) => {
|
||||||
const schema = {
|
const schema = {
|
||||||
type: 'void',
|
type: 'void',
|
||||||
title: '{{ t("Add new") }}',
|
title: '{{ t("Add new") }}',
|
||||||
'x-action': 'create',
|
'x-action': 'create',
|
||||||
'x-designer': 'Action.Designer',
|
'x-designer': 'Action.Designer',
|
||||||
'x-component': 'Action',
|
'x-component': 'Action',
|
||||||
'x-component-props': {
|
'x-component-props': {
|
||||||
icon: 'PlusOutlined',
|
icon: 'PlusOutlined',
|
||||||
openMode: 'drawer',
|
openMode: 'drawer',
|
||||||
type: 'primary',
|
type: 'primary',
|
||||||
},
|
},
|
||||||
properties: {
|
properties: {
|
||||||
drawer: {
|
drawer: {
|
||||||
type: 'void',
|
type: 'void',
|
||||||
title: '{{ t("Add record") }}',
|
title: '{{ t("Add record") }}',
|
||||||
'x-component': 'Action.Container',
|
'x-component': 'Action.Container',
|
||||||
'x-component-props': {
|
'x-component-props': {
|
||||||
className: 'nb-action-popup',
|
className: 'nb-action-popup',
|
||||||
},
|
},
|
||||||
properties: {
|
properties: {
|
||||||
tabs: {
|
tabs: {
|
||||||
type: 'void',
|
type: 'void',
|
||||||
'x-component': 'Tabs',
|
'x-component': 'Tabs',
|
||||||
'x-component-props': {},
|
'x-component-props': {},
|
||||||
'x-initializer': 'TabPaneInitializers',
|
'x-initializer': 'TabPaneInitializersForCreateFormBlock',
|
||||||
properties: {
|
properties: {
|
||||||
tab1: {
|
tab1: {
|
||||||
type: 'void',
|
type: 'void',
|
||||||
title: '{{t("Add new")}}',
|
title: '{{t("Add new")}}',
|
||||||
'x-component': 'Tabs.TabPane',
|
'x-component': 'Tabs.TabPane',
|
||||||
'x-designer': 'Tabs.Designer',
|
'x-designer': 'Tabs.Designer',
|
||||||
'x-component-props': {},
|
'x-component-props': {},
|
||||||
properties: {
|
properties: {
|
||||||
grid: {
|
grid: {
|
||||||
type: 'void',
|
type: 'void',
|
||||||
'x-component': 'Grid',
|
'x-component': 'Grid',
|
||||||
'x-initializer': 'CreateFormBlockInitializers',
|
'x-initializer': 'CreateFormBlockInitializers',
|
||||||
properties: {},
|
properties: {},
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -48,6 +47,7 @@ export const CreateActionInitializer = (props) => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
},
|
||||||
return <ActionInitializer {...props} schema={schema} />;
|
|
||||||
};
|
};
|
||||||
|
return <ActionInitializer {...props} schema={schema} />;
|
||||||
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user