fix(collection-manager): fix table layout

This commit is contained in:
Rairn 2023-04-23 18:28:37 +08:00
parent 25d2ebf02a
commit 683db5b3ba

View File

@ -24,11 +24,10 @@ import { OverridingCollectionField } from './OverridingCollectionField';
import { SyncFieldsAction } from './SyncFieldsAction'; import { SyncFieldsAction } from './SyncFieldsAction';
import { ViewCollectionField } from './ViewInheritedField'; import { ViewCollectionField } from './ViewInheritedField';
import { collection } from './schemas/collectionFields'; import { collection } from './schemas/collectionFields';
const CELL_WIDTH = 200;
const indentStyle = css` const indentStyle = css`
.ant-table { .ant-table {
margin-left: -7px !important; margin-left: -16px !important;
} }
`; `;
const rowStyle = css` const rowStyle = css`
@ -36,6 +35,25 @@ const rowStyle = css`
background-color: white; background-color: white;
} }
`; `;
const tableContainer = css`
tr {
display: flex;
}
td,
th {
flex: 2;
width: 0;
&:last-child {
flex: 1;
}
}
.ant-table-selection-column,
.ant-table-row-expand-icon-cell {
flex-basis: 50px !important;
min-width: 50px;
flex: 0;
}
`;
const titlePrompt = 'Default title for each record'; const titlePrompt = 'Default title for each record';
// 只有下面类型的字段才可以设置为标题字段 // 只有下面类型的字段才可以设置为标题字段
@ -67,18 +85,15 @@ const CurrentFields = (props) => {
{ {
dataIndex: 'name', dataIndex: 'name',
title: t('Field name'), title: t('Field name'),
width: CELL_WIDTH + 20,
}, },
{ {
dataIndex: 'interface', dataIndex: 'interface',
title: t('Field interface'), title: t('Field interface'),
width: CELL_WIDTH,
render: (value) => <Tag>{compile(getInterface(value)?.title)}</Tag>, render: (value) => <Tag>{compile(getInterface(value)?.title)}</Tag>,
}, },
{ {
dataIndex: 'titleField', dataIndex: 'titleField',
title: t('Title field'), title: t('Title field'),
width: CELL_WIDTH,
render: function Render(_, record) { render: function Render(_, record) {
const handleChange = (checked) => { const handleChange = (checked) => {
setLoadingRecord(record); setLoadingRecord(record);
@ -112,7 +127,6 @@ const CurrentFields = (props) => {
{ {
dataIndex: 'actions', dataIndex: 'actions',
title: t('Actions'), title: t('Actions'),
width: CELL_WIDTH,
render: (_, record) => { render: (_, record) => {
const deleteProps = { const deleteProps = {
confirm: { confirm: {
@ -177,18 +191,15 @@ const InheritFields = (props) => {
{ {
dataIndex: 'name', dataIndex: 'name',
title: t('Field name'), title: t('Field name'),
width: CELL_WIDTH + 20,
}, },
{ {
dataIndex: 'interface', dataIndex: 'interface',
title: t('Field interface'), title: t('Field interface'),
width: CELL_WIDTH,
render: (value) => <Tag>{compile(getInterface(value)?.title)}</Tag>, render: (value) => <Tag>{compile(getInterface(value)?.title)}</Tag>,
}, },
{ {
dataIndex: 'titleField', dataIndex: 'titleField',
title: t('Title field'), title: t('Title field'),
width: CELL_WIDTH,
render(_, record) { render(_, record) {
const handleChange = (checked) => { const handleChange = (checked) => {
setLoadingRecord(record); setLoadingRecord(record);
@ -222,7 +233,6 @@ const InheritFields = (props) => {
{ {
dataIndex: 'actions', dataIndex: 'actions',
title: t('Actions'), title: t('Actions'),
width: CELL_WIDTH,
render: function Render(_, record) { render: function Render(_, record) {
const overrideProps = { const overrideProps = {
type: 'primary', type: 'primary',
@ -275,34 +285,27 @@ export const CollectionFields = (props) => {
<div <div
className={css` className={css`
font-weight: 500; font-weight: 500;
white-space: nowrap;
width: 100px;
`} `}
> >
{value} {value}
</div> </div>
), ),
// width: CELL_WIDTH,
}, },
{ {
dataIndex: 'name', dataIndex: 'name',
title: t('Field name'), title: t('Field name'),
width: CELL_WIDTH + 20,
}, },
{ {
dataIndex: 'interface', dataIndex: 'interface',
title: t('Field interface'), title: t('Field interface'),
width: CELL_WIDTH,
}, },
{ {
dataIndex: 'titleField', dataIndex: 'titleField',
title: t('Title field'), title: t('Title field'),
width: CELL_WIDTH,
}, },
{ {
dataIndex: 'actions', dataIndex: 'actions',
title: t('Actions'), title: t('Actions'),
width: CELL_WIDTH,
}, },
]; ];
@ -420,6 +423,7 @@ export const CollectionFields = (props) => {
columns={columns} columns={columns}
dataSource={dataSource.filter((d) => d.fields.length)} dataSource={dataSource.filter((d) => d.fields.length)}
pagination={false} pagination={false}
className={tableContainer}
expandable={{ expandable={{
defaultExpandAllRows: true, defaultExpandAllRows: true,
expandedRowClassName: () => rowStyle, expandedRowClassName: () => rowStyle,