Merge pull request #4942 from nwind/feat-property-autovar

feat: Property 的 title 等属性支持自动变量解析 Closes #4900
This commit is contained in:
RUNZE LU 2022-07-22 11:09:13 +08:00 committed by GitHub
commit da2469c1ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 9 deletions

View File

@ -165,6 +165,7 @@ order: 60
{
"type": "page",
"data": {
"title": "title1",
"items": [
{
"label": "cpu",
@ -196,6 +197,7 @@ order: 60
},
"body": {
"type": "property",
"title": "${title}",
"source": "${items}"
}
}
@ -372,6 +374,8 @@ items 里的属性还支持 `visibleOn` 和 `hiddenOn` 表达式,能隐藏部
| column | `number` | 3 | 每行几列 |
| mode | `string` | 'table' | 显示模式,目前只有 'table' 和 'simple' |
| separator | `string` | ',' | 'simple' 模式下属性名和值之间的分隔符 |
| title | `string` | | 标题 |
| source | `string` | | 数据源 |
| items[].label | `SchemaTpl` | | 属性名 |
| items[].content | `SchemaTpl` | | 属性值 |
| items[].span | `SchemaTpl` | | 属性值跨几列 |

View File

@ -119,14 +119,7 @@ export default class Property extends React.Component<PropertyProps, object> {
*/
prepareRows() {
const {column = 3, items, source, data} = this.props;
const propertyItems =
(items
? items
: (resolveVariableAndFilter(
source,
data,
'| raw'
) as Array<PropertyItem>)) || [];
const propertyItems = items ? items : source || [];
const rows: PropertyContent[][] = [];
@ -246,6 +239,7 @@ export default class Property extends React.Component<PropertyProps, object> {
}
@Renderer({
type: 'property'
type: 'property',
autoVar: true
})
export class PropertyRenderer extends Property {}