Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(form:select): update demo #1851

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 32 additions & 12 deletions packages/form/src/widgets/select/demo/simple.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,26 @@ import { NzMessageService } from 'ng-zorro-antd/message';
template: `
<sf #sf [schema]="schema" (formSubmit)="submit($event)" />
<button nz-button (click)="updateStatus()">Update Status</button>
<button nz-button (click)="updateAsyncData()">Update async data</button>
`,
standalone: true,
imports: [DelonFormModule, NzButtonModule]
})
export class DemoComponent {
private readonly msg = inject(NzMessageService);
@ViewChild('sf', { static: false }) private sf!: SFComponent;
asyncData = [
{
label: '订单状态',
group: true,
children: [
{ label: '待支付', value: 'WAIT_BUYER_PAY' },
{ label: '已支付', value: 'TRADE_SUCCESS' },
{ label: '交易完成', value: 'TRADE_FINISHED' }
]
}
];
delay = 1200;
schema: SFSchema = {
properties: {
status: {
Expand Down Expand Up @@ -71,18 +84,7 @@ export class DemoComponent {
default: 'WAIT_BUYER_PAY',
ui: {
widget: 'select',
asyncData: () =>
of([
{
label: '订单状态',
group: true,
children: [
{ label: '待支付', value: 'WAIT_BUYER_PAY' },
{ label: '已支付', value: 'TRADE_SUCCESS' },
{ label: '交易完成', value: 'TRADE_FINISHED' }
]
}
]).pipe(delay(1200))
asyncData: () => of(this.asyncData).pipe(delay(this.delay))
} as SFSelectWidgetSchema
},
hide: {
Expand All @@ -107,5 +109,23 @@ export class DemoComponent {
statusProperty.schema.enum = ['1', '2', '3'];
statusProperty.widget.reset('2');
}

updateAsyncData(): void {
this.delay = 0;
this.asyncData = [
{
label: 'Order Status',
group: true,
children: [
{ label: 'Wait buyer pay', value: 'WAIT_BUYER_PAY' },
{ label: 'Trade success', value: 'TRADE_SUCCESS' },
{ label: 'Trade finished', value: 'TRADE_FINISHED' }
]
}
];
// Reset the value to make the element load data again
const updatePath = '/async';
this.sf.setValue(updatePath, this.sf.getProperty(updatePath)?.value);
}
}
```
Loading