@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
package/ng-package.json
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dignite-ng/expand.dynamic-form",
|
|
3
|
-
"version": "3.0.0-rc.
|
|
3
|
+
"version": "3.0.0-rc.6",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"@angular/common": "~18.1.0",
|
|
6
6
|
"@angular/core": "~18.1.0"
|
|
@@ -12,18 +12,5 @@
|
|
|
12
12
|
"publishConfig": {
|
|
13
13
|
"access": "public",
|
|
14
14
|
"registry": "https://registry.npmjs.org/"
|
|
15
|
-
},
|
|
16
|
-
"module": "fesm2022/dignite-ng-expand.dynamic-form.mjs",
|
|
17
|
-
"typings": "index.d.ts",
|
|
18
|
-
"exports": {
|
|
19
|
-
"./package.json": {
|
|
20
|
-
"default": "./package.json"
|
|
21
|
-
},
|
|
22
|
-
".": {
|
|
23
|
-
"types": "./index.d.ts",
|
|
24
|
-
"esm2022": "./esm2022/dignite-ng-expand.dynamic-form.mjs",
|
|
25
|
-
"esm": "./esm2022/dignite-ng-expand.dynamic-form.mjs",
|
|
26
|
-
"default": "./fesm2022/dignite-ng-expand.dynamic-form.mjs"
|
|
27
|
-
}
|
|
28
15
|
}
|
|
29
|
-
}
|
|
16
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { DynamicComponent } from './dynamic.component';
|
|
4
|
+
|
|
5
|
+
describe('DynamicComponent', () => {
|
|
6
|
+
let component: DynamicComponent;
|
|
7
|
+
let fixture: ComponentFixture<DynamicComponent>;
|
|
8
|
+
|
|
9
|
+
beforeEach(() => {
|
|
10
|
+
TestBed.configureTestingModule({
|
|
11
|
+
declarations: [DynamicComponent]
|
|
12
|
+
});
|
|
13
|
+
fixture = TestBed.createComponent(DynamicComponent);
|
|
14
|
+
component = fixture.componentInstance;
|
|
15
|
+
fixture.detectChanges();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('should create', () => {
|
|
19
|
+
expect(component).toBeTruthy();
|
|
20
|
+
});
|
|
21
|
+
});
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { Component, Inject, Input, ViewChild, ViewContainerRef } from '@angular/core';
|
|
2
|
+
import { FormGroup } from '@angular/forms';
|
|
3
|
+
import { FieldControlGroupInterfaces } from '../../interfaces';
|
|
4
|
+
import { AddFieldControlGroup, } from '../form';
|
|
5
|
+
|
|
6
|
+
@Component({
|
|
7
|
+
selector: 'df-dynamic',
|
|
8
|
+
templateUrl: './dynamic.component.html',
|
|
9
|
+
styleUrls: ['./dynamic.component.scss'],
|
|
10
|
+
})
|
|
11
|
+
export class DynamicComponent {
|
|
12
|
+
|
|
13
|
+
/**选择的表单信息 */
|
|
14
|
+
_selected: any;
|
|
15
|
+
@Input()
|
|
16
|
+
public set selected(v: any) {
|
|
17
|
+
this._selected = v === undefined ? '' : v === null ? '' : v;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**表单控件类型 */
|
|
21
|
+
_type: string;
|
|
22
|
+
@Input()
|
|
23
|
+
public set type(v: string) {
|
|
24
|
+
this._type = v;
|
|
25
|
+
if (this._entity) this.dataLoaded(3);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**语言 */
|
|
29
|
+
_culture: FormGroup | undefined;
|
|
30
|
+
@Input()
|
|
31
|
+
public set culture(v: any) {
|
|
32
|
+
this._culture = v;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**父级字段名称,用于为表单设置控件赋值 */
|
|
36
|
+
_parentFiledName: any;
|
|
37
|
+
@Input()
|
|
38
|
+
public set parentFiledName(v: any) {
|
|
39
|
+
this._parentFiledName = v;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**字段配置列表 */
|
|
43
|
+
_fields: any = '';
|
|
44
|
+
@Input()
|
|
45
|
+
public set fields(v: any) {
|
|
46
|
+
this._fields = v;
|
|
47
|
+
}
|
|
48
|
+
/**表单实体 */
|
|
49
|
+
_entity: FormGroup | undefined;
|
|
50
|
+
@Input()
|
|
51
|
+
public set entity(v: any) {
|
|
52
|
+
if (v) {
|
|
53
|
+
this._entity = v;
|
|
54
|
+
this.dataLoaded(3);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**表单控件模板-动态表单配置组件 */
|
|
59
|
+
@ViewChild('FormControlRef', { read: ViewContainerRef, static: true })
|
|
60
|
+
FormControlRef?: ViewContainerRef;
|
|
61
|
+
|
|
62
|
+
/**表单控件模板-动态表单组件 */
|
|
63
|
+
@ViewChild('FormComponentsRef', { read: ViewContainerRef, static: true })
|
|
64
|
+
FormComponentsRef?: ViewContainerRef;
|
|
65
|
+
|
|
66
|
+
constructor(@Inject('MERGED_FORM_CONFIG') private mergedConfig: any[]) {}
|
|
67
|
+
|
|
68
|
+
/**数据加载完成 */
|
|
69
|
+
async dataLoaded(val) {
|
|
70
|
+
let _fieldControlGroup: any[] = AddFieldControlGroup(this.mergedConfig);
|
|
71
|
+
if (this._entity) {
|
|
72
|
+
//加载所有的动态表单组件
|
|
73
|
+
if (this._type) {
|
|
74
|
+
let fieldControlItem = _fieldControlGroup.find(el => el.name === this._type);
|
|
75
|
+
this.loadfieldConfigComponent(fieldControlItem);
|
|
76
|
+
}
|
|
77
|
+
if (this._fields && this._parentFiledName && this._culture) {
|
|
78
|
+
|
|
79
|
+
/**表单控件组中的项 */
|
|
80
|
+
let fieldControlItem = _fieldControlGroup.find(
|
|
81
|
+
el => el.name === this._fields?.field?.formControlName
|
|
82
|
+
);
|
|
83
|
+
this.loadfieldComponent(fieldControlItem);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**加载动态表单配置组件 */
|
|
89
|
+
loadfieldConfigComponent(FieldControlItem?: FieldControlGroupInterfaces) {
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
//清空了容器中的所有组件
|
|
93
|
+
this.FormControlRef?.clear();
|
|
94
|
+
if (!FieldControlItem || !FieldControlItem.fieldConfigComponent) return;
|
|
95
|
+
//在容器中创建组件
|
|
96
|
+
const { instance } = this.FormControlRef?.createComponent(
|
|
97
|
+
FieldControlItem.fieldConfigComponent
|
|
98
|
+
); //创建组件模板
|
|
99
|
+
/**向创建的组件模板中传值 */
|
|
100
|
+
instance.selected = this._selected;
|
|
101
|
+
instance.type = this._type;
|
|
102
|
+
instance.Entity = this._entity;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**加载动态表单组件 */
|
|
106
|
+
loadfieldComponent(FieldControlItem?: FieldControlGroupInterfaces) {
|
|
107
|
+
// this.FormControlRef.clear
|
|
108
|
+
//清空了容器中的所有组件
|
|
109
|
+
this.FormComponentsRef?.clear();
|
|
110
|
+
if (!FieldControlItem || !FieldControlItem.fieldComponent) return;
|
|
111
|
+
//在容器中创建组件
|
|
112
|
+
const { instance } = this.FormComponentsRef?.createComponent(FieldControlItem.fieldComponent); //创建组件模板
|
|
113
|
+
/**向创建的组件模板中传值 */
|
|
114
|
+
instance.fields = this._fields;
|
|
115
|
+
instance.parentFiledName = this._parentFiledName;
|
|
116
|
+
instance.selected = this._selected;
|
|
117
|
+
instance.culture = this._culture;
|
|
118
|
+
instance.entity = this._entity;
|
|
119
|
+
|
|
120
|
+
}
|
|
121
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dynamic.component'
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<form [formGroup]="_Entity">
|
|
2
|
+
<div formGroupName="formConfiguration">
|
|
3
|
+
<div class="mb-3">
|
|
4
|
+
<label class="form-label">{{'DigniteAbpForms::DateEditMode' | abpLocalization}}</label>
|
|
5
|
+
<div>
|
|
6
|
+
<div class="form-check form-check-inline">
|
|
7
|
+
<input class="form-check-input" type="radio" [value]="_DateEditInterfaces.Date"
|
|
8
|
+
formControlName="DateEdit.InputMode" id="flexRadioDefault1" (change)="timeTypeChange()">
|
|
9
|
+
<label class="form-check-label" for="flexRadioDefault1">
|
|
10
|
+
{{'DigniteAbpForms::Date' | abpLocalization}}
|
|
11
|
+
</label>
|
|
12
|
+
</div>
|
|
13
|
+
<div class="form-check form-check-inline">
|
|
14
|
+
<input class="form-check-input" type="radio" [value]="_DateEditInterfaces.DateTime"
|
|
15
|
+
formControlName="DateEdit.InputMode" id="flexRadioDefault2" (change)="timeTypeChange()">
|
|
16
|
+
<label class="form-check-label" for="flexRadioDefault2">
|
|
17
|
+
{{'DigniteAbpForms::DateTime' | abpLocalization}}
|
|
18
|
+
</label>
|
|
19
|
+
</div>
|
|
20
|
+
<div class="form-check form-check-inline">
|
|
21
|
+
<input class="form-check-input" type="radio" [value]="_DateEditInterfaces.Month"
|
|
22
|
+
formControlName="DateEdit.InputMode" id="flexRadioDefault3" (change)="timeTypeChange()">
|
|
23
|
+
<label class="form-check-label" for="flexRadioDefault3">
|
|
24
|
+
{{'DigniteAbpForms::Month' | abpLocalization}}
|
|
25
|
+
</label>
|
|
26
|
+
</div>
|
|
27
|
+
</div>
|
|
28
|
+
</div>
|
|
29
|
+
<div class="mb-3">
|
|
30
|
+
<label class="form-label">{{'DigniteAbpForms::Min' | abpLocalization}}</label>
|
|
31
|
+
<input [type]="dateTimeType" class="form-control" step="1" formControlName="DateEdit.Min">
|
|
32
|
+
</div>
|
|
33
|
+
<div class="mb-3">
|
|
34
|
+
<label class="form-label">{{'DigniteAbpForms::Max' | abpLocalization}}</label>
|
|
35
|
+
<input [type]="dateTimeType" class="form-control" step="1" formControlName="DateEdit.Max">
|
|
36
|
+
</div>
|
|
37
|
+
<button type="submit" (abpInit)="submitclick?.nativeElement?.click()" style="display: none;"
|
|
38
|
+
#submitclick></button>
|
|
39
|
+
</div>
|
|
40
|
+
</form>
|
|
File without changes
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { DateEditConfigComponent } from './date-edit-config.component';
|
|
4
|
+
|
|
5
|
+
describe('DateEditConfigComponent', () => {
|
|
6
|
+
let component: DateEditConfigComponent;
|
|
7
|
+
let fixture: ComponentFixture<DateEditConfigComponent>;
|
|
8
|
+
|
|
9
|
+
beforeEach(() => {
|
|
10
|
+
TestBed.configureTestingModule({
|
|
11
|
+
declarations: [DateEditConfigComponent]
|
|
12
|
+
});
|
|
13
|
+
fixture = TestBed.createComponent(DateEditConfigComponent);
|
|
14
|
+
component = fixture.componentInstance;
|
|
15
|
+
fixture.detectChanges();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('should create', () => {
|
|
19
|
+
expect(component).toBeTruthy();
|
|
20
|
+
});
|
|
21
|
+
});
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { ChangeDetectorRef, Component, ElementRef, inject, Input, ViewChild } from '@angular/core';
|
|
2
|
+
import { FormBuilder, FormControl, FormGroup } from '@angular/forms';
|
|
3
|
+
import { DateEditConfig } from './date-edit-config';
|
|
4
|
+
import { DateEditInterfaces } from '../../../enums/date-edit-interfaces';
|
|
5
|
+
import { DatePipe } from '@angular/common';
|
|
6
|
+
|
|
7
|
+
@Component({
|
|
8
|
+
selector: 'df-date-edit-config',
|
|
9
|
+
templateUrl: './date-edit-config.component.html',
|
|
10
|
+
styleUrls: ['./date-edit-config.component.scss'],
|
|
11
|
+
})
|
|
12
|
+
export class DateEditConfigComponent {
|
|
13
|
+
constructor(private fb: FormBuilder) {}
|
|
14
|
+
private _dataPipe = inject(DatePipe);
|
|
15
|
+
_DateEditInterfaces = DateEditInterfaces;
|
|
16
|
+
/**表单控件类型 */
|
|
17
|
+
_type: any;
|
|
18
|
+
@Input()
|
|
19
|
+
public set type(v: any) {
|
|
20
|
+
this._type = v;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**选择的表单信息 */
|
|
24
|
+
_selected: any;
|
|
25
|
+
@Input()
|
|
26
|
+
public set selected(v: any) {
|
|
27
|
+
this._selected = v;
|
|
28
|
+
}
|
|
29
|
+
/**表单实体 */
|
|
30
|
+
_Entity: FormGroup | undefined;
|
|
31
|
+
@Input()
|
|
32
|
+
public set Entity(v: FormGroup) {
|
|
33
|
+
this._Entity = v;
|
|
34
|
+
this.dataLoaded();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
dateTimeType: any = 'date';
|
|
38
|
+
get formConfiguration() {
|
|
39
|
+
return this._Entity.get('formConfiguration') as FormGroup;
|
|
40
|
+
}
|
|
41
|
+
@ViewChild('submitclick', { static: true }) submitclick: ElementRef;
|
|
42
|
+
|
|
43
|
+
private cdr = inject(ChangeDetectorRef);
|
|
44
|
+
async dataLoaded() {
|
|
45
|
+
if (this._Entity && this._type) {
|
|
46
|
+
await this.AfterInit();
|
|
47
|
+
this.cdr.detectChanges(); // 手动触发变更检测
|
|
48
|
+
this.submitclick?.nativeElement?.click();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
AfterInit() {
|
|
53
|
+
return new Promise((resolve, rejects) => {
|
|
54
|
+
this._Entity.setControl('formConfiguration', this.fb.group(new DateEditConfig()));
|
|
55
|
+
if (this._selected && this._selected.formControlName == this._type) {
|
|
56
|
+
this.formConfiguration.patchValue({
|
|
57
|
+
...this._selected.formConfiguration,
|
|
58
|
+
});
|
|
59
|
+
this.timeTypeChange()
|
|
60
|
+
}
|
|
61
|
+
resolve(true);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
/**切换时间类型 */
|
|
65
|
+
timeTypeChange() {
|
|
66
|
+
let type = this.formConfiguration.value['DateEdit.InputMode'];
|
|
67
|
+
let Min = this.formConfiguration.value['DateEdit.Min'];
|
|
68
|
+
let Max = this.formConfiguration.value['DateEdit.Max'];
|
|
69
|
+
if (type == DateEditInterfaces.Date) {
|
|
70
|
+
this.dateTimeType = 'date';
|
|
71
|
+
Min = this._dataPipe.transform(Min, 'yyyy-MM-dd');
|
|
72
|
+
Max = this._dataPipe.transform(Max, 'yyyy-MM-dd');
|
|
73
|
+
} else if (type == DateEditInterfaces.DateTime) {
|
|
74
|
+
this.dateTimeType = 'datetime-local';
|
|
75
|
+
Min = this._dataPipe.transform(Min, 'yyyy-MM-dd HH:mm:ss');
|
|
76
|
+
Max = this._dataPipe.transform(Max, 'yyyy-MM-dd HH:mm:ss');
|
|
77
|
+
} else if (type == DateEditInterfaces.Month) {
|
|
78
|
+
this.dateTimeType = 'month';
|
|
79
|
+
Min = this._dataPipe.transform(Min, 'yyyy-MM');
|
|
80
|
+
Max = this._dataPipe.transform(Max, 'yyyy-MM');
|
|
81
|
+
}
|
|
82
|
+
this.formConfiguration.patchValue({
|
|
83
|
+
'DateEdit.Min': Min,
|
|
84
|
+
'DateEdit.Max': Max,
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FormControl, Validators } from "@angular/forms";
|
|
2
|
+
import { DateEditInterfaces } from "../../../enums/date-edit-interfaces";
|
|
3
|
+
|
|
4
|
+
export class DateEditConfig {
|
|
5
|
+
/**日期格式 */
|
|
6
|
+
'DateEdit.InputMode': any = [DateEditInterfaces.Date, []];
|
|
7
|
+
/**最小值 */
|
|
8
|
+
'DateEdit.Min': any = ['', []];
|
|
9
|
+
/**最大值 */
|
|
10
|
+
'DateEdit.Max': any = ['', []];
|
|
11
|
+
|
|
12
|
+
constructor() {
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
|
|
6
|
+
<ng-container *ngIf="_fields.field.formConfiguration['DateEdit.InputMode'] === _DateEditInterfaces.Date">
|
|
7
|
+
<input type="date" class="form-control" step="1" formControlName="{{_fields.field.name}}"
|
|
8
|
+
[min]="_fields.field.formConfiguration['DateEdit.Min']"
|
|
9
|
+
[max]="_fields.field.formConfiguration['DateEdit.Max']" />
|
|
10
|
+
</ng-container>
|
|
11
|
+
<ng-container
|
|
12
|
+
*ngIf="_fields.field.formConfiguration['DateEdit.InputMode'] === _DateEditInterfaces.DateTime">
|
|
13
|
+
<input type="datetime-local" class="form-control" step="1" formControlName="{{_fields.field.name}}"
|
|
14
|
+
[min]="_fields.field.formConfiguration['DateEdit.Min']"
|
|
15
|
+
[max]="_fields.field.formConfiguration['DateEdit.Max']" />
|
|
16
|
+
</ng-container>
|
|
17
|
+
<ng-container *ngIf="_fields.field.formConfiguration['DateEdit.InputMode'] === _DateEditInterfaces.Month">
|
|
18
|
+
<input type="month" class="form-control" step="1" formControlName="{{_fields.field.name}}"
|
|
19
|
+
[min]="_fields.field.formConfiguration['DateEdit.Min']"
|
|
20
|
+
[max]="_fields.field.formConfiguration['DateEdit.Max']" />
|
|
21
|
+
</ng-container>
|
|
22
|
+
<small class="form-text text-muted d-block" *ngIf="_fields.field.description">{{_fields.field.description}}</small>
|
|
23
|
+
</div>
|
|
24
|
+
</div>
|
|
25
|
+
<button type="submit" style="display: none;" #submitclick></button>
|
|
26
|
+
</form>
|
|
File without changes
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { DateEditControlComponent } from './date-edit-control.component';
|
|
4
|
+
|
|
5
|
+
describe('DateEditControlComponent', () => {
|
|
6
|
+
let component: DateEditControlComponent;
|
|
7
|
+
let fixture: ComponentFixture<DateEditControlComponent>;
|
|
8
|
+
|
|
9
|
+
beforeEach(() => {
|
|
10
|
+
TestBed.configureTestingModule({
|
|
11
|
+
declarations: [DateEditControlComponent]
|
|
12
|
+
});
|
|
13
|
+
fixture = TestBed.createComponent(DateEditControlComponent);
|
|
14
|
+
component = fixture.componentInstance;
|
|
15
|
+
fixture.detectChanges();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('should create', () => {
|
|
19
|
+
expect(component).toBeTruthy();
|
|
20
|
+
});
|
|
21
|
+
});
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { Component, ElementRef, Input, ViewChild, ChangeDetectorRef, inject } from '@angular/core';
|
|
2
|
+
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
|
3
|
+
import { DateEditInterfaces } from '../../../enums/date-edit-interfaces';
|
|
4
|
+
import { DatePipe } from '@angular/common';
|
|
5
|
+
|
|
6
|
+
@Component({
|
|
7
|
+
selector: 'df-date-edit-control',
|
|
8
|
+
templateUrl: './date-edit-control.component.html',
|
|
9
|
+
styleUrls: ['./date-edit-control.component.scss'],
|
|
10
|
+
})
|
|
11
|
+
export class DateEditControlComponent {
|
|
12
|
+
constructor(private fb: FormBuilder, private cdr: ChangeDetectorRef) {}
|
|
13
|
+
private _dataPipe = inject(DatePipe);
|
|
14
|
+
_DateEditInterfaces = DateEditInterfaces;
|
|
15
|
+
|
|
16
|
+
/**字段配置列表 */
|
|
17
|
+
_fields: any = '';
|
|
18
|
+
@Input()
|
|
19
|
+
public set fields(v: any) {
|
|
20
|
+
this._fields = v;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**父级字段名称,用于为表单设置控件赋值 */
|
|
24
|
+
_parentFiledName: any;
|
|
25
|
+
@Input()
|
|
26
|
+
public set parentFiledName(v: any) {
|
|
27
|
+
this._parentFiledName = v;
|
|
28
|
+
}
|
|
29
|
+
/**父级字段名称,用于为表单设置控件赋值 */
|
|
30
|
+
_selected: any;
|
|
31
|
+
@Input()
|
|
32
|
+
public set selected(v: any) {
|
|
33
|
+
this._selected = v;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**表单实体 */
|
|
37
|
+
_entity: FormGroup | undefined;
|
|
38
|
+
@Input()
|
|
39
|
+
public set entity(v: any) {
|
|
40
|
+
this._entity = v;
|
|
41
|
+
this.dataLoaded();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
public get entity(): any {
|
|
45
|
+
return this._entity;
|
|
46
|
+
}
|
|
47
|
+
@ViewChild('submitclick', { static: true }) submitclick: ElementRef;
|
|
48
|
+
|
|
49
|
+
get extraProperties() {
|
|
50
|
+
return this._entity.get('extraProperties') as FormGroup;
|
|
51
|
+
}
|
|
52
|
+
get fieldInput() {
|
|
53
|
+
return this.extraProperties.get(this._fields.field.name);
|
|
54
|
+
}
|
|
55
|
+
/**数据加载完成 */
|
|
56
|
+
async dataLoaded() {
|
|
57
|
+
if (this._fields && this._entity) {
|
|
58
|
+
await this.AfterInit();
|
|
59
|
+
|
|
60
|
+
this.cdr.detectChanges();
|
|
61
|
+
this.submitclick.nativeElement.click();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
AfterInit() {
|
|
66
|
+
return new Promise((resolve, rejects) => {
|
|
67
|
+
let ValidatorsArray = [];
|
|
68
|
+
let formConfiguration = this._fields.field.formConfiguration;
|
|
69
|
+
if (this._fields.required) {
|
|
70
|
+
ValidatorsArray.push(Validators.required);
|
|
71
|
+
}
|
|
72
|
+
if (formConfiguration['DateEdit.Min']) {
|
|
73
|
+
ValidatorsArray.push(Validators.min(formConfiguration['DateEdit.Min']));
|
|
74
|
+
}
|
|
75
|
+
if (formConfiguration['DateEdit.Max']) {
|
|
76
|
+
ValidatorsArray.push(Validators.max(formConfiguration['DateEdit.Max']));
|
|
77
|
+
}
|
|
78
|
+
let controlName = this._selected;
|
|
79
|
+
if (this._fields.field.formConfiguration['DateEdit.InputMode'] === DateEditInterfaces.Date) {
|
|
80
|
+
controlName = this._dataPipe.transform(this._selected, 'yyyy-MM-dd');
|
|
81
|
+
}
|
|
82
|
+
if (
|
|
83
|
+
this._fields.field.formConfiguration['DateEdit.InputMode'] === DateEditInterfaces.DateTime
|
|
84
|
+
) {
|
|
85
|
+
controlName = this._dataPipe.transform(this._selected, 'yyyy-MM-dd HH:mm:ss');
|
|
86
|
+
}
|
|
87
|
+
if (this._fields.field.formConfiguration['DateEdit.InputMode'] === DateEditInterfaces.Month) {
|
|
88
|
+
controlName = this._dataPipe.transform(this._selected, 'yyyy-MM');
|
|
89
|
+
}
|
|
90
|
+
let newControl = this.fb.control(controlName, ValidatorsArray);
|
|
91
|
+
this.extraProperties.setControl(this._fields.field.name, newControl);
|
|
92
|
+
|
|
93
|
+
resolve(true);
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
ngOnDestroy(): void {
|
|
97
|
+
//Called once, before the instance is destroyed.
|
|
98
|
+
//Add 'implements OnDestroy' to the class.
|
|
99
|
+
this.extraProperties.removeControl(this._fields.field.name);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { FieldControlGroupInterfaces } from '../../interfaces';
|
|
2
|
+
// import { CkEditorConfigComponent, CkEditorControlComponent } from "./ck-editor";
|
|
3
|
+
import { DateEditConfigComponent } from './date-edit/date-edit-config.component';
|
|
4
|
+
import { DateEditControlComponent } from './date-edit/date-edit-control.component';
|
|
5
|
+
import { NumbericEditConfigComponent } from './numeric-edit/numberic-edit-config.component';
|
|
6
|
+
import { NumbericEditControlComponent } from './numeric-edit/numberic-edit-control.component';
|
|
7
|
+
import { SelectConfigComponent, SelectControlComponent } from './select';
|
|
8
|
+
import { SwitchConfigComponent, SwitchControlComponent } from './switch';
|
|
9
|
+
import { TextEditComponent, TextEditConfigComponent } from './text-edit';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* 表单控件分组-包含配置,控件,显示的数组
|
|
13
|
+
*/
|
|
14
|
+
export const FieldControlGroup: FieldControlGroupInterfaces[] = [
|
|
15
|
+
{
|
|
16
|
+
displayName: '文本框',
|
|
17
|
+
name: 'TextEdit',
|
|
18
|
+
fieldConfigComponent: TextEditConfigComponent,
|
|
19
|
+
fieldComponent: TextEditComponent,
|
|
20
|
+
// fieldViewComponent:TextBoxViewComponent,
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
displayName: '开关',
|
|
24
|
+
name: 'Switch',
|
|
25
|
+
fieldConfigComponent: SwitchConfigComponent,
|
|
26
|
+
fieldComponent: SwitchControlComponent,
|
|
27
|
+
// fieldViewComponent:TextBoxViewComponent,
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
displayName: '选择',
|
|
31
|
+
name: 'Select',
|
|
32
|
+
fieldConfigComponent: SelectConfigComponent,
|
|
33
|
+
fieldComponent: SelectControlComponent,
|
|
34
|
+
// fieldViewComponent:TextBoxViewComponent,
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
displayName: '数字',
|
|
38
|
+
name: 'NumericEdit',
|
|
39
|
+
fieldConfigComponent: NumbericEditConfigComponent,
|
|
40
|
+
fieldComponent: NumbericEditControlComponent,
|
|
41
|
+
// fieldViewComponent:TextBoxViewComponent,
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
displayName: '日期',
|
|
45
|
+
name: 'DateEdit',
|
|
46
|
+
fieldConfigComponent: DateEditConfigComponent,
|
|
47
|
+
fieldComponent: DateEditControlComponent,
|
|
48
|
+
// fieldViewComponent:TextBoxViewComponent,
|
|
49
|
+
},
|
|
50
|
+
];
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
export function AddFieldControlGroup(array = []) {
|
|
54
|
+
|
|
55
|
+
for (const element of array) {
|
|
56
|
+
let find = FieldControlGroup.find((control) => {
|
|
57
|
+
return control.name === element.name;
|
|
58
|
+
});
|
|
59
|
+
if(!find){
|
|
60
|
+
FieldControlGroup.push(element);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return FieldControlGroup;
|
|
64
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
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="NumericEditField.Placeholder">
|
|
6
|
+
</div>
|
|
7
|
+
<div class="mb-3">
|
|
8
|
+
<label class="form-label">{{'DigniteAbpForms::Min' | abpLocalization}}</label>
|
|
9
|
+
<input type="text" class="form-control" formControlName="NumericEditField.Min">
|
|
10
|
+
</div>
|
|
11
|
+
<div class="mb-3">
|
|
12
|
+
<label class="form-label">{{'DigniteAbpForms::Max' | abpLocalization}}</label>
|
|
13
|
+
<input type="text" class="form-control" formControlName="NumericEditField.Max">
|
|
14
|
+
</div>
|
|
15
|
+
<div class="mb-3">
|
|
16
|
+
<label class="form-label">{{'DigniteAbpForms::NumericDecimals' | abpLocalization}}</label>
|
|
17
|
+
<input type="text" class="form-control" formControlName="NumericEditField.Decimals">
|
|
18
|
+
</div>
|
|
19
|
+
<div class="mb-3">
|
|
20
|
+
<label class="form-label">{{'DigniteAbpForms::NumericStep' | abpLocalization}}</label>
|
|
21
|
+
<input type="text" class="form-control" formControlName="NumericEditField.Step">
|
|
22
|
+
<small class="form-text text-muted d-block">{{'DigniteAbpForms::NumericStepHelp'|abpLocalization}}</small>
|
|
23
|
+
</div>
|
|
24
|
+
<div class="mb-3">
|
|
25
|
+
<label class="form-label">{{'DigniteAbpForms::FormatSpecifier' | abpLocalization}}</label>
|
|
26
|
+
<input type="text" class="form-control" formControlName="FormatSpecifier">
|
|
27
|
+
<small class="form-text text-muted d-block">See:<a href="https://docs.microsoft.com/zh-cn/dotnet/standard/base-types/standard-numeric-format-strings" target="_blank">https://docs.microsoft.com/zh-cn/dotnet/standard/base-types/standard-numeric-format-strings</a></small>
|
|
28
|
+
</div>
|
|
29
|
+
<button type="submit" (abpInit)="submitclick?.nativeElement?.click()" style="display: none;" #submitclick></button>
|
|
30
|
+
</div>
|
|
31
|
+
</form>
|
|
File without changes
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { NumbericEditConfigComponent } from './numberic-edit-config.component';
|
|
4
|
+
|
|
5
|
+
describe('NumbericEditConfigComponent', () => {
|
|
6
|
+
let component: NumbericEditConfigComponent;
|
|
7
|
+
let fixture: ComponentFixture<NumbericEditConfigComponent>;
|
|
8
|
+
|
|
9
|
+
beforeEach(() => {
|
|
10
|
+
TestBed.configureTestingModule({
|
|
11
|
+
declarations: [NumbericEditConfigComponent]
|
|
12
|
+
});
|
|
13
|
+
fixture = TestBed.createComponent(NumbericEditConfigComponent);
|
|
14
|
+
component = fixture.componentInstance;
|
|
15
|
+
fixture.detectChanges();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('should create', () => {
|
|
19
|
+
expect(component).toBeTruthy();
|
|
20
|
+
});
|
|
21
|
+
});
|