-
Notifications
You must be signed in to change notification settings - Fork 672
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: merge branch 'master' into perf-standalone-self
- Loading branch information
Showing
25 changed files
with
358 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
title: acl | ||
subtitle: ACL | ||
type: Examples | ||
--- | ||
|
||
Combined with `@delon/acl` permissions, a Schema can be used to build forms for different roles or permission points. |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
--- | ||
title: | ||
zh-CN: 基础样例 | ||
en-US: Basic Usage | ||
order: 0 | ||
--- | ||
|
||
## zh-CN | ||
|
||
最简单的用法。 | ||
|
||
## en-US | ||
|
||
Simplest of usage. | ||
|
||
```ts | ||
import { Component, DestroyRef, ViewChild, inject } from '@angular/core'; | ||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; | ||
import { timer } from 'rxjs'; | ||
|
||
import { DelonFormModule, SFComponent, SFSchema } from '@delon/form'; | ||
import { NzButtonModule } from 'ng-zorro-antd/button'; | ||
import { NzMessageService } from 'ng-zorro-antd/message'; | ||
|
||
@Component({ | ||
selector: 'app-demo', | ||
template: ` | ||
<p class="mb-md"> | ||
<button nz-button (click)="getUserNameValue()">Get userName value</button> | ||
<button nz-button (click)="modifyUserNameValue()">Modify userName value</button> | ||
<button nz-button (click)="toggleUserNameRequired()">Toggle userName required</button> | ||
<button nz-button (click)="toggleUserNameDisabled()">Toggle userName disabled</button> | ||
<button nz-button (click)="triggerUserNameAsyncStatus()">userName async status</button> | ||
</p> | ||
<sf #sf [schema]="schema" (formSubmit)="submit($event)" /> | ||
`, | ||
standalone: true, | ||
imports: [DelonFormModule, NzButtonModule] | ||
}) | ||
export class DemoComponent { | ||
@ViewChild('sf') private readonly sf!: SFComponent; | ||
private readonly msg = inject(NzMessageService); | ||
private readonly d$ = inject(DestroyRef); | ||
schema: SFSchema = { | ||
properties: { | ||
userName: { type: 'string', title: '用户名' }, | ||
pwd: { type: 'string', title: '密码' } | ||
}, | ||
required: ['userName', 'pwd'] | ||
}; | ||
|
||
private get userNameRequired(): boolean { | ||
return (this.sf.getProperty('/userName')?.parent?.schema.required ?? []).includes('userName'); | ||
} | ||
|
||
private get userNameDisabled(): boolean { | ||
return this.sf.getProperty('/userName')?.schema?.readOnly === true; | ||
} | ||
|
||
toggleUserNameRequired(): void { | ||
this.sf.setRequired(`/userName`, !this.userNameRequired); | ||
} | ||
|
||
toggleUserNameDisabled(): void { | ||
this.sf.setDisabled(`/userName`, !this.userNameDisabled); | ||
} | ||
|
||
modifyUserNameValue(): void { | ||
this.sf.setValue(`/userName`, `Mock text ${+new Date()}`); | ||
} | ||
|
||
getUserNameValue(): void { | ||
this.msg.info(this.sf.getValue('/userName')); | ||
} | ||
|
||
triggerUserNameAsyncStatus(): void { | ||
this.sf.updateFeedback('/userName', 'validating'); | ||
timer(1000 * 2) | ||
.pipe(takeUntilDestroyed(this.d$)) | ||
.subscribe(() => { | ||
this.sf.updateFeedback('/userName', 'success'); | ||
}); | ||
} | ||
|
||
submit(value: {}): void { | ||
this.msg.success(JSON.stringify(value)); | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
title: method | ||
subtitle: Built-in methods | ||
type: Examples | ||
--- | ||
|
||
`SFComponent` provides some shortcut methods, such as: `setValue`, `setDisabled`, `setRequired`, etc. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
title: method | ||
subtitle: 内置方法 | ||
type: Examples | ||
--- | ||
|
||
`SFComponent` 提供一些快捷方法,例如:`setValue`、`setDisabled`、`setRequired` 等 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- | ||
title: modal | ||
subtitle: Modal | ||
type: Examples | ||
--- | ||
|
||
Using a form in a modal box is a very common scenario. In fact, when you run `ng g ng-alain:edit edit`, you will get a complete example; you will get an HTML template like this: | ||
|
||
```html | ||
<sf mode="edit" [schema]="schema" [ui]="ui" [formData]="i" button="none"> | ||
<div class="modal-footer"> | ||
<button nz-button type="button" (click)="close()">Close</button> | ||
<button nz-button type="submit" [nzType]="'primary'" (click)="save(sf.value)" [disabled]="!sf.valid" [nzLoading]="http.loading">Save</button> | ||
</div> | ||
</sf> | ||
``` | ||
|
||
`.modal-footer` has been very friendly to integrate custom dynamic boxes. |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,6 +55,7 @@ switchLanguage() { | |
| 法文 | fr_FR | | ||
| 西班牙语 | es_ES | | ||
| 意大利语 | it_IT | | ||
| 越南语 | vi_VI | | ||
|
||
## 增加语言包 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.