Commit d9b2bf8a authored by chenos's avatar chenos
Browse files

feat(client): tab icon

parent 8f64061e
tree-demo 0.7 0.7.6 Dunqing-feat-select-m2o-next auditlogs chore/error-message doc/api-database doc/db-repository doc/dev-res-action doc/new-user-manual doc/plugin-workflow doc/relation-repository example/custom-signup-page example/util examples excel-function feat/associate-operate feat/batch-operation feat/cache feat/collection-inherits feat/collection-templates feat/database feat/field-unique feat/grap-collection feat/inherit-collection feat/logger feat/plugin-file-manager feat/plugin-import feat/plugin-import-2 feat/plugin-manager-0823 feat/plugin-user-groups feat/plugin-verification feat/plugin-workflow-collection-field feat/pm feat/pnpm-support feat/reference-check feat/request-logs feat/resize-grid-columns feat/safer-update feat/submodule-graph-collection feat/tree-table-block feat/workflow-request fix/association-deleted fix/attachment-upload fix/block-select-collection-menu fix/bulk-update-db-locked fix/collection-manager-del-foreign-key fix/create-inherits fix/database-find-with-appends fix/database-view-error fix/destroy-fields-by-array fix/docker-ci fix/export-date fix/export-percent fix/form-sys-fields-default-edit-mode fix/menu-schema fix/merge-include fix/plugin-cm fix/table-data perf/cache-schema perf/token pre-release refactor/client refactor/plugin-workflow-ui rollback table-demo tree v0.8.0-alpha.13 v0.8.0-alpha.11 v0.8.0-alpha.9 v0.8.0-alpha.8 v0.8.0-alpha.7 v0.8.0-alpha.6 v0.8.0-alpha.5 v0.8.0-alpha.3 v0.8.0-alpha.2 v0.8.0-alpha.1 v0.7.7-alpha.1 v0.7.6-alpha.2 v0.7.5-alpha.1.1666403334 v0.7.5-alpha.1 v0.7.4-alpha.7 v0.7.4-alpha.4 v0.7.4-alpha.1
No related merge requests found
Showing with 36 additions and 17 deletions
+36 -17
......@@ -20,26 +20,37 @@ export const TabsDesigner = () => {
properties: {
title: {
title: t('Tab name'),
required: true,
'x-decorator': 'FormItem',
'x-component': 'Input',
'x-component-props': {},
},
icon: {
title: t('Icon'),
'x-decorator': 'FormItem',
'x-component': 'IconPicker',
'x-component-props': {},
},
},
} as ISchema
}
initialValues={{ title: field.title }}
onSubmit={({ title }) => {
if (title) {
fieldSchema.title = title;
field.title = title;
dn.emit('patch', {
schema: {
['x-uid']: fieldSchema['x-uid'],
title,
},
});
dn.refresh();
}
initialValues={{ title: field.title, icon: field.componentProps.icon }}
onSubmit={({ title, icon }) => {
const props = fieldSchema['x-component-props'] || {};
fieldSchema.title = title;
field.title = title;
props.icon = icon;
field.componentProps.icon = icon;
fieldSchema['x-component-props'] = fieldSchema['x-component-props'] || {};
fieldSchema['x-component-props'].icon = icon;
dn.emit('patch', {
schema: {
['x-uid']: fieldSchema['x-uid'],
title,
['x-component-props']: props,
},
});
dn.refresh();
}}
/>
<SchemaSettings.Divider />
......
......@@ -3,6 +3,7 @@ import { observer, RecursionField, useField, useFieldSchema } from '@formily/rea
import { TabPaneProps, Tabs as AntdTabs, TabsProps } from 'antd';
import classNames from 'classnames';
import React from 'react';
import { Icon } from '../../../icon';
import { useSchemaInitializer } from '../../../schema-initializer';
import { DndContext, SortableItem } from '../../common';
import { useDesigner } from '../../hooks/useDesigner';
......@@ -77,12 +78,12 @@ const designerCss = css`
}
`;
Tabs.TabPane = observer((props: TabPaneProps) => {
Tabs.TabPane = observer((props: TabPaneProps & { icon?: any }) => {
const Designer = useDesigner();
const field = useField();
return (
<SortableItem className={classNames('nb-action-link', designerCss, props.className)}>
{props.tab || field.title}
{props.icon && <Icon style={{ marginRight: 2 }} type={props.icon} />} {props.tab || field.title}
<Designer />
</SortableItem>
);
......
......@@ -13,13 +13,15 @@ export const TabPaneInitializers = () => {
return {
async run() {
await form.submit();
const { title } = form.values;
const { title, icon } = form.values;
insertBeforeEnd({
type: 'void',
title,
'x-component': 'Tabs.TabPane',
'x-designer': 'Tabs.Designer',
'x-component-props': {},
'x-component-props': {
icon,
},
properties: {
grid: {
type: 'void',
......@@ -67,6 +69,11 @@ export const TabPaneInitializers = () => {
'x-component': 'Input',
'x-decorator': 'FormItem',
},
icon: {
title: '{{t("Icon")}}',
'x-component': 'IconPicker',
'x-decorator': 'FormItem',
},
footer: {
'x-component': 'Action.Modal.Footer',
type: 'void',
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment