Skip to content

Commit 6df7c38

Browse files
authoredAug 25, 2022
feat(form): add hide property (#1516)
1 parent facc48c commit 6df7c38

File tree

3 files changed

+40
-15
lines changed

3 files changed

+40
-15
lines changed
 

‎packages/form/src/schema/index.ts

+7
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ export interface SFSchemaEnum {
3636
*/
3737
group?: boolean;
3838

39+
/**
40+
* Whether to hide item
41+
*
42+
* 是否隐藏项
43+
*/
44+
hide?: boolean;
45+
3946
isLeaf?: boolean;
4047

4148
/** 组对应的子类 */

‎packages/form/src/widgets/select/demo/simple.md

+25-14
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,17 @@ Simplest of usage.
1515

1616
```ts
1717
import { Component, ViewChild } from '@angular/core';
18+
import { of, delay } from 'rxjs';
19+
1820
import { SFComponent, SFSchema, SFSelectWidgetSchema } from '@delon/form';
1921
import { NzMessageService } from 'ng-zorro-antd/message';
20-
import { of, delay } from 'rxjs';
2122

2223
@Component({
2324
selector: 'app-demo',
2425
template: `
2526
<sf #sf [schema]="schema" (formSubmit)="submit($event)"></sf>
2627
<button nz-button (click)="updateStatus()">Update Status</button>
27-
`,
28+
`
2829
})
2930
export class DemoComponent {
3031
@ViewChild('sf', { static: false }) private sf!: SFComponent;
@@ -36,13 +37,13 @@ export class DemoComponent {
3637
enum: [
3738
{ label: '待支付', value: 'WAIT_BUYER_PAY', otherData: 1 },
3839
{ label: '已支付', value: 'TRADE_SUCCESS' },
39-
{ label: '交易完成', value: 'TRADE_FINISHED' },
40+
{ label: '交易完成', value: 'TRADE_FINISHED' }
4041
],
4142
default: 'WAIT_BUYER_PAY',
4243
ui: {
4344
widget: 'select',
44-
change: (value, orgData) => console.log(value, orgData),
45-
} as SFSelectWidgetSchema,
45+
change: (value, orgData) => console.log(value, orgData)
46+
} as SFSelectWidgetSchema
4647
},
4748
// 标签
4849
tags: {
@@ -51,13 +52,13 @@ export class DemoComponent {
5152
enum: [
5253
{ label: '待支付', value: 'WAIT_BUYER_PAY' },
5354
{ label: '已支付', value: 'TRADE_SUCCESS' },
54-
{ label: '交易完成', value: 'TRADE_FINISHED' },
55+
{ label: '交易完成', value: 'TRADE_FINISHED' }
5556
],
5657
ui: {
5758
widget: 'select',
58-
mode: 'tags',
59+
mode: 'tags'
5960
} as SFSelectWidgetSchema,
60-
default: null,
61+
default: null
6162
},
6263
// 异步数据
6364
async: {
@@ -74,13 +75,23 @@ export class DemoComponent {
7475
children: [
7576
{ label: '待支付', value: 'WAIT_BUYER_PAY' },
7677
{ label: '已支付', value: 'TRADE_SUCCESS' },
77-
{ label: '交易完成', value: 'TRADE_FINISHED' },
78-
],
79-
},
80-
]).pipe(delay(1200)),
81-
} as SFSelectWidgetSchema,
78+
{ label: '交易完成', value: 'TRADE_FINISHED' }
79+
]
80+
}
81+
]).pipe(delay(1200))
82+
} as SFSelectWidgetSchema
8283
},
83-
},
84+
hide: {
85+
type: 'string',
86+
title: '隐藏项',
87+
enum: [
88+
{ label: '第1个', value: 1 },
89+
{ label: '第2个', value: 2, hide: true },
90+
{ label: '第3个(第2个被隐藏了)', value: 3 }
91+
],
92+
default: 1
93+
}
94+
}
8495
};
8596

8697
constructor(private msg: NzMessageService) {}

‎packages/form/src/widgets/select/select.widget.html

+8-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,13 @@
3636
(nzScrollToBottom)="scrollToBottom()"
3737
>
3838
<ng-container *ngIf="!loading && !hasGroup">
39-
<nz-option *ngFor="let o of data" [nzLabel]="o.label" [nzValue]="o.value" [nzDisabled]="o.disabled"></nz-option>
39+
<nz-option
40+
*ngFor="let o of data"
41+
[nzLabel]="o.label"
42+
[nzValue]="o.value"
43+
[nzHide]="o.hide"
44+
[nzDisabled]="o.disabled"
45+
></nz-option>
4046
</ng-container>
4147
<ng-container *ngIf="!loading && hasGroup">
4248
<nz-option-group *ngFor="let i of data" [nzLabel]="i.label">
@@ -45,6 +51,7 @@
4551
[nzLabel]="o.label"
4652
[nzValue]="o.value"
4753
[nzDisabled]="o.disabled"
54+
[nzHide]="o.hide"
4855
></nz-option>
4956
</nz-option-group>
5057
</ng-container>

0 commit comments

Comments
 (0)
Please sign in to comment.