@dignite-ng/expand.dynamic-form 3.0.0-rc.6 → 3.0.0-rc.8
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/esm2022/dignite-ng-expand.dynamic-form.mjs +5 -0
- package/esm2022/lib/components/dynamic/dynamic-config.component.mjs +11 -0
- package/esm2022/lib/components/dynamic/dynamic-control.component.mjs +11 -0
- package/esm2022/lib/components/dynamic/dynamic-view.component.mjs +57 -0
- package/esm2022/lib/components/dynamic/dynamic.component.mjs +106 -0
- package/esm2022/lib/components/dynamic/index.mjs +5 -0
- package/esm2022/lib/components/form/date-edit/date-edit-config.component.mjs +90 -0
- package/esm2022/lib/components/form/date-edit/date-edit-config.mjs +12 -0
- package/esm2022/lib/components/form/date-edit/date-edit-control.component.mjs +99 -0
- package/esm2022/lib/components/form/date-edit/date-edit-view.component.mjs +40 -0
- package/esm2022/lib/components/form/date-edit/index.mjs +3 -0
- package/esm2022/lib/components/form/form-control-group.mjs +65 -0
- package/esm2022/lib/components/form/index.mjs +7 -0
- package/esm2022/lib/components/form/numeric-edit/index.mjs +3 -0
- package/esm2022/lib/components/form/numeric-edit/numberic-edit-config.component.mjs +60 -0
- package/esm2022/lib/components/form/numeric-edit/numberic-edit-config.mjs +25 -0
- package/esm2022/lib/components/form/numeric-edit/numberic-edit-control.component.mjs +106 -0
- package/esm2022/lib/components/form/numeric-edit/numeric-edit-view.component.mjs +39 -0
- package/esm2022/lib/components/form/select/index.mjs +3 -0
- package/esm2022/lib/components/form/select/select-config.component.mjs +93 -0
- package/esm2022/lib/components/form/select/select-config.mjs +19 -0
- package/esm2022/lib/components/form/select/select-control.component.mjs +87 -0
- package/esm2022/lib/components/form/select/select-view.component.mjs +44 -0
- package/esm2022/lib/components/form/switch/index.mjs +3 -0
- package/esm2022/lib/components/form/switch/switch-config.component.mjs +61 -0
- package/esm2022/lib/components/form/switch/switch-config.mjs +14 -0
- package/esm2022/lib/components/form/switch/switch-control.component.mjs +80 -0
- package/esm2022/lib/components/form/switch/switch-view.component.mjs +40 -0
- package/esm2022/lib/components/form/text-edit/index.mjs +4 -0
- package/esm2022/lib/components/form/text-edit/text-edit-config.component.mjs +63 -0
- package/esm2022/lib/components/form/text-edit/text-edit-config.mjs +18 -0
- package/esm2022/lib/components/form/text-edit/text-edit-view.component.mjs +39 -0
- package/esm2022/lib/components/form/text-edit/text-edit.component.mjs +89 -0
- package/esm2022/lib/components/index.mjs +3 -0
- package/esm2022/lib/dynamic-form.module.mjs +122 -0
- package/esm2022/lib/enums/date-edit-interfaces.mjs +16 -0
- package/esm2022/lib/enums/text-edit-mode.mjs +8 -0
- package/esm2022/lib/interfaces/form-config-interfaces.mjs +2 -0
- package/esm2022/lib/interfaces/index.mjs +2 -0
- package/esm2022/lib/services/df-api.service.mjs +82 -0
- package/esm2022/lib/services/form-control.service.mjs +33 -0
- package/esm2022/lib/services/index.mjs +2 -0
- package/esm2022/public-api.mjs +7 -0
- package/fesm2022/dignite-ng-expand.dynamic-form.mjs +1518 -0
- package/fesm2022/dignite-ng-expand.dynamic-form.mjs.map +1 -0
- package/index.d.ts +5 -0
- package/lib/components/dynamic/dynamic-config.component.d.ts +5 -0
- package/lib/components/dynamic/dynamic-control.component.d.ts +5 -0
- package/lib/components/dynamic/dynamic-view.component.d.ts +24 -0
- package/lib/components/dynamic/dynamic.component.d.ts +38 -0
- package/lib/components/dynamic/index.d.ts +4 -0
- package/lib/components/form/date-edit/date-edit-config.component.d.ts +29 -0
- package/lib/components/form/date-edit/date-edit-config.d.ts +9 -0
- package/lib/components/form/date-edit/date-edit-control.component.d.ts +33 -0
- package/lib/components/form/date-edit/date-edit-view.component.d.ts +17 -0
- package/lib/components/form/date-edit/index.d.ts +2 -0
- package/lib/components/form/form-control-group.d.ts +6 -0
- package/lib/components/form/index.d.ts +6 -0
- package/lib/components/form/numeric-edit/index.d.ts +2 -0
- package/lib/components/form/numeric-edit/numberic-edit-config.component.d.ts +23 -0
- package/lib/components/form/numeric-edit/numberic-edit-config.d.ts +11 -0
- package/lib/components/form/numeric-edit/numberic-edit-control.component.d.ts +34 -0
- package/lib/components/form/numeric-edit/numeric-edit-view.component.d.ts +17 -0
- package/lib/components/form/select/index.d.ts +2 -0
- package/lib/components/form/select/select-config.component.d.ts +31 -0
- package/lib/components/form/select/select-config.d.ts +7 -0
- package/lib/components/form/select/select-control.component.d.ts +29 -0
- package/lib/components/form/select/select-view.component.d.ts +17 -0
- package/lib/components/form/switch/index.d.ts +2 -0
- package/lib/components/form/switch/switch-config.component.d.ts +23 -0
- package/lib/components/form/switch/switch-config.d.ts +5 -0
- package/lib/components/form/switch/switch-control.component.d.ts +28 -0
- package/lib/components/form/switch/switch-view.component.d.ts +17 -0
- package/lib/components/form/text-edit/index.d.ts +3 -0
- package/lib/components/form/text-edit/text-edit-config.component.d.ts +25 -0
- package/lib/components/form/text-edit/text-edit-config.d.ts +7 -0
- package/lib/components/form/text-edit/text-edit-view.component.d.ts +17 -0
- package/lib/components/form/text-edit/text-edit.component.d.ts +30 -0
- package/lib/components/index.d.ts +2 -0
- package/lib/dynamic-form.module.d.ts +32 -0
- package/lib/enums/date-edit-interfaces.d.ts +5 -0
- package/lib/enums/text-edit-mode.d.ts +4 -0
- package/{src/lib/interfaces/form-config-interfaces.ts → lib/interfaces/form-config-interfaces.d.ts} +2 -7
- package/lib/interfaces/index.d.ts +1 -0
- package/lib/services/df-api.service.d.ts +18 -0
- package/lib/services/form-control.service.d.ts +9 -0
- package/lib/services/index.d.ts +1 -0
- package/package.json +15 -2
- package/{src/public-api.ts → public-api.d.ts} +0 -4
- package/ng-package.json +0 -7
- package/src/lib/components/dynamic/dynamic.component.html +0 -2
- package/src/lib/components/dynamic/dynamic.component.scss +0 -0
- package/src/lib/components/dynamic/dynamic.component.spec.ts +0 -21
- package/src/lib/components/dynamic/dynamic.component.ts +0 -121
- package/src/lib/components/dynamic/index.ts +0 -1
- package/src/lib/components/form/date-edit/date-edit-config.component.html +0 -40
- 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 +0 -21
- package/src/lib/components/form/date-edit/date-edit-config.component.ts +0 -87
- package/src/lib/components/form/date-edit/date-edit-config.ts +0 -14
- package/src/lib/components/form/date-edit/date-edit-control.component.html +0 -26
- 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 +0 -21
- package/src/lib/components/form/date-edit/date-edit-control.component.ts +0 -101
- package/src/lib/components/form/date-edit/index.ts +0 -2
- package/src/lib/components/form/form-control-group.ts +0 -64
- package/src/lib/components/form/index.ts +0 -6
- package/src/lib/components/form/numeric-edit/index.ts +0 -2
- package/src/lib/components/form/numeric-edit/numberic-edit-config.component.html +0 -31
- 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 +0 -21
- package/src/lib/components/form/numeric-edit/numberic-edit-config.component.ts +0 -57
- package/src/lib/components/form/numeric-edit/numberic-edit-config.ts +0 -28
- package/src/lib/components/form/numeric-edit/numberic-edit-control.component.html +0 -13
- 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 +0 -21
- package/src/lib/components/form/numeric-edit/numberic-edit-control.component.ts +0 -119
- package/src/lib/components/form/select/index.ts +0 -2
- package/src/lib/components/form/select/select-config.component.html +0 -59
- package/src/lib/components/form/select/select-config.component.scss +0 -0
- package/src/lib/components/form/select/select-config.component.spec.ts +0 -21
- package/src/lib/components/form/select/select-config.component.ts +0 -90
- package/src/lib/components/form/select/select-config.ts +0 -24
- package/src/lib/components/form/select/select-control.component.html +0 -32
- package/src/lib/components/form/select/select-control.component.scss +0 -32
- package/src/lib/components/form/select/select-control.component.spec.ts +0 -21
- package/src/lib/components/form/select/select-control.component.ts +0 -86
- package/src/lib/components/form/switch/index.ts +0 -2
- package/src/lib/components/form/switch/switch-config.component.html +0 -17
- package/src/lib/components/form/switch/switch-config.component.scss +0 -0
- package/src/lib/components/form/switch/switch-config.component.spec.ts +0 -21
- package/src/lib/components/form/switch/switch-config.component.ts +0 -58
- package/src/lib/components/form/switch/switch-config.ts +0 -17
- package/src/lib/components/form/switch/switch-control.component.html +0 -13
- package/src/lib/components/form/switch/switch-control.component.scss +0 -0
- package/src/lib/components/form/switch/switch-control.component.spec.ts +0 -21
- package/src/lib/components/form/switch/switch-control.component.ts +0 -81
- package/src/lib/components/form/text-edit/index.ts +0 -3
- package/src/lib/components/form/text-edit/text-edit-config.component.html +0 -32
- 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 +0 -21
- package/src/lib/components/form/text-edit/text-edit-config.component.ts +0 -59
- package/src/lib/components/form/text-edit/text-edit-config.ts +0 -24
- package/src/lib/components/form/text-edit/text-edit.component.html +0 -17
- 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 +0 -21
- package/src/lib/components/form/text-edit/text-edit.component.ts +0 -91
- package/src/lib/components/index.ts +0 -2
- package/src/lib/dynamic-form.module.ts +0 -74
- package/src/lib/enums/date-edit-interfaces.ts +0 -16
- package/src/lib/enums/index.ts +0 -2
- package/src/lib/enums/text-edit-mode.ts +0 -7
- package/src/lib/interfaces/index.ts +0 -1
- package/src/lib/proxy/README.md +0 -17
- package/src/lib/proxy/dignite/file-explorer/directories/file-descriptor.service.ts +0 -65
- package/src/lib/proxy/dignite/file-explorer/directories/index.ts +0 -2
- package/src/lib/proxy/dignite/file-explorer/directories/models.ts +0 -35
- package/src/lib/proxy/dignite/file-explorer/files/file-descriptor.service.ts +0 -86
- package/src/lib/proxy/dignite/file-explorer/files/index.ts +0 -2
- package/src/lib/proxy/dignite/file-explorer/files/models.ts +0 -57
- package/src/lib/proxy/dignite/file-explorer/index.ts +0 -3
- package/src/lib/proxy/dignite/index.ts +0 -2
- package/src/lib/proxy/generate-proxy.json +0 -11810
- package/src/lib/proxy/index.ts +0 -4
- package/src/lib/proxy/microsoft/asp-net-core/index.ts +0 -2
- package/src/lib/proxy/microsoft/asp-net-core/mvc/index.ts +0 -1
- package/src/lib/proxy/microsoft/asp-net-core/mvc/models.ts +0 -12
- package/src/lib/proxy/microsoft/extensions/index.ts +0 -2
- package/src/lib/proxy/microsoft/extensions/primitives/index.ts +0 -1
- package/src/lib/proxy/microsoft/extensions/primitives/models.ts +0 -9
- package/src/lib/proxy/microsoft/index.ts +0 -4
- package/src/lib/proxy/microsoft/net/http/headers/index.ts +0 -1
- package/src/lib/proxy/microsoft/net/http/headers/models.ts +0 -7
- package/src/lib/proxy/microsoft/net/http/index.ts +0 -2
- package/src/lib/proxy/microsoft/net/index.ts +0 -2
- package/src/lib/proxy/volo/abp/content/index.ts +0 -1
- package/src/lib/proxy/volo/abp/content/models.ts +0 -6
- package/src/lib/proxy/volo/abp/index.ts +0 -2
- package/src/lib/proxy/volo/index.ts +0 -2
- package/src/lib/services/df-api.service.ts +0 -75
- package/src/lib/services/index.ts +0 -1
- package/tsconfig.lib.json +0 -14
- package/tsconfig.lib.prod.json +0 -10
- package/tsconfig.spec.json +0 -14
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { Component, ElementRef, Input, ViewChild, ChangeDetectionStrategy ,ChangeDetectorRef } from '@angular/core';
|
|
2
|
-
import { FormBuilder, FormGroup, ValidatorFn, Validators } from '@angular/forms';
|
|
3
|
-
import { AbstractControl, ValidationErrors } from '@angular/forms';
|
|
4
|
-
|
|
5
|
-
export function maxDecimalPlacesValidator(maxDecimalPlaces: number): ValidatorFn {
|
|
6
|
-
return (control: AbstractControl): ValidationErrors | null => {
|
|
7
|
-
const value = control.value;
|
|
8
|
-
if (typeof value === 'number' && isNaN(value) === false) {
|
|
9
|
-
const decimalPart = value.toString().split('.')[1];
|
|
10
|
-
if (decimalPart && decimalPart.length > maxDecimalPlaces) {
|
|
11
|
-
return { 'maxDecimalPlaces': { actual: decimalPart.length, max: maxDecimalPlaces } };
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
return null;
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
@Component({
|
|
18
|
-
selector: 'df-numberic-edit-control',
|
|
19
|
-
templateUrl: './numberic-edit-control.component.html',
|
|
20
|
-
styleUrls: ['./numberic-edit-control.component.scss'],
|
|
21
|
-
changeDetection: ChangeDetectionStrategy.OnPush
|
|
22
|
-
})
|
|
23
|
-
export class NumbericEditControlComponent {
|
|
24
|
-
|
|
25
|
-
constructor(
|
|
26
|
-
private fb: FormBuilder,
|
|
27
|
-
private cdr: ChangeDetectorRef
|
|
28
|
-
) {
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
public get entity(): any {
|
|
34
|
-
return this._entity
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
/**字段配置列表 */
|
|
39
|
-
_fields: any = ''
|
|
40
|
-
@Input()
|
|
41
|
-
public set fields(v: any) {
|
|
42
|
-
this._fields = v;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**父级字段名称,用于为表单设置控件赋值 */
|
|
46
|
-
_parentFiledName: any
|
|
47
|
-
@Input()
|
|
48
|
-
public set parentFiledName(v: any) {
|
|
49
|
-
this._parentFiledName = v;
|
|
50
|
-
}
|
|
51
|
-
/**父级字段名称,用于为表单设置控件赋值 */
|
|
52
|
-
_selected: any
|
|
53
|
-
@Input()
|
|
54
|
-
public set selected(v: any) {
|
|
55
|
-
this._selected = v ;
|
|
56
|
-
//
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**表单实体 */
|
|
60
|
-
_entity: FormGroup | undefined
|
|
61
|
-
@Input()
|
|
62
|
-
public set entity(v: any) {
|
|
63
|
-
this._entity = v;
|
|
64
|
-
this.dataLoaded()
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
@ViewChild('submitclick', { static: true }) submitclick: ElementRef;
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
get extraProperties() {
|
|
71
|
-
return this._entity?.get('extraProperties') as FormGroup
|
|
72
|
-
}
|
|
73
|
-
get fieldInput() { return this.extraProperties.get(this._fields.field.name); }
|
|
74
|
-
/**数据加载完成 */
|
|
75
|
-
async dataLoaded() {
|
|
76
|
-
if (this._fields && this._entity) {
|
|
77
|
-
await this.AfterInit()
|
|
78
|
-
this.cdr.detectChanges();
|
|
79
|
-
this.submitclick.nativeElement.click();
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
AfterInit() {
|
|
84
|
-
return new Promise((resolve, rejects) => {
|
|
85
|
-
let ValidatorsArray:any[] = []
|
|
86
|
-
let formConfiguration=this._fields.field.formConfiguration
|
|
87
|
-
if (this._fields.required) {
|
|
88
|
-
ValidatorsArray.push(Validators.required)
|
|
89
|
-
}
|
|
90
|
-
if (formConfiguration['NumericEditField.Min']) {
|
|
91
|
-
ValidatorsArray.push(Validators.min(formConfiguration['NumericEditField.Min']))
|
|
92
|
-
}
|
|
93
|
-
if (formConfiguration['NumericEditField.Max']) {
|
|
94
|
-
ValidatorsArray.push(Validators.max(formConfiguration['NumericEditField.Max']))
|
|
95
|
-
}
|
|
96
|
-
let newControl = this.fb.control(this._selected, ValidatorsArray)
|
|
97
|
-
this.extraProperties.setControl(this._fields.field.name, newControl)
|
|
98
|
-
|
|
99
|
-
resolve(true)
|
|
100
|
-
})
|
|
101
|
-
}
|
|
102
|
-
ngOnDestroy(): void {
|
|
103
|
-
//Called once, before the instance is destroyed.
|
|
104
|
-
//Add 'implements OnDestroy' to the class.
|
|
105
|
-
this.extraProperties.removeControl(this._fields.field.name)
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/**数字框输入 */
|
|
109
|
-
inputchange(event){
|
|
110
|
-
let val=event.target.value;
|
|
111
|
-
|
|
112
|
-
const decimalPart = val.toString().split('.')[1]||'';
|
|
113
|
-
let formConfiguration=this._fields.field.formConfiguration;
|
|
114
|
-
let Decimals=formConfiguration['NumericEditField.Decimals'];
|
|
115
|
-
if(decimalPart.length>Decimals){
|
|
116
|
-
this.fieldInput?.patchValue(val.slice(0,val.length-(decimalPart.length-2)));
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
<form [formGroup]="_Entity">
|
|
2
|
-
<div formGroupName="formConfiguration">
|
|
3
|
-
<div class="mb-3">
|
|
4
|
-
<label class="form-label">{{'DigniteAbpForms::SelectListItem' | abpLocalization}}</label>
|
|
5
|
-
<table class="table">
|
|
6
|
-
<thead>
|
|
7
|
-
<tr>
|
|
8
|
-
<th scope="col">{{'DigniteAbpForms::SelectListItemText' | abpLocalization}}</th>
|
|
9
|
-
<th scope="col">{{'DigniteAbpForms::SelectListItemValue' | abpLocalization}}</th>
|
|
10
|
-
<th scope="col">{{'DigniteAbpForms::Selected' | abpLocalization}}</th>
|
|
11
|
-
<th scope="col" style="width: 1%;">
|
|
12
|
-
<button class="btn btn-light btn-sm" (click.stop)="addSelectOptions()">
|
|
13
|
-
<i class="fas fa-plus-circle"></i>
|
|
14
|
-
</button>
|
|
15
|
-
</th>
|
|
16
|
-
</tr>
|
|
17
|
-
</thead>
|
|
18
|
-
<tbody formArrayName="Select.Options">
|
|
19
|
-
<ng-container *ngFor="let item of SelectOptions.controls;let i=index">
|
|
20
|
-
<tr [formGroupName]="i">
|
|
21
|
-
<td><input type="text" class="form-control" formControlName="Text" (change)="textChange($event,i)"></td>
|
|
22
|
-
<td><input type="text" class="form-control" formControlName="Value"></td>
|
|
23
|
-
<td>
|
|
24
|
-
<div class="form-check form-check-inline">
|
|
25
|
-
<input class="form-check-input" type="checkbox" formControlName="Selected" id="selected">
|
|
26
|
-
</div>
|
|
27
|
-
</td>
|
|
28
|
-
<td scope="row" style="width: 1%;">
|
|
29
|
-
<button class="btn btn-light btn-sm" (click.stop)="deleteSelectOptions(i)">
|
|
30
|
-
<i class="fas fa-minus"></i>
|
|
31
|
-
</button>
|
|
32
|
-
</td>
|
|
33
|
-
</tr>
|
|
34
|
-
</ng-container>
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
</tbody>
|
|
38
|
-
</table>
|
|
39
|
-
</div>
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
<div class="mb-3">
|
|
44
|
-
<label class="form-label">{{'DigniteAbpForms::NullText' | abpLocalization}}</label>
|
|
45
|
-
<input type="text" class="form-control" formControlName="Select.NullText">
|
|
46
|
-
</div>
|
|
47
|
-
<div class="mb-3">
|
|
48
|
-
<div class="form-check form-check-inline">
|
|
49
|
-
<input class="form-check-input" type="checkbox" formControlName="Select.Multiple"
|
|
50
|
-
id="Multiple">
|
|
51
|
-
<label class="form-check-label" for="Multiple">
|
|
52
|
-
{{'DigniteAbpForms::Multiple' | abpLocalization}}
|
|
53
|
-
</label>
|
|
54
|
-
</div>
|
|
55
|
-
</div>
|
|
56
|
-
<button type="submit" (abpInit)="submitclick?.nativeElement?.click()" style="display: none;"
|
|
57
|
-
#submitclick></button>
|
|
58
|
-
</div>
|
|
59
|
-
</form>
|
|
File without changes
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
-
|
|
3
|
-
import { SelectConfigComponent } from './select-config.component';
|
|
4
|
-
|
|
5
|
-
describe('SelectConfigComponent', () => {
|
|
6
|
-
let component: SelectConfigComponent;
|
|
7
|
-
let fixture: ComponentFixture<SelectConfigComponent>;
|
|
8
|
-
|
|
9
|
-
beforeEach(() => {
|
|
10
|
-
TestBed.configureTestingModule({
|
|
11
|
-
declarations: [SelectConfigComponent]
|
|
12
|
-
});
|
|
13
|
-
fixture = TestBed.createComponent(SelectConfigComponent);
|
|
14
|
-
component = fixture.componentInstance;
|
|
15
|
-
fixture.detectChanges();
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it('should create', () => {
|
|
19
|
-
expect(component).toBeTruthy();
|
|
20
|
-
});
|
|
21
|
-
});
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { ChangeDetectorRef, Component, ElementRef, inject, Input, ViewChild } from '@angular/core';
|
|
2
|
-
import { FormArray, FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';
|
|
3
|
-
import { SelectConfig } from './select-config';
|
|
4
|
-
import { DfApiService } from '../../../services';
|
|
5
|
-
|
|
6
|
-
@Component({
|
|
7
|
-
selector: 'df-select-config',
|
|
8
|
-
|
|
9
|
-
templateUrl: './select-config.component.html',
|
|
10
|
-
styleUrls: ['./select-config.component.scss'],
|
|
11
|
-
})
|
|
12
|
-
export class SelectConfigComponent {
|
|
13
|
-
constructor(private fb: FormBuilder, private _DfApiService: DfApiService) {}
|
|
14
|
-
/**表单控件类型 */
|
|
15
|
-
_type: any;
|
|
16
|
-
@Input()
|
|
17
|
-
public set type(v: any) {
|
|
18
|
-
this._type = v;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**选择的表单信息 */
|
|
22
|
-
_selected: any;
|
|
23
|
-
@Input()
|
|
24
|
-
public set selected(v: any) {
|
|
25
|
-
this._selected = v;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**表单实体 */
|
|
29
|
-
_Entity: FormGroup | undefined;
|
|
30
|
-
@Input()
|
|
31
|
-
public set Entity(v: FormGroup) {
|
|
32
|
-
this._Entity = v;
|
|
33
|
-
this.dataLoaded();
|
|
34
|
-
}
|
|
35
|
-
get formConfiguration() {
|
|
36
|
-
return this._Entity.get('formConfiguration') as FormGroup;
|
|
37
|
-
}
|
|
38
|
-
get SelectOptions() {
|
|
39
|
-
return this.formConfiguration.controls['Select.Options'] as FormArray;
|
|
40
|
-
}
|
|
41
|
-
@ViewChild('submitclick', { static: true }) submitclick: ElementRef;
|
|
42
|
-
private cdr = inject(ChangeDetectorRef);
|
|
43
|
-
async dataLoaded() {
|
|
44
|
-
if (this._Entity && this._type) {
|
|
45
|
-
await this.AfterInit();
|
|
46
|
-
this.cdr.detectChanges(); // 手动触发变更检测
|
|
47
|
-
this.submitclick?.nativeElement?.click();
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
/**增加选项 */
|
|
51
|
-
addSelectOptions() {
|
|
52
|
-
this.SelectOptions.push(
|
|
53
|
-
new FormGroup({
|
|
54
|
-
Text: new FormControl('', Validators.required),
|
|
55
|
-
Value: new FormControl('', Validators.required),
|
|
56
|
-
Selected: new FormControl(false),
|
|
57
|
-
})
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
/**删除某个选项 */
|
|
61
|
-
deleteSelectOptions(index) {
|
|
62
|
-
this.SelectOptions.removeAt(index);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
AfterInit() {
|
|
66
|
-
return new Promise((resolve, rejects) => {
|
|
67
|
-
this._Entity.setControl('formConfiguration', this.fb.group(new SelectConfig()));
|
|
68
|
-
if (this._selected && this._selected.formControlName == this._type) {
|
|
69
|
-
this._selected.formConfiguration['Select.Options']?.forEach(el => {
|
|
70
|
-
this.addSelectOptions();
|
|
71
|
-
});
|
|
72
|
-
this.formConfiguration.patchValue({
|
|
73
|
-
...this._selected.formConfiguration,
|
|
74
|
-
});
|
|
75
|
-
} else {
|
|
76
|
-
this.addSelectOptions();
|
|
77
|
-
}
|
|
78
|
-
resolve(true);
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
textChange(event, index) {
|
|
83
|
-
let SelectOptionsItem = this.SelectOptions.at(index);
|
|
84
|
-
let value = event.target.value;
|
|
85
|
-
if (SelectOptionsItem.get('Value').value) return;
|
|
86
|
-
SelectOptionsItem.patchValue({
|
|
87
|
-
Value: this._DfApiService.chineseToPinyin(value),
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { FormArray, FormControl, Validators } from "@angular/forms";
|
|
2
|
-
|
|
3
|
-
export class SelectConfig {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
/**空值文本 */
|
|
7
|
-
'Select.NullText': any = ['', []];
|
|
8
|
-
//多选
|
|
9
|
-
'Select.Multiple': any = [false, []];
|
|
10
|
-
// 选项
|
|
11
|
-
'Select.Options': any = new FormArray([])
|
|
12
|
-
|
|
13
|
-
constructor(data?: SelectConfig) {
|
|
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
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
<form [formGroup]="_entity">
|
|
2
|
-
<div formGroupName="extraProperties" class="selectcontrol">
|
|
3
|
-
<div class="mb-3">
|
|
4
|
-
<label class="form-label" *ngIf="_fields.displayName">{{ _fields.displayName }}</label>
|
|
5
|
-
<ng-container *ngIf="formConfiguration['Select.Multiple']; else elseTemplate">
|
|
6
|
-
<!-- <select class="form-select" multiple formControlName="{{_fields.field.name}}">
|
|
7
|
-
<ng-container *ngFor="let item of _fields.field.formConfiguration['Select.Options'];let i =index">
|
|
8
|
-
<option [value]="item.Value">{{item.Text}}</option>
|
|
9
|
-
</ng-container>
|
|
10
|
-
</select> -->
|
|
11
|
-
<nz-select class="form-select form-select-multiple" [nzMaxTagCount]="1"
|
|
12
|
-
nzShowSearch nzMode="multiple"
|
|
13
|
-
formControlName="{{_fields.field.name}}">
|
|
14
|
-
<nz-option *ngFor="let item of _fields.field.formConfiguration['Select.Options']"
|
|
15
|
-
[nzLabel]="item.Text" [nzValue]="item.Value"></nz-option>
|
|
16
|
-
</nz-select>
|
|
17
|
-
</ng-container>
|
|
18
|
-
<ng-template #elseTemplate>
|
|
19
|
-
<select class="form-select" [multiple]="false" formControlName="{{_fields.field.name}}">
|
|
20
|
-
<option [value]="">{{formConfiguration['Select.NullText']}}</option>
|
|
21
|
-
<ng-container *ngFor="let item of _fields.field.formConfiguration['Select.Options'];let i =index">
|
|
22
|
-
<option [value]="item.Value">{{item.Text}}</option>
|
|
23
|
-
</ng-container>
|
|
24
|
-
</select>
|
|
25
|
-
</ng-template>
|
|
26
|
-
<small class="form-text text-muted d-block"
|
|
27
|
-
*ngIf="_fields.field.description">{{_fields.field.description}}</small>
|
|
28
|
-
</div>
|
|
29
|
-
|
|
30
|
-
</div>
|
|
31
|
-
<button type="submit" style="display: none;" #submitclick></button>
|
|
32
|
-
</form>
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
::ng-deep .selectcontrol {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
nz-select {
|
|
5
|
-
width: 100%;
|
|
6
|
-
|
|
7
|
-
.ant-select-selector {
|
|
8
|
-
background: transparent !important;
|
|
9
|
-
border: none !important;
|
|
10
|
-
padding: .275rem 1.25rem !important;
|
|
11
|
-
box-shadow: none !important;
|
|
12
|
-
height: auto !important
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.anticon-search,
|
|
16
|
-
.anticon-down {
|
|
17
|
-
display: none
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
.ant-select-multiple .ant-select-selection-item{
|
|
21
|
-
max-width: 40% !important;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
::ng-deep .was-validated .form-select-multiple {
|
|
26
|
-
border-color: #4fbf67;
|
|
27
|
-
padding-right: calc(1.5em + 1.35rem);
|
|
28
|
-
background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3e%3cpath fill='%234fbf67' d='M2.3 6.73.6 4.53c-.4-1.04.46-1.4 1.1-.8l1.1 1.4 3.4-3.8c.6-.63 1.6-.27 1.2.7l-4 4.6c-.43.5-.8.4-1.1.1z'/%3e%3c/svg%3e");
|
|
29
|
-
background-repeat: no-repeat;
|
|
30
|
-
background-position: right calc(0.375em + 0.3375rem) center;
|
|
31
|
-
background-size: calc(0.75em + 0.675rem) calc(0.75em + 0.675rem);
|
|
32
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
-
|
|
3
|
-
import { SelectControlComponent } from './select-control.component';
|
|
4
|
-
|
|
5
|
-
describe('SelectControlComponent', () => {
|
|
6
|
-
let component: SelectControlComponent;
|
|
7
|
-
let fixture: ComponentFixture<SelectControlComponent>;
|
|
8
|
-
|
|
9
|
-
beforeEach(() => {
|
|
10
|
-
TestBed.configureTestingModule({
|
|
11
|
-
declarations: [SelectControlComponent]
|
|
12
|
-
});
|
|
13
|
-
fixture = TestBed.createComponent(SelectControlComponent);
|
|
14
|
-
component = fixture.componentInstance;
|
|
15
|
-
fixture.detectChanges();
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it('should create', () => {
|
|
19
|
-
expect(component).toBeTruthy();
|
|
20
|
-
});
|
|
21
|
-
});
|
|
@@ -1,86 +0,0 @@
|
|
|
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-select-control',
|
|
6
|
-
templateUrl: './select-control.component.html',
|
|
7
|
-
styleUrls: ['./select-control.component.scss'],
|
|
8
|
-
})
|
|
9
|
-
export class SelectControlComponent {
|
|
10
|
-
constructor(private fb: FormBuilder) {}
|
|
11
|
-
|
|
12
|
-
/**字段配置列表 */
|
|
13
|
-
_fields: any = '';
|
|
14
|
-
@Input()
|
|
15
|
-
public set fields(v: any) {
|
|
16
|
-
this._fields = v;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**父级字段名称,用于为表单设置控件赋值 */
|
|
20
|
-
_parentFiledName: any;
|
|
21
|
-
@Input()
|
|
22
|
-
public set parentFiledName(v: any) {
|
|
23
|
-
this._parentFiledName = v;
|
|
24
|
-
}
|
|
25
|
-
/**父级字段名称,用于为表单设置控件赋值 */
|
|
26
|
-
_selected: any;
|
|
27
|
-
@Input()
|
|
28
|
-
public set selected(v: any) {
|
|
29
|
-
this._selected = v;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**表单实体 */
|
|
33
|
-
_entity: FormGroup | undefined;
|
|
34
|
-
@Input()
|
|
35
|
-
public set entity(v: any) {
|
|
36
|
-
this._entity = v;
|
|
37
|
-
this.dataLoaded();
|
|
38
|
-
}
|
|
39
|
-
@ViewChild('submitclick', { static: true }) submitclick: ElementRef;
|
|
40
|
-
|
|
41
|
-
get extraProperties() {
|
|
42
|
-
return this._entity?.get('extraProperties') as FormGroup;
|
|
43
|
-
}
|
|
44
|
-
private cdr = inject(ChangeDetectorRef);
|
|
45
|
-
/**数据加载完成 */
|
|
46
|
-
async dataLoaded() {
|
|
47
|
-
if (this._fields && this._entity) {
|
|
48
|
-
await this.AfterInit();
|
|
49
|
-
this.cdr.detectChanges(); // 手动触发变更检测
|
|
50
|
-
this.submitclick?.nativeElement?.click();
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
formConfiguration: any = '';
|
|
55
|
-
AfterInit() {
|
|
56
|
-
return new Promise((resolve, rejects) => {
|
|
57
|
-
let ValidatorsArray:any[] = [];
|
|
58
|
-
if (this._fields.required) {
|
|
59
|
-
ValidatorsArray.push(Validators.required);
|
|
60
|
-
}
|
|
61
|
-
this.formConfiguration = this._fields.field.formConfiguration;
|
|
62
|
-
if (!this._selected) {
|
|
63
|
-
const isMultiple = this.formConfiguration['Select.Multiple'];
|
|
64
|
-
|
|
65
|
-
let selectValue:any = isMultiple ? [] : '';
|
|
66
|
-
this.formConfiguration['Select.Options'].forEach(el => {
|
|
67
|
-
if (el.Selected) {
|
|
68
|
-
selectValue = isMultiple
|
|
69
|
-
? [...selectValue, el.value || el.Value]
|
|
70
|
-
: [el.value || el.Value];
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
this._selected = selectValue;
|
|
75
|
-
}
|
|
76
|
-
let newControl = this.fb.control(this._selected, ValidatorsArray);
|
|
77
|
-
this.extraProperties.setControl(this._fields.field.name, newControl);
|
|
78
|
-
resolve(true);
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
ngOnDestroy(): void {
|
|
82
|
-
//Called once, before the instance is destroyed.
|
|
83
|
-
//Add 'implements OnDestroy' to the class.
|
|
84
|
-
this.extraProperties.removeControl(this._fields.field.name);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
<form [formGroup]="_Entity">
|
|
2
|
-
<div formGroupName="formConfiguration">
|
|
3
|
-
<div class="mb-3">
|
|
4
|
-
<div>
|
|
5
|
-
<div class="form-check form-check-inline">
|
|
6
|
-
<input class="form-check-input" type="checkbox" formControlName="Switch.Default"
|
|
7
|
-
id="flexRadioDefault1">
|
|
8
|
-
<label class="form-check-label" for="flexRadioDefault1">
|
|
9
|
-
{{'DigniteAbpForms::DefaultValue' | abpLocalization}}
|
|
10
|
-
</label>
|
|
11
|
-
</div>
|
|
12
|
-
|
|
13
|
-
</div>
|
|
14
|
-
</div>
|
|
15
|
-
<button type="submit" (abpInit)="submitclick?.nativeElement?.click()" style="display: none;" #submitclick></button>
|
|
16
|
-
</div>
|
|
17
|
-
</form>
|
|
File without changes
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
-
|
|
3
|
-
import { SwitchConfigComponent } from './switch-config.component';
|
|
4
|
-
|
|
5
|
-
describe('SwitchConfigComponent', () => {
|
|
6
|
-
let component: SwitchConfigComponent;
|
|
7
|
-
let fixture: ComponentFixture<SwitchConfigComponent>;
|
|
8
|
-
|
|
9
|
-
beforeEach(() => {
|
|
10
|
-
TestBed.configureTestingModule({
|
|
11
|
-
declarations: [SwitchConfigComponent]
|
|
12
|
-
});
|
|
13
|
-
fixture = TestBed.createComponent(SwitchConfigComponent);
|
|
14
|
-
component = fixture.componentInstance;
|
|
15
|
-
fixture.detectChanges();
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it('should create', () => {
|
|
19
|
-
expect(component).toBeTruthy();
|
|
20
|
-
});
|
|
21
|
-
});
|
|
@@ -1,58 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
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
|
|
@@ -1,21 +0,0 @@
|
|
|
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
|
-
});
|