@dignite-ng/expand.dynamic-form 3.0.0-rc.4 → 3.0.0-rc.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ng-package.json +7 -0
- package/package.json +2 -15
- package/src/lib/components/dynamic/dynamic.component.html +2 -0
- package/src/lib/components/dynamic/dynamic.component.scss +0 -0
- package/src/lib/components/dynamic/dynamic.component.spec.ts +21 -0
- package/src/lib/components/dynamic/dynamic.component.ts +121 -0
- package/src/lib/components/dynamic/index.ts +1 -0
- package/src/lib/components/form/date-edit/date-edit-config.component.html +40 -0
- package/src/lib/components/form/date-edit/date-edit-config.component.scss +0 -0
- package/src/lib/components/form/date-edit/date-edit-config.component.spec.ts +21 -0
- package/src/lib/components/form/date-edit/date-edit-config.component.ts +87 -0
- package/src/lib/components/form/date-edit/date-edit-config.ts +14 -0
- package/src/lib/components/form/date-edit/date-edit-control.component.html +26 -0
- package/src/lib/components/form/date-edit/date-edit-control.component.scss +0 -0
- package/src/lib/components/form/date-edit/date-edit-control.component.spec.ts +21 -0
- package/src/lib/components/form/date-edit/date-edit-control.component.ts +101 -0
- package/src/lib/components/form/date-edit/index.ts +2 -0
- package/src/lib/components/form/form-control-group.ts +64 -0
- package/src/lib/components/form/index.ts +6 -0
- package/src/lib/components/form/numeric-edit/index.ts +2 -0
- package/src/lib/components/form/numeric-edit/numberic-edit-config.component.html +31 -0
- package/src/lib/components/form/numeric-edit/numberic-edit-config.component.scss +0 -0
- package/src/lib/components/form/numeric-edit/numberic-edit-config.component.spec.ts +21 -0
- package/src/lib/components/form/numeric-edit/numberic-edit-config.component.ts +57 -0
- package/src/lib/components/form/numeric-edit/numberic-edit-config.ts +28 -0
- package/src/lib/components/form/numeric-edit/numberic-edit-control.component.html +13 -0
- package/src/lib/components/form/numeric-edit/numberic-edit-control.component.scss +0 -0
- package/src/lib/components/form/numeric-edit/numberic-edit-control.component.spec.ts +21 -0
- package/src/lib/components/form/numeric-edit/numberic-edit-control.component.ts +119 -0
- package/src/lib/components/form/select/index.ts +2 -0
- package/src/lib/components/form/select/select-config.component.html +59 -0
- package/src/lib/components/form/select/select-config.component.scss +0 -0
- package/src/lib/components/form/select/select-config.component.spec.ts +21 -0
- package/src/lib/components/form/select/select-config.component.ts +90 -0
- package/src/lib/components/form/select/select-config.ts +24 -0
- package/src/lib/components/form/select/select-control.component.html +32 -0
- package/src/lib/components/form/select/select-control.component.scss +32 -0
- package/src/lib/components/form/select/select-control.component.spec.ts +21 -0
- package/src/lib/components/form/select/select-control.component.ts +86 -0
- package/src/lib/components/form/switch/index.ts +2 -0
- package/src/lib/components/form/switch/switch-config.component.html +17 -0
- package/src/lib/components/form/switch/switch-config.component.scss +0 -0
- package/src/lib/components/form/switch/switch-config.component.spec.ts +21 -0
- package/src/lib/components/form/switch/switch-config.component.ts +58 -0
- package/src/lib/components/form/switch/switch-config.ts +17 -0
- package/src/lib/components/form/switch/switch-control.component.html +13 -0
- package/src/lib/components/form/switch/switch-control.component.scss +0 -0
- package/src/lib/components/form/switch/switch-control.component.spec.ts +21 -0
- package/src/lib/components/form/switch/switch-control.component.ts +81 -0
- package/src/lib/components/form/text-edit/index.ts +3 -0
- package/src/lib/components/form/text-edit/text-edit-config.component.html +32 -0
- package/src/lib/components/form/text-edit/text-edit-config.component.scss +0 -0
- package/src/lib/components/form/text-edit/text-edit-config.component.spec.ts +21 -0
- package/src/lib/components/form/text-edit/text-edit-config.component.ts +59 -0
- package/src/lib/components/form/text-edit/text-edit-config.ts +24 -0
- package/src/lib/components/form/text-edit/text-edit.component.html +17 -0
- package/src/lib/components/form/text-edit/text-edit.component.scss +0 -0
- package/src/lib/components/form/text-edit/text-edit.component.spec.ts +21 -0
- package/src/lib/components/form/text-edit/text-edit.component.ts +91 -0
- package/src/lib/components/index.ts +2 -0
- package/src/lib/dynamic-form.module.ts +74 -0
- package/src/lib/enums/date-edit-interfaces.ts +16 -0
- package/src/lib/enums/index.ts +2 -0
- package/src/lib/enums/text-edit-mode.ts +7 -0
- package/{lib/interfaces/form-config-interfaces.d.ts → src/lib/interfaces/form-config-interfaces.ts} +7 -2
- package/src/lib/interfaces/index.ts +1 -0
- package/src/lib/proxy/README.md +17 -0
- package/src/lib/proxy/dignite/file-explorer/directories/file-descriptor.service.ts +65 -0
- package/src/lib/proxy/dignite/file-explorer/directories/index.ts +2 -0
- package/src/lib/proxy/dignite/file-explorer/directories/models.ts +35 -0
- package/src/lib/proxy/dignite/file-explorer/files/file-descriptor.service.ts +86 -0
- package/src/lib/proxy/dignite/file-explorer/files/index.ts +2 -0
- package/src/lib/proxy/dignite/file-explorer/files/models.ts +57 -0
- package/src/lib/proxy/dignite/file-explorer/index.ts +3 -0
- package/src/lib/proxy/dignite/index.ts +2 -0
- package/src/lib/proxy/generate-proxy.json +11810 -0
- package/src/lib/proxy/index.ts +4 -0
- package/src/lib/proxy/microsoft/asp-net-core/index.ts +2 -0
- package/src/lib/proxy/microsoft/asp-net-core/mvc/index.ts +1 -0
- package/src/lib/proxy/microsoft/asp-net-core/mvc/models.ts +12 -0
- package/src/lib/proxy/microsoft/extensions/index.ts +2 -0
- package/src/lib/proxy/microsoft/extensions/primitives/index.ts +1 -0
- package/src/lib/proxy/microsoft/extensions/primitives/models.ts +9 -0
- package/src/lib/proxy/microsoft/index.ts +4 -0
- package/src/lib/proxy/microsoft/net/http/headers/index.ts +1 -0
- package/src/lib/proxy/microsoft/net/http/headers/models.ts +7 -0
- package/src/lib/proxy/microsoft/net/http/index.ts +2 -0
- package/src/lib/proxy/microsoft/net/index.ts +2 -0
- package/src/lib/proxy/volo/abp/content/index.ts +1 -0
- package/src/lib/proxy/volo/abp/content/models.ts +6 -0
- package/src/lib/proxy/volo/abp/index.ts +2 -0
- package/src/lib/proxy/volo/index.ts +2 -0
- package/src/lib/services/df-api.service.ts +75 -0
- package/src/lib/services/index.ts +1 -0
- package/{public-api.d.ts → src/public-api.ts} +4 -0
- package/tsconfig.lib.json +14 -0
- package/tsconfig.lib.prod.json +10 -0
- package/tsconfig.spec.json +14 -0
- package/esm2022/dignite-ng-expand.dynamic-form.mjs +0 -5
- package/esm2022/lib/components/dynamic/dynamic.component.mjs +0 -109
- package/esm2022/lib/components/dynamic/index.mjs +0 -2
- package/esm2022/lib/components/form/date-edit/date-edit-config.component.mjs +0 -90
- package/esm2022/lib/components/form/date-edit/date-edit-config.mjs +0 -12
- package/esm2022/lib/components/form/date-edit/date-edit-control.component.mjs +0 -99
- package/esm2022/lib/components/form/date-edit/index.mjs +0 -3
- package/esm2022/lib/components/form/form-control-group.mjs +0 -53
- package/esm2022/lib/components/form/index.mjs +0 -7
- package/esm2022/lib/components/form/numeric-edit/index.mjs +0 -3
- package/esm2022/lib/components/form/numeric-edit/numberic-edit-config.component.mjs +0 -60
- package/esm2022/lib/components/form/numeric-edit/numberic-edit-config.mjs +0 -24
- package/esm2022/lib/components/form/numeric-edit/numberic-edit-control.component.mjs +0 -106
- package/esm2022/lib/components/form/select/index.mjs +0 -3
- package/esm2022/lib/components/form/select/select-config.component.mjs +0 -93
- package/esm2022/lib/components/form/select/select-config.mjs +0 -19
- package/esm2022/lib/components/form/select/select-control.component.mjs +0 -86
- package/esm2022/lib/components/form/switch/index.mjs +0 -3
- package/esm2022/lib/components/form/switch/switch-config.component.mjs +0 -61
- package/esm2022/lib/components/form/switch/switch-config.mjs +0 -14
- package/esm2022/lib/components/form/switch/switch-control.component.mjs +0 -80
- package/esm2022/lib/components/form/text-edit/index.mjs +0 -4
- package/esm2022/lib/components/form/text-edit/text-edit-config.component.mjs +0 -63
- package/esm2022/lib/components/form/text-edit/text-edit-config.mjs +0 -18
- package/esm2022/lib/components/form/text-edit/text-edit.component.mjs +0 -89
- package/esm2022/lib/components/index.mjs +0 -3
- package/esm2022/lib/dynamic-form.module.mjs +0 -88
- package/esm2022/lib/enums/date-edit-interfaces.mjs +0 -16
- package/esm2022/lib/enums/text-edit-mode.mjs +0 -8
- package/esm2022/lib/interfaces/form-config-interfaces.mjs +0 -2
- package/esm2022/lib/interfaces/index.mjs +0 -2
- package/esm2022/lib/services/df-api.service.mjs +0 -82
- package/esm2022/lib/services/index.mjs +0 -2
- package/esm2022/public-api.mjs +0 -7
- package/fesm2022/dignite-ng-expand.dynamic-form.mjs +0 -1200
- package/fesm2022/dignite-ng-expand.dynamic-form.mjs.map +0 -1
- package/index.d.ts +0 -5
- package/lib/components/dynamic/dynamic.component.d.ts +0 -38
- package/lib/components/dynamic/index.d.ts +0 -1
- package/lib/components/form/date-edit/date-edit-config.component.d.ts +0 -29
- package/lib/components/form/date-edit/date-edit-config.d.ts +0 -9
- package/lib/components/form/date-edit/date-edit-control.component.d.ts +0 -33
- package/lib/components/form/date-edit/index.d.ts +0 -2
- package/lib/components/form/form-control-group.d.ts +0 -6
- package/lib/components/form/index.d.ts +0 -6
- package/lib/components/form/numeric-edit/index.d.ts +0 -2
- package/lib/components/form/numeric-edit/numberic-edit-config.component.d.ts +0 -23
- package/lib/components/form/numeric-edit/numberic-edit-config.d.ts +0 -11
- package/lib/components/form/numeric-edit/numberic-edit-control.component.d.ts +0 -34
- package/lib/components/form/select/index.d.ts +0 -2
- package/lib/components/form/select/select-config.component.d.ts +0 -31
- package/lib/components/form/select/select-config.d.ts +0 -7
- package/lib/components/form/select/select-control.component.d.ts +0 -29
- package/lib/components/form/switch/index.d.ts +0 -2
- package/lib/components/form/switch/switch-config.component.d.ts +0 -23
- package/lib/components/form/switch/switch-config.d.ts +0 -5
- package/lib/components/form/switch/switch-control.component.d.ts +0 -28
- package/lib/components/form/text-edit/index.d.ts +0 -3
- package/lib/components/form/text-edit/text-edit-config.component.d.ts +0 -25
- package/lib/components/form/text-edit/text-edit-config.d.ts +0 -7
- package/lib/components/form/text-edit/text-edit.component.d.ts +0 -30
- package/lib/components/index.d.ts +0 -2
- package/lib/dynamic-form.module.d.ts +0 -23
- package/lib/enums/date-edit-interfaces.d.ts +0 -5
- package/lib/enums/text-edit-mode.d.ts +0 -4
- package/lib/interfaces/index.d.ts +0 -1
- package/lib/services/df-api.service.d.ts +0 -18
- package/lib/services/index.d.ts +0 -1
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { ChangeDetectorRef, Component, ElementRef, inject, Input, ViewChild } from '@angular/core';
|
|
2
|
+
import { FormBuilder, FormGroup } from '@angular/forms';
|
|
3
|
+
import { SwitchConfig } from './switch-config';
|
|
4
|
+
@Component({
|
|
5
|
+
selector: 'df-switch-config',
|
|
6
|
+
templateUrl: './switch-config.component.html',
|
|
7
|
+
styleUrls: ['./switch-config.component.scss'],
|
|
8
|
+
})
|
|
9
|
+
export class SwitchConfigComponent {
|
|
10
|
+
constructor(private fb: FormBuilder) {}
|
|
11
|
+
/**表单控件类型 */
|
|
12
|
+
_type: any;
|
|
13
|
+
@Input()
|
|
14
|
+
public set type(v: any) {
|
|
15
|
+
this._type = v;
|
|
16
|
+
this.dataLoaded();
|
|
17
|
+
}
|
|
18
|
+
/**表单实体 */
|
|
19
|
+
_Entity: FormGroup | undefined;
|
|
20
|
+
@Input()
|
|
21
|
+
public set Entity(v: FormGroup) {
|
|
22
|
+
this._Entity = v;
|
|
23
|
+
this.dataLoaded();
|
|
24
|
+
}
|
|
25
|
+
/**选择的表单信息 */
|
|
26
|
+
_selected: any;
|
|
27
|
+
@Input()
|
|
28
|
+
public set selected(v: any) {
|
|
29
|
+
this._selected = v;
|
|
30
|
+
|
|
31
|
+
this.dataLoaded();
|
|
32
|
+
}
|
|
33
|
+
get formConfiguration() {
|
|
34
|
+
return this._Entity.get('formConfiguration') as FormGroup;
|
|
35
|
+
}
|
|
36
|
+
@ViewChild('submitclick', { static: true }) submitclick: ElementRef;
|
|
37
|
+
|
|
38
|
+
private cdr = inject(ChangeDetectorRef);
|
|
39
|
+
async dataLoaded() {
|
|
40
|
+
if (this._Entity && this._type) {
|
|
41
|
+
await this.AfterInit();
|
|
42
|
+
this.cdr.detectChanges(); // 手动触发变更检测
|
|
43
|
+
this.submitclick?.nativeElement?.click();
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
AfterInit() {
|
|
48
|
+
return new Promise((resolve, rejects) => {
|
|
49
|
+
this._Entity.setControl('formConfiguration', this.fb.group(new SwitchConfig()));
|
|
50
|
+
if (this._selected && this._selected.formControlName == this._type) {
|
|
51
|
+
this.formConfiguration.patchValue({
|
|
52
|
+
...this._selected.formConfiguration,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
resolve(true);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { FormControl, Validators } from "@angular/forms";
|
|
2
|
+
|
|
3
|
+
export class SwitchConfig {
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
/**默认值 */
|
|
7
|
+
'Switch.Default': any = [false, []];
|
|
8
|
+
constructor(data?: SwitchConfig) {
|
|
9
|
+
if (data) {
|
|
10
|
+
for (const key in data) {
|
|
11
|
+
if (data.hasOwnProperty(key)) {
|
|
12
|
+
this[key] = data[key];
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<form [formGroup]="_entity">
|
|
2
|
+
<div formGroupName="extraProperties">
|
|
3
|
+
<div class="mb-3">
|
|
4
|
+
<label class="form-label" *ngIf="_fields.displayName">{{ _fields.displayName }}</label>
|
|
5
|
+
<div class="form-check form-switch">
|
|
6
|
+
<input class="form-check-input" type="checkbox" role="switch" formControlName="{{_fields.field.name}}">
|
|
7
|
+
</div>
|
|
8
|
+
<small class="form-text text-muted d-block" *ngIf="_fields.field.description">{{_fields.field.description}}</small>
|
|
9
|
+
</div>
|
|
10
|
+
|
|
11
|
+
</div>
|
|
12
|
+
<button type="submit" style="display: none;" #submitclick></button>
|
|
13
|
+
</form>
|
|
File without changes
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { SwitchControlComponent } from './switch-control.component';
|
|
4
|
+
|
|
5
|
+
describe('SwitchControlComponent', () => {
|
|
6
|
+
let component: SwitchControlComponent;
|
|
7
|
+
let fixture: ComponentFixture<SwitchControlComponent>;
|
|
8
|
+
|
|
9
|
+
beforeEach(() => {
|
|
10
|
+
TestBed.configureTestingModule({
|
|
11
|
+
declarations: [SwitchControlComponent]
|
|
12
|
+
});
|
|
13
|
+
fixture = TestBed.createComponent(SwitchControlComponent);
|
|
14
|
+
component = fixture.componentInstance;
|
|
15
|
+
fixture.detectChanges();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('should create', () => {
|
|
19
|
+
expect(component).toBeTruthy();
|
|
20
|
+
});
|
|
21
|
+
});
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { ChangeDetectorRef, Component, ElementRef, inject, Input, ViewChild } from '@angular/core';
|
|
2
|
+
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
|
3
|
+
|
|
4
|
+
@Component({
|
|
5
|
+
selector: 'df-switch-control',
|
|
6
|
+
templateUrl: './switch-control.component.html',
|
|
7
|
+
styleUrls: ['./switch-control.component.scss'],
|
|
8
|
+
})
|
|
9
|
+
export class SwitchControlComponent {
|
|
10
|
+
constructor(private fb: FormBuilder) {}
|
|
11
|
+
|
|
12
|
+
/**表单实体 */
|
|
13
|
+
_entity: FormGroup | undefined;
|
|
14
|
+
@Input()
|
|
15
|
+
public set entity(v: any) {
|
|
16
|
+
this._entity = v;
|
|
17
|
+
this.dataLoaded();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**字段配置列表 */
|
|
21
|
+
_fields: any = '';
|
|
22
|
+
@Input()
|
|
23
|
+
public set fields(v: any) {
|
|
24
|
+
this._fields = v;
|
|
25
|
+
this.dataLoaded();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**父级字段名称,用于为表单设置控件赋值 */
|
|
29
|
+
_parentFiledName: any;
|
|
30
|
+
@Input()
|
|
31
|
+
public set parentFiledName(v: any) {
|
|
32
|
+
this._parentFiledName = v;
|
|
33
|
+
this.dataLoaded();
|
|
34
|
+
}
|
|
35
|
+
/** */
|
|
36
|
+
_selected: any;
|
|
37
|
+
@Input()
|
|
38
|
+
public set selected(v: any) {
|
|
39
|
+
// ?v:false;
|
|
40
|
+
this._selected = v;
|
|
41
|
+
this.dataLoaded();
|
|
42
|
+
}
|
|
43
|
+
@ViewChild('submitclick', { static: true }) submitclick: ElementRef;
|
|
44
|
+
|
|
45
|
+
get extraProperties() {
|
|
46
|
+
return this._entity.get('extraProperties') as FormGroup;
|
|
47
|
+
}
|
|
48
|
+
private cdr = inject(ChangeDetectorRef);
|
|
49
|
+
/**数据加载完成 */
|
|
50
|
+
async dataLoaded() {
|
|
51
|
+
if (this._fields && this._entity) {
|
|
52
|
+
await this.AfterInit();
|
|
53
|
+
this.cdr.detectChanges(); // 手动触发变更检测
|
|
54
|
+
this.submitclick?.nativeElement?.click();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
AfterInit() {
|
|
59
|
+
return new Promise((resolve, rejects) => {
|
|
60
|
+
let ValidatorsArray = [];
|
|
61
|
+
if (this._fields.required) {
|
|
62
|
+
ValidatorsArray.push(Validators.required);
|
|
63
|
+
}
|
|
64
|
+
let newControl = this.fb.control(
|
|
65
|
+
this._selected
|
|
66
|
+
? this._selected
|
|
67
|
+
: this._selected === false
|
|
68
|
+
? this._selected
|
|
69
|
+
: this._fields.field.formConfiguration['Switch.Default'],
|
|
70
|
+
ValidatorsArray
|
|
71
|
+
);
|
|
72
|
+
this.extraProperties.setControl(this._fields.field.name, newControl);
|
|
73
|
+
resolve(true);
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
ngOnDestroy(): void {
|
|
77
|
+
//Called once, before the instance is destroyed.
|
|
78
|
+
//Add 'implements OnDestroy' to the class.
|
|
79
|
+
this.extraProperties.removeControl(this._fields.field.name);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<form [formGroup]="_Entity">
|
|
2
|
+
<div formGroupName="formConfiguration">
|
|
3
|
+
<div class="mb-3">
|
|
4
|
+
<label class="form-label">{{'DigniteAbpForms::Placeholder' | abpLocalization}}</label>
|
|
5
|
+
<input type="text" class="form-control" formControlName="TextEdit.Placeholder">
|
|
6
|
+
</div>
|
|
7
|
+
<div class="mb-3">
|
|
8
|
+
<label class="form-label">{{'DigniteAbpForms::TextEditMode' | abpLocalization}}</label>
|
|
9
|
+
<div>
|
|
10
|
+
<div class="form-check form-check-inline">
|
|
11
|
+
<input class="form-check-input" type="radio" [value]="_TextEditMode.SingleLine" formControlName="TextEdit.Mode"
|
|
12
|
+
id="flexRadioDefault1">
|
|
13
|
+
<label class="form-check-label" for="flexRadioDefault1">
|
|
14
|
+
{{'DigniteAbpForms::SingleLine' | abpLocalization}}
|
|
15
|
+
</label>
|
|
16
|
+
</div>
|
|
17
|
+
<div class="form-check form-check-inline">
|
|
18
|
+
<input class="form-check-input" type="radio" [value]="_TextEditMode.MultipleLine" formControlName="TextEdit.Mode"
|
|
19
|
+
id="flexRadioDefault2">
|
|
20
|
+
<label class="form-check-label" for="flexRadioDefault2">
|
|
21
|
+
{{'DigniteAbpForms::MultipleLine' | abpLocalization}}
|
|
22
|
+
</label>
|
|
23
|
+
</div>
|
|
24
|
+
</div>
|
|
25
|
+
</div>
|
|
26
|
+
<div class="mb-3">
|
|
27
|
+
<label class="form-label">{{'DigniteAbpForms::CharLimit' | abpLocalization}}</label>
|
|
28
|
+
<input type="number" class="form-control" formControlName="TextEdit.CharLimit">
|
|
29
|
+
</div>
|
|
30
|
+
<button type="submit" (abpInit)="submitclick?.nativeElement?.click()" style="display: none;" #submitclick></button>
|
|
31
|
+
</div>
|
|
32
|
+
</form>
|
|
File without changes
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { TextEditConfigComponent } from './text-edit-config.component';
|
|
4
|
+
|
|
5
|
+
describe('TextEditConfigComponent', () => {
|
|
6
|
+
let component: TextEditConfigComponent;
|
|
7
|
+
let fixture: ComponentFixture<TextEditConfigComponent>;
|
|
8
|
+
|
|
9
|
+
beforeEach(() => {
|
|
10
|
+
TestBed.configureTestingModule({
|
|
11
|
+
declarations: [TextEditConfigComponent]
|
|
12
|
+
});
|
|
13
|
+
fixture = TestBed.createComponent(TextEditConfigComponent);
|
|
14
|
+
component = fixture.componentInstance;
|
|
15
|
+
fixture.detectChanges();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('should create', () => {
|
|
19
|
+
expect(component).toBeTruthy();
|
|
20
|
+
});
|
|
21
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { ChangeDetectorRef, Component, ElementRef, inject, Input, ViewChild } from '@angular/core';
|
|
2
|
+
import { FormBuilder, FormGroup } from '@angular/forms';
|
|
3
|
+
import { TextEditConfig } from './text-edit-config';
|
|
4
|
+
import { TextEditMode } from '../../../enums/text-edit-mode';
|
|
5
|
+
|
|
6
|
+
@Component({
|
|
7
|
+
selector: 'df-text-edit-config',
|
|
8
|
+
templateUrl: './text-edit-config.component.html',
|
|
9
|
+
styleUrls: ['./text-edit-config.component.scss'],
|
|
10
|
+
})
|
|
11
|
+
export class TextEditConfigComponent {
|
|
12
|
+
constructor(private fb: FormBuilder) {}
|
|
13
|
+
_TextEditMode = TextEditMode;
|
|
14
|
+
/**表单控件类型 */
|
|
15
|
+
_type: any;
|
|
16
|
+
@Input()
|
|
17
|
+
public set type(v: any) {
|
|
18
|
+
this._type = v;
|
|
19
|
+
this.dataLoaded();
|
|
20
|
+
}
|
|
21
|
+
/**表单实体 */
|
|
22
|
+
_Entity: FormGroup | undefined;
|
|
23
|
+
@Input()
|
|
24
|
+
public set Entity(v: FormGroup) {
|
|
25
|
+
this._Entity = v;
|
|
26
|
+
this.dataLoaded();
|
|
27
|
+
}
|
|
28
|
+
/**选择的表单信息 */
|
|
29
|
+
_selected: any;
|
|
30
|
+
@Input()
|
|
31
|
+
public set selected(v: any) {
|
|
32
|
+
this._selected = v;
|
|
33
|
+
this.dataLoaded();
|
|
34
|
+
}
|
|
35
|
+
get formConfiguration() {
|
|
36
|
+
return this._Entity.get('formConfiguration') as FormGroup;
|
|
37
|
+
}
|
|
38
|
+
@ViewChild('submitclick', { static: true }) submitclick: ElementRef;
|
|
39
|
+
private cdr = inject(ChangeDetectorRef);
|
|
40
|
+
async dataLoaded() {
|
|
41
|
+
if (this._Entity && this._type) {
|
|
42
|
+
await this.AfterInit();
|
|
43
|
+
this.cdr.detectChanges(); // 手动触发变更检测
|
|
44
|
+
this.submitclick?.nativeElement?.click();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
AfterInit() {
|
|
49
|
+
return new Promise((resolve, rejects) => {
|
|
50
|
+
this._Entity.setControl('formConfiguration', this.fb.group(new TextEditConfig()));
|
|
51
|
+
if (this._selected && this._selected.formControlName == this._type) {
|
|
52
|
+
this.formConfiguration.patchValue({
|
|
53
|
+
...this._selected.formConfiguration,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
resolve(true);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { FormControl, Validators } from "@angular/forms";
|
|
2
|
+
|
|
3
|
+
export class TextEditConfig {
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
/**占位符 */
|
|
7
|
+
'TextEdit.Placeholder': any = ['', []];
|
|
8
|
+
//字段类型,单行文本,多行文本
|
|
9
|
+
'TextEdit.Mode': any = [0, []];
|
|
10
|
+
// 字数限制
|
|
11
|
+
'TextEdit.CharLimit': any = ['265', []];
|
|
12
|
+
|
|
13
|
+
constructor(data?: TextEditConfig) {
|
|
14
|
+
if (data) {
|
|
15
|
+
for (const key in data) {
|
|
16
|
+
if (data.hasOwnProperty(key)) {
|
|
17
|
+
this[key] = data[key];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<form [formGroup]="_entity">
|
|
2
|
+
<div [formGroupName]="_parentFiledName">
|
|
3
|
+
<div class="mb-3">
|
|
4
|
+
<label class="form-label" *ngIf="_fields.displayName">{{ _fields.displayName }}</label>
|
|
5
|
+
<ng-container *ngIf="_fields.field.formConfiguration['TextEdit.Mode'] ===_TextEditMode.SingleLine">
|
|
6
|
+
<input type="text" class="form-control" formControlName="{{_fields.field.name}}"
|
|
7
|
+
[placeholder]="_fields.field.formConfiguration['TextEdit.Placeholder']" />
|
|
8
|
+
</ng-container>
|
|
9
|
+
<ng-container *ngIf="_fields.field.formConfiguration['TextEdit.Mode'] === _TextEditMode.MultipleLine">
|
|
10
|
+
<textarea class="form-control" formControlName="{{_fields.field.name}}"
|
|
11
|
+
[placeholder]="_fields.field.formConfiguration['TextEdit.Placeholder']" rows="3"></textarea>
|
|
12
|
+
</ng-container>
|
|
13
|
+
<small class="form-text text-muted d-block" *ngIf="_fields.field.description">{{_fields.field.description}}</small>
|
|
14
|
+
</div>
|
|
15
|
+
</div>
|
|
16
|
+
<button type="submit" style="display: none;" #submitclick></button>
|
|
17
|
+
</form>
|
|
File without changes
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { TextEditComponent } from './text-edit.component';
|
|
4
|
+
|
|
5
|
+
describe('TextEditComponent', () => {
|
|
6
|
+
let component: TextEditComponent;
|
|
7
|
+
let fixture: ComponentFixture<TextEditComponent>;
|
|
8
|
+
|
|
9
|
+
beforeEach(() => {
|
|
10
|
+
TestBed.configureTestingModule({
|
|
11
|
+
declarations: [TextEditComponent]
|
|
12
|
+
});
|
|
13
|
+
fixture = TestBed.createComponent(TextEditComponent);
|
|
14
|
+
component = fixture.componentInstance;
|
|
15
|
+
fixture.detectChanges();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('should create', () => {
|
|
19
|
+
expect(component).toBeTruthy();
|
|
20
|
+
});
|
|
21
|
+
});
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/* eslint-disable @angular-eslint/no-empty-lifecycle-method */
|
|
2
|
+
/* eslint-disable @angular-eslint/use-lifecycle-interface */
|
|
3
|
+
import { ChangeDetectorRef, Component, ElementRef, inject, Input, ViewChild } from '@angular/core';
|
|
4
|
+
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
|
5
|
+
import { TextEditMode } from '../../../enums/text-edit-mode';
|
|
6
|
+
import { TextEditConfig } from './text-edit-config';
|
|
7
|
+
|
|
8
|
+
@Component({
|
|
9
|
+
selector: 'df-text-edit',
|
|
10
|
+
templateUrl: './text-edit.component.html',
|
|
11
|
+
styleUrls: ['./text-edit.component.scss']
|
|
12
|
+
})
|
|
13
|
+
export class TextEditComponent {
|
|
14
|
+
|
|
15
|
+
constructor(
|
|
16
|
+
private fb: FormBuilder,
|
|
17
|
+
) {
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
_TextEditMode = TextEditMode
|
|
21
|
+
/**表单实体 */
|
|
22
|
+
_entity: FormGroup | undefined
|
|
23
|
+
@Input()
|
|
24
|
+
public set entity(v: any) {
|
|
25
|
+
this._entity = v;
|
|
26
|
+
if (v) this.dataLoaded()
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**字段配置列表 */
|
|
30
|
+
_fields: any = ''
|
|
31
|
+
@Input()
|
|
32
|
+
public set fields(v: any) {
|
|
33
|
+
this._fields = v;
|
|
34
|
+
if (v) this.dataLoaded()
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**父级字段名称,用于为表单设置控件赋值 */
|
|
38
|
+
_parentFiledName: any
|
|
39
|
+
@Input()
|
|
40
|
+
public set parentFiledName(v: any) {
|
|
41
|
+
this._parentFiledName = v;
|
|
42
|
+
if (v) this.dataLoaded()
|
|
43
|
+
}
|
|
44
|
+
/**父级字段名称,用于为表单设置控件赋值 */
|
|
45
|
+
_selected: any
|
|
46
|
+
@Input()
|
|
47
|
+
public set selected(v: any) {
|
|
48
|
+
this._selected = v || '';
|
|
49
|
+
if (v) this.dataLoaded()
|
|
50
|
+
}
|
|
51
|
+
@ViewChild('submitclick', { static: true }) submitclick: ElementRef;
|
|
52
|
+
|
|
53
|
+
extraProperties: FormGroup | undefined;
|
|
54
|
+
private cdr = inject(ChangeDetectorRef);
|
|
55
|
+
async dataLoaded() {
|
|
56
|
+
if (this._fields && this._entity && this._parentFiledName) {
|
|
57
|
+
this.extraProperties = this._entity.get(this._parentFiledName) as FormGroup
|
|
58
|
+
await this.AfterInit()
|
|
59
|
+
this.cdr.detectChanges(); // 手动触发变更检测
|
|
60
|
+
this.submitclick?.nativeElement?.click();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
AfterInit() {
|
|
66
|
+
return new Promise((resolve, rejects) => {
|
|
67
|
+
let ValidatorsArray = []
|
|
68
|
+
if (this._fields.required) {
|
|
69
|
+
ValidatorsArray.push(Validators.required)
|
|
70
|
+
}
|
|
71
|
+
this._fields.field.formConfiguration={
|
|
72
|
+
...this.fb.group(new TextEditConfig()).value,
|
|
73
|
+
...this._fields.field.formConfiguration
|
|
74
|
+
}
|
|
75
|
+
if (this._fields.field.formConfiguration['TextEdit.CharLimit']) {
|
|
76
|
+
ValidatorsArray.push(Validators.maxLength(this._fields.field.formConfiguration['TextEdit.CharLimit']))
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
let newControl = this.fb.control(this._selected, ValidatorsArray)
|
|
80
|
+
this.extraProperties.setControl(this._fields.field.name, newControl)
|
|
81
|
+
resolve(true)
|
|
82
|
+
})
|
|
83
|
+
}
|
|
84
|
+
ngOnDestroy(): void {
|
|
85
|
+
//Called once, before the instance is destroyed.
|
|
86
|
+
//Add 'implements OnDestroy' to the class.
|
|
87
|
+
this.extraProperties.removeControl(this._fields.field.name)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
isObjEmpty = (obj) => Object.keys(obj).length === 0
|
|
91
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { APP_INITIALIZER, ModuleWithProviders, NgModule } from '@angular/core';
|
|
2
|
+
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|
3
|
+
import { CoreModule } from '@abp/ng.core';
|
|
4
|
+
import { ThemeSharedModule } from '@abp/ng.theme.shared';
|
|
5
|
+
import { NgbDropdownModule } from '@ng-bootstrap/ng-bootstrap';
|
|
6
|
+
// import { NzTreeModule } from 'ng-zorro-antd/tree';
|
|
7
|
+
import {
|
|
8
|
+
TextEditConfigComponent,
|
|
9
|
+
TextEditComponent,
|
|
10
|
+
SwitchConfigComponent,
|
|
11
|
+
SwitchControlComponent,
|
|
12
|
+
NumbericEditConfigComponent,
|
|
13
|
+
NumbericEditControlComponent,
|
|
14
|
+
DateEditConfigComponent,
|
|
15
|
+
DateEditControlComponent,
|
|
16
|
+
SelectConfigComponent,
|
|
17
|
+
SelectControlComponent,
|
|
18
|
+
AddFieldControlGroup,
|
|
19
|
+
DynamicComponent,
|
|
20
|
+
} from './components';
|
|
21
|
+
import { NzSelectModule } from 'ng-zorro-antd/select';
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
@NgModule({
|
|
26
|
+
declarations: [
|
|
27
|
+
TextEditConfigComponent,
|
|
28
|
+
TextEditComponent,
|
|
29
|
+
SwitchConfigComponent,
|
|
30
|
+
SwitchControlComponent,
|
|
31
|
+
NumbericEditConfigComponent,
|
|
32
|
+
NumbericEditControlComponent,
|
|
33
|
+
DateEditConfigComponent,
|
|
34
|
+
DateEditControlComponent,
|
|
35
|
+
SelectConfigComponent,
|
|
36
|
+
SelectControlComponent,
|
|
37
|
+
DynamicComponent,
|
|
38
|
+
|
|
39
|
+
],
|
|
40
|
+
imports: [
|
|
41
|
+
FormsModule,
|
|
42
|
+
CoreModule,
|
|
43
|
+
ThemeSharedModule,
|
|
44
|
+
ReactiveFormsModule,
|
|
45
|
+
NgbDropdownModule,
|
|
46
|
+
NzSelectModule,
|
|
47
|
+
// NzTreeModule,
|
|
48
|
+
],
|
|
49
|
+
exports: [
|
|
50
|
+
TextEditConfigComponent,
|
|
51
|
+
TextEditComponent,
|
|
52
|
+
SwitchConfigComponent,
|
|
53
|
+
SwitchControlComponent,
|
|
54
|
+
NumbericEditConfigComponent,
|
|
55
|
+
NumbericEditControlComponent,
|
|
56
|
+
DateEditConfigComponent,
|
|
57
|
+
DateEditControlComponent,
|
|
58
|
+
SelectConfigComponent,
|
|
59
|
+
SelectControlComponent,
|
|
60
|
+
DynamicComponent,
|
|
61
|
+
],
|
|
62
|
+
providers: [
|
|
63
|
+
],
|
|
64
|
+
})
|
|
65
|
+
export class DynamicFormModule {
|
|
66
|
+
static forRoot(config?: any): ModuleWithProviders<DynamicFormModule> {
|
|
67
|
+
return {
|
|
68
|
+
ngModule: DynamicFormModule,
|
|
69
|
+
providers: [
|
|
70
|
+
]
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export enum DateEditInterfaces {
|
|
2
|
+
/// <summary>
|
|
3
|
+
/// Only date is allowed to be entered.
|
|
4
|
+
/// </summary>
|
|
5
|
+
Date = 0,
|
|
6
|
+
|
|
7
|
+
/// <summary>
|
|
8
|
+
/// Both date and time are allowed to be entered.
|
|
9
|
+
/// </summary>
|
|
10
|
+
DateTime = 1,
|
|
11
|
+
|
|
12
|
+
/// <summary>
|
|
13
|
+
/// Allowed to select only year and month.
|
|
14
|
+
/// </summary>
|
|
15
|
+
Month = 2
|
|
16
|
+
}
|
package/{lib/interfaces/form-config-interfaces.d.ts → src/lib/interfaces/form-config-interfaces.ts}
RENAMED
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
import { Type } from "@angular/core";
|
|
2
|
+
|
|
2
3
|
export interface FieldControlGroupInterfaces {
|
|
3
|
-
displayName: string
|
|
4
|
-
name: string
|
|
4
|
+
displayName: string
|
|
5
|
+
name: string
|
|
6
|
+
// type: TextEditMode,
|
|
5
7
|
/**
|
|
6
8
|
* 动态表单控件
|
|
7
9
|
*/
|
|
8
10
|
fieldComponent?: Type<any>;
|
|
11
|
+
|
|
9
12
|
/**
|
|
10
13
|
* 表单控件配置组件
|
|
11
14
|
*/
|
|
12
15
|
fieldConfigComponent?: Type<any>;
|
|
16
|
+
|
|
13
17
|
/**
|
|
14
18
|
* 条目列表中显示的组件
|
|
15
19
|
*/
|
|
16
20
|
fieldViewComponent?: Type<any>;
|
|
17
21
|
}
|
|
22
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './form-config-interfaces'
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Proxy Generation Output
|
|
2
|
+
|
|
3
|
+
This directory includes the output of the latest proxy generation.
|
|
4
|
+
The files and folders in it will be overwritten when proxy generation is run again.
|
|
5
|
+
Therefore, please do not place your own content in this folder.
|
|
6
|
+
|
|
7
|
+
In addition, `generate-proxy.json` works like a lock file.
|
|
8
|
+
It includes information used by the proxy generator, so please do not delete or modify it.
|
|
9
|
+
|
|
10
|
+
Finally, the name of the files and folders should not be changed for two reasons:
|
|
11
|
+
- Proxy generator will keep creating them at those paths and you will have multiple copies of the same content.
|
|
12
|
+
- ABP Suite generates files which include imports from this folder.
|
|
13
|
+
|
|
14
|
+
> **Important Notice:** If you are building a module and are planning to publish to npm,
|
|
15
|
+
> some of the generated proxies are likely to be exported from public-api.ts file. In such a case,
|
|
16
|
+
> please make sure you export files directly and not from barrel exports. In other words,
|
|
17
|
+
> do not include index.ts exports in your public-api.ts exports.
|