Skip to content

Commit

Permalink
Merge pull request #1471 from alibaba/emptyOnly
Browse files Browse the repository at this point in the history
feat: 修改字段名称 hideEmptyTable
  • Loading branch information
lhbxs authored Jan 24, 2024
2 parents 618bc0e + 789a791 commit d9027aa
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 14 deletions.
3 changes: 3 additions & 0 deletions packages/form-render/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# 更新日志

### 2.3.9
- [+] TableList 增加 hideEmptyTable 属性

### 2.3.8
- [!] 修复 schema 多层嵌套下,getSchemaByPath 获取异常

Expand Down
2 changes: 1 addition & 1 deletion packages/form-render/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "form-render",
"version": "2.3.8",
"version": "2.3.9",
"description": "通过 JSON Schema 生成标准 Form,常用于自定义搭建配置界面生成",
"keywords": [
"Form",
Expand Down
7 changes: 3 additions & 4 deletions packages/form-render/src/widgets/listTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ interface ListTableProps {
/*
* 没有数据时是否隐藏表格
*/
hideTableWhenNoData?: boolean;
hideEmptyTable?: boolean;
[key: string]: any;
};

Expand Down Expand Up @@ -61,8 +61,7 @@ const TableList: React.FC<ListTableProps> = (props) => {
hideMove,
hideAdd,
hideOperate,
hideTableWhenNoData,

hideEmptyTable,
addItem,
copyItem,
moveItem,
Expand Down Expand Up @@ -188,7 +187,7 @@ const TableList: React.FC<ListTableProps> = (props) => {
});
}

const showTable = fields.length > 0 ? true : !hideTableWhenNoData;
const showTable = fields.length > 0 ? true : !hideEmptyTable;

return (
<div className={classnames('fr-table-list', { 'fr-table-list-no-popover': !islidatePopover })}>
Expand Down
27 changes: 18 additions & 9 deletions packages/form-render/src/widgets/listVirtual/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ interface ListVirtualProps {
delConfirmProps: any;
renderCore: any;
rootPath: any;
/*
* 没有数据时是否隐藏表格
*/
hideEmptyTable?: boolean;
[key: string]: any;
};

Expand Down Expand Up @@ -58,6 +62,7 @@ const VirtualList: React.FC<ListVirtualProps> = (props) => {
hideMove,
hideAdd,
hideOperate,
hideEmptyTable,

addItem,
copyItem,
Expand Down Expand Up @@ -180,17 +185,21 @@ const VirtualList: React.FC<ListVirtualProps> = (props) => {
});
}

const showTable = fields.length > 0 ? true : !hideEmptyTable;

return (
<>
<Table
className={classnames('fr-virtual-list', { 'fr-virtual-list-no-popover': !islidatePopover })}
size='middle'
columns={columns}
dataSource={fields}
pagination={false}
scroll={{ y: scrollY }}
components={vt}
/>
{showTable && (
<Table
className={classnames('fr-virtual-list', { 'fr-virtual-list-no-popover': !islidatePopover })}
size='middle'
columns={columns}
dataSource={fields}
pagination={false}
scroll={{ y: scrollY }}
components={vt}
/>
)}
{(!schema.max || fields.length < schema.max) && !hideAdd && (
<Button
icon={<PlusOutlined />}
Expand Down

0 comments on commit d9027aa

Please sign in to comment.