@dignite-ng/expand.dynamic-form 3.0.0-rc.6 → 3.0.0-rc.7

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.
Files changed (166) hide show
  1. package/esm2022/dignite-ng-expand.dynamic-form.mjs +5 -0
  2. package/esm2022/lib/components/dynamic/dynamic.component.mjs +106 -0
  3. package/esm2022/lib/components/dynamic/index.mjs +2 -0
  4. package/esm2022/lib/components/form/date-edit/date-edit-config.component.mjs +90 -0
  5. package/esm2022/lib/components/form/date-edit/date-edit-config.mjs +12 -0
  6. package/esm2022/lib/components/form/date-edit/date-edit-control.component.mjs +99 -0
  7. package/esm2022/lib/components/form/date-edit/index.mjs +3 -0
  8. package/esm2022/lib/components/form/form-control-group.mjs +60 -0
  9. package/esm2022/lib/components/form/index.mjs +7 -0
  10. package/esm2022/lib/components/form/numeric-edit/index.mjs +3 -0
  11. package/esm2022/lib/components/form/numeric-edit/numberic-edit-config.component.mjs +60 -0
  12. package/esm2022/lib/components/form/numeric-edit/numberic-edit-config.mjs +25 -0
  13. package/esm2022/lib/components/form/numeric-edit/numberic-edit-control.component.mjs +106 -0
  14. package/esm2022/lib/components/form/select/index.mjs +3 -0
  15. package/esm2022/lib/components/form/select/select-config.component.mjs +93 -0
  16. package/esm2022/lib/components/form/select/select-config.mjs +19 -0
  17. package/esm2022/lib/components/form/select/select-control.component.mjs +87 -0
  18. package/esm2022/lib/components/form/switch/index.mjs +3 -0
  19. package/esm2022/lib/components/form/switch/switch-config.component.mjs +61 -0
  20. package/esm2022/lib/components/form/switch/switch-config.mjs +14 -0
  21. package/esm2022/lib/components/form/switch/switch-control.component.mjs +80 -0
  22. package/esm2022/lib/components/form/text-edit/index.mjs +4 -0
  23. package/esm2022/lib/components/form/text-edit/text-edit-config.component.mjs +63 -0
  24. package/esm2022/lib/components/form/text-edit/text-edit-config.mjs +18 -0
  25. package/esm2022/lib/components/form/text-edit/text-edit.component.mjs +89 -0
  26. package/esm2022/lib/components/index.mjs +3 -0
  27. package/esm2022/lib/dynamic-form.module.mjs +92 -0
  28. package/esm2022/lib/enums/date-edit-interfaces.mjs +16 -0
  29. package/esm2022/lib/enums/text-edit-mode.mjs +8 -0
  30. package/esm2022/lib/interfaces/form-config-interfaces.mjs +2 -0
  31. package/esm2022/lib/interfaces/index.mjs +2 -0
  32. package/esm2022/lib/services/df-api.service.mjs +82 -0
  33. package/esm2022/lib/services/index.mjs +2 -0
  34. package/esm2022/public-api.mjs +7 -0
  35. package/fesm2022/dignite-ng-expand.dynamic-form.mjs +1209 -0
  36. package/fesm2022/dignite-ng-expand.dynamic-form.mjs.map +1 -0
  37. package/index.d.ts +5 -0
  38. package/lib/components/dynamic/dynamic.component.d.ts +38 -0
  39. package/lib/components/dynamic/index.d.ts +1 -0
  40. package/lib/components/form/date-edit/date-edit-config.component.d.ts +29 -0
  41. package/lib/components/form/date-edit/date-edit-config.d.ts +9 -0
  42. package/lib/components/form/date-edit/date-edit-control.component.d.ts +33 -0
  43. package/lib/components/form/date-edit/index.d.ts +2 -0
  44. package/lib/components/form/form-control-group.d.ts +6 -0
  45. package/lib/components/form/index.d.ts +6 -0
  46. package/lib/components/form/numeric-edit/index.d.ts +2 -0
  47. package/lib/components/form/numeric-edit/numberic-edit-config.component.d.ts +23 -0
  48. package/lib/components/form/numeric-edit/numberic-edit-config.d.ts +11 -0
  49. package/lib/components/form/numeric-edit/numberic-edit-control.component.d.ts +34 -0
  50. package/lib/components/form/select/index.d.ts +2 -0
  51. package/lib/components/form/select/select-config.component.d.ts +31 -0
  52. package/lib/components/form/select/select-config.d.ts +7 -0
  53. package/lib/components/form/select/select-control.component.d.ts +29 -0
  54. package/lib/components/form/switch/index.d.ts +2 -0
  55. package/lib/components/form/switch/switch-config.component.d.ts +23 -0
  56. package/lib/components/form/switch/switch-config.d.ts +5 -0
  57. package/lib/components/form/switch/switch-control.component.d.ts +28 -0
  58. package/lib/components/form/text-edit/index.d.ts +3 -0
  59. package/lib/components/form/text-edit/text-edit-config.component.d.ts +25 -0
  60. package/lib/components/form/text-edit/text-edit-config.d.ts +7 -0
  61. package/lib/components/form/text-edit/text-edit.component.d.ts +30 -0
  62. package/lib/components/index.d.ts +2 -0
  63. package/lib/dynamic-form.module.d.ts +24 -0
  64. package/lib/enums/date-edit-interfaces.d.ts +5 -0
  65. package/lib/enums/text-edit-mode.d.ts +4 -0
  66. package/{src/lib/interfaces/form-config-interfaces.ts → lib/interfaces/form-config-interfaces.d.ts} +2 -7
  67. package/lib/interfaces/index.d.ts +1 -0
  68. package/lib/services/df-api.service.d.ts +18 -0
  69. package/lib/services/index.d.ts +1 -0
  70. package/package.json +15 -2
  71. package/{src/public-api.ts → public-api.d.ts} +0 -4
  72. package/ng-package.json +0 -7
  73. package/src/lib/components/dynamic/dynamic.component.html +0 -2
  74. package/src/lib/components/dynamic/dynamic.component.scss +0 -0
  75. package/src/lib/components/dynamic/dynamic.component.spec.ts +0 -21
  76. package/src/lib/components/dynamic/dynamic.component.ts +0 -121
  77. package/src/lib/components/dynamic/index.ts +0 -1
  78. package/src/lib/components/form/date-edit/date-edit-config.component.html +0 -40
  79. package/src/lib/components/form/date-edit/date-edit-config.component.scss +0 -0
  80. package/src/lib/components/form/date-edit/date-edit-config.component.spec.ts +0 -21
  81. package/src/lib/components/form/date-edit/date-edit-config.component.ts +0 -87
  82. package/src/lib/components/form/date-edit/date-edit-config.ts +0 -14
  83. package/src/lib/components/form/date-edit/date-edit-control.component.html +0 -26
  84. package/src/lib/components/form/date-edit/date-edit-control.component.scss +0 -0
  85. package/src/lib/components/form/date-edit/date-edit-control.component.spec.ts +0 -21
  86. package/src/lib/components/form/date-edit/date-edit-control.component.ts +0 -101
  87. package/src/lib/components/form/date-edit/index.ts +0 -2
  88. package/src/lib/components/form/form-control-group.ts +0 -64
  89. package/src/lib/components/form/index.ts +0 -6
  90. package/src/lib/components/form/numeric-edit/index.ts +0 -2
  91. package/src/lib/components/form/numeric-edit/numberic-edit-config.component.html +0 -31
  92. package/src/lib/components/form/numeric-edit/numberic-edit-config.component.scss +0 -0
  93. package/src/lib/components/form/numeric-edit/numberic-edit-config.component.spec.ts +0 -21
  94. package/src/lib/components/form/numeric-edit/numberic-edit-config.component.ts +0 -57
  95. package/src/lib/components/form/numeric-edit/numberic-edit-config.ts +0 -28
  96. package/src/lib/components/form/numeric-edit/numberic-edit-control.component.html +0 -13
  97. package/src/lib/components/form/numeric-edit/numberic-edit-control.component.scss +0 -0
  98. package/src/lib/components/form/numeric-edit/numberic-edit-control.component.spec.ts +0 -21
  99. package/src/lib/components/form/numeric-edit/numberic-edit-control.component.ts +0 -119
  100. package/src/lib/components/form/select/index.ts +0 -2
  101. package/src/lib/components/form/select/select-config.component.html +0 -59
  102. package/src/lib/components/form/select/select-config.component.scss +0 -0
  103. package/src/lib/components/form/select/select-config.component.spec.ts +0 -21
  104. package/src/lib/components/form/select/select-config.component.ts +0 -90
  105. package/src/lib/components/form/select/select-config.ts +0 -24
  106. package/src/lib/components/form/select/select-control.component.html +0 -32
  107. package/src/lib/components/form/select/select-control.component.scss +0 -32
  108. package/src/lib/components/form/select/select-control.component.spec.ts +0 -21
  109. package/src/lib/components/form/select/select-control.component.ts +0 -86
  110. package/src/lib/components/form/switch/index.ts +0 -2
  111. package/src/lib/components/form/switch/switch-config.component.html +0 -17
  112. package/src/lib/components/form/switch/switch-config.component.scss +0 -0
  113. package/src/lib/components/form/switch/switch-config.component.spec.ts +0 -21
  114. package/src/lib/components/form/switch/switch-config.component.ts +0 -58
  115. package/src/lib/components/form/switch/switch-config.ts +0 -17
  116. package/src/lib/components/form/switch/switch-control.component.html +0 -13
  117. package/src/lib/components/form/switch/switch-control.component.scss +0 -0
  118. package/src/lib/components/form/switch/switch-control.component.spec.ts +0 -21
  119. package/src/lib/components/form/switch/switch-control.component.ts +0 -81
  120. package/src/lib/components/form/text-edit/index.ts +0 -3
  121. package/src/lib/components/form/text-edit/text-edit-config.component.html +0 -32
  122. package/src/lib/components/form/text-edit/text-edit-config.component.scss +0 -0
  123. package/src/lib/components/form/text-edit/text-edit-config.component.spec.ts +0 -21
  124. package/src/lib/components/form/text-edit/text-edit-config.component.ts +0 -59
  125. package/src/lib/components/form/text-edit/text-edit-config.ts +0 -24
  126. package/src/lib/components/form/text-edit/text-edit.component.html +0 -17
  127. package/src/lib/components/form/text-edit/text-edit.component.scss +0 -0
  128. package/src/lib/components/form/text-edit/text-edit.component.spec.ts +0 -21
  129. package/src/lib/components/form/text-edit/text-edit.component.ts +0 -91
  130. package/src/lib/components/index.ts +0 -2
  131. package/src/lib/dynamic-form.module.ts +0 -74
  132. package/src/lib/enums/date-edit-interfaces.ts +0 -16
  133. package/src/lib/enums/index.ts +0 -2
  134. package/src/lib/enums/text-edit-mode.ts +0 -7
  135. package/src/lib/interfaces/index.ts +0 -1
  136. package/src/lib/proxy/README.md +0 -17
  137. package/src/lib/proxy/dignite/file-explorer/directories/file-descriptor.service.ts +0 -65
  138. package/src/lib/proxy/dignite/file-explorer/directories/index.ts +0 -2
  139. package/src/lib/proxy/dignite/file-explorer/directories/models.ts +0 -35
  140. package/src/lib/proxy/dignite/file-explorer/files/file-descriptor.service.ts +0 -86
  141. package/src/lib/proxy/dignite/file-explorer/files/index.ts +0 -2
  142. package/src/lib/proxy/dignite/file-explorer/files/models.ts +0 -57
  143. package/src/lib/proxy/dignite/file-explorer/index.ts +0 -3
  144. package/src/lib/proxy/dignite/index.ts +0 -2
  145. package/src/lib/proxy/generate-proxy.json +0 -11810
  146. package/src/lib/proxy/index.ts +0 -4
  147. package/src/lib/proxy/microsoft/asp-net-core/index.ts +0 -2
  148. package/src/lib/proxy/microsoft/asp-net-core/mvc/index.ts +0 -1
  149. package/src/lib/proxy/microsoft/asp-net-core/mvc/models.ts +0 -12
  150. package/src/lib/proxy/microsoft/extensions/index.ts +0 -2
  151. package/src/lib/proxy/microsoft/extensions/primitives/index.ts +0 -1
  152. package/src/lib/proxy/microsoft/extensions/primitives/models.ts +0 -9
  153. package/src/lib/proxy/microsoft/index.ts +0 -4
  154. package/src/lib/proxy/microsoft/net/http/headers/index.ts +0 -1
  155. package/src/lib/proxy/microsoft/net/http/headers/models.ts +0 -7
  156. package/src/lib/proxy/microsoft/net/http/index.ts +0 -2
  157. package/src/lib/proxy/microsoft/net/index.ts +0 -2
  158. package/src/lib/proxy/volo/abp/content/index.ts +0 -1
  159. package/src/lib/proxy/volo/abp/content/models.ts +0 -6
  160. package/src/lib/proxy/volo/abp/index.ts +0 -2
  161. package/src/lib/proxy/volo/index.ts +0 -2
  162. package/src/lib/services/df-api.service.ts +0 -75
  163. package/src/lib/services/index.ts +0 -1
  164. package/tsconfig.lib.json +0 -14
  165. package/tsconfig.lib.prod.json +0 -10
  166. package/tsconfig.spec.json +0 -14
@@ -1,101 +0,0 @@
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
- }
@@ -1,2 +0,0 @@
1
- export * from './date-edit-config.component'
2
- export * from './date-edit-control.component'
@@ -1,64 +0,0 @@
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
- }
@@ -1,6 +0,0 @@
1
- export * from './text-edit'
2
- export * from './switch'
3
- export * from './numeric-edit'
4
- export * from './date-edit'
5
- export * from './form-control-group'
6
- export * from './select'
@@ -1,2 +0,0 @@
1
- export * from './numberic-edit-config.component'
2
- export * from './numberic-edit-control.component'
@@ -1,31 +0,0 @@
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>
@@ -1,21 +0,0 @@
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
- });
@@ -1,57 +0,0 @@
1
- import { ChangeDetectorRef, Component, ElementRef, inject, Input, ViewChild } from '@angular/core';
2
- import { FormBuilder, FormGroup } from '@angular/forms';
3
- import { NumbericEditConfig } from './numberic-edit-config';
4
-
5
- @Component({
6
- selector: 'df-numberic-edit-config',
7
- templateUrl: './numberic-edit-config.component.html',
8
- styleUrls: ['./numberic-edit-config.component.scss'],
9
- })
10
- export class NumbericEditConfigComponent {
11
- constructor(private fb: FormBuilder) {}
12
- /**表单控件类型 */
13
- _type: any;
14
- @Input()
15
- public set type(v: any) {
16
- this._type = v;
17
- // this.dataLoaded()
18
- }
19
-
20
- /**选择的表单信息 */
21
- _selected: any;
22
- @Input()
23
- public set selected(v: any) {
24
- this._selected = v ? v : v == false ? v : '';
25
- }
26
- /**表单实体 */
27
- _Entity: FormGroup | undefined;
28
- @Input()
29
- public set Entity(v: FormGroup) {
30
- this._Entity = v;
31
- this.dataLoaded();
32
- }
33
- get formConfiguration() {
34
- return this._Entity.get('formConfiguration') as FormGroup;
35
- }
36
- @ViewChild('submitclick', { static: false }) submitclick?: ElementRef;
37
- private cdr = inject(ChangeDetectorRef);
38
- async dataLoaded() {
39
- if (this._Entity && this._type) {
40
- await this.AfterInit();
41
- this.cdr.detectChanges(); // 手动触发变更检测
42
- this.submitclick?.nativeElement?.click();
43
- }
44
- }
45
-
46
- AfterInit() {
47
- return new Promise((resolve, rejects) => {
48
- this._Entity.setControl('formConfiguration', this.fb.group(new NumbericEditConfig()));
49
- if (this._selected && this._selected.formControlName == this._type) {
50
- this.formConfiguration.patchValue({
51
- ...this._selected.formConfiguration,
52
- });
53
- }
54
- resolve(true);
55
- });
56
- }
57
- }
@@ -1,28 +0,0 @@
1
- import { FormControl, Validators } from "@angular/forms";
2
-
3
- export class NumbericEditConfig {
4
- /**占位符 */
5
- 'NumericEditField.Placeholder': any = ['', []];
6
- /**最小值 */
7
- 'NumericEditField.Min': any = ['', [Validators.required]];
8
- //最大值
9
- 'NumericEditField.Max': any = ['', [Validators.required]];
10
- // 小数位数
11
- 'NumericEditField.Decimals': any = [2, []];
12
- //步长
13
- 'NumericEditField.Step': any = ['', []];
14
- //格式说明符
15
- 'FormatSpecifier': any = ['', []];
16
-
17
- constructor(data?: NumbericEditConfig) {
18
- if (data) {
19
- for (const key in data) {
20
- if (data.hasOwnProperty(key)) {
21
- this[key] = data[key];
22
- }
23
- }
24
- }
25
-
26
-
27
- }
28
- }
@@ -1,13 +0,0 @@
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
- <input type="number" class="form-control" formControlName="{{_fields.field.name}}"
6
- [placeholder]="_fields.field.formConfiguration['NumericEditField.Placeholder']||''"
7
- [step]="_fields.field.formConfiguration['NumericEditField.Step']" (input)="inputchange($event)" />
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>
@@ -1,21 +0,0 @@
1
- import { ComponentFixture, TestBed } from '@angular/core/testing';
2
-
3
- import { NumbericEditControlComponent } from './numberic-edit-control.component';
4
-
5
- describe('NumbericEditControlComponent', () => {
6
- let component: NumbericEditControlComponent;
7
- let fixture: ComponentFixture<NumbericEditControlComponent>;
8
-
9
- beforeEach(() => {
10
- TestBed.configureTestingModule({
11
- declarations: [NumbericEditControlComponent]
12
- });
13
- fixture = TestBed.createComponent(NumbericEditControlComponent);
14
- component = fixture.componentInstance;
15
- fixture.detectChanges();
16
- });
17
-
18
- it('should create', () => {
19
- expect(component).toBeTruthy();
20
- });
21
- });
@@ -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,2 +0,0 @@
1
- export * from './select-config.component'
2
- export * from './select-control.component'
@@ -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>
@@ -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
- }