@stemy/ngx-dynamic-form 19.1.13 → 19.2.0
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/fesm2022/stemy-ngx-dynamic-form-ui-nebular.mjs +4 -4
- package/fesm2022/stemy-ngx-dynamic-form-ui-nebular.mjs.map +1 -1
- package/fesm2022/stemy-ngx-dynamic-form.mjs +859 -1662
- package/fesm2022/stemy-ngx-dynamic-form.mjs.map +1 -1
- package/ngx-dynamic-form/common-types.d.ts +109 -26
- package/ngx-dynamic-form/components/dynamic-form/dynamic-form.component.d.ts +21 -0
- package/ngx-dynamic-form/components/dynamic-form-array/dynamic-form-array.component.d.ts +9 -0
- package/ngx-dynamic-form/components/dynamic-form-chips/dynamic-form-chips.component.d.ts +7 -0
- package/ngx-dynamic-form/components/dynamic-form-field/dynamic-form-field.component.d.ts +6 -0
- package/ngx-dynamic-form/components/dynamic-form-fieldset/dynamic-form-fieldset.component.d.ts +7 -0
- package/ngx-dynamic-form/components/dynamic-form-group/dynamic-form-group.component.d.ts +6 -0
- package/ngx-dynamic-form/components/dynamic-form-upload/dynamic-form-upload.component.d.ts +7 -0
- package/ngx-dynamic-form/directives/async-submit.directive.d.ts +17 -23
- package/ngx-dynamic-form/ngx-dynamic-form.imports.d.ts +5 -9
- package/ngx-dynamic-form/ngx-dynamic-form.module.d.ts +13 -11
- package/ngx-dynamic-form/services/dynamic-form-builder.service.d.ts +27 -0
- package/ngx-dynamic-form/services/dynamic-form.service.d.ts +28 -46
- package/ngx-dynamic-form/utils/customizer.d.ts +5 -12
- package/ngx-dynamic-form/utils/decorators.d.ts +10 -0
- package/ngx-dynamic-form/utils/misc.d.ts +2 -4
- package/ngx-dynamic-form/utils/validation.d.ts +13 -0
- package/package.json +21 -16
- package/public_api.d.ts +13 -18
- package/ui-nebular/index.d.ts +1 -5
- package/common-types.d.ts +0 -37
- package/components/base/dynamic-base-form-array.component.d.ts +0 -38
- package/components/base/dynamic-base-form-control-container.component.d.ts +0 -39
- package/components/base/dynamic-base-form-control.component.d.ts +0 -26
- package/components/base/dynamic-base-form-group.component.d.ts +0 -25
- package/components/base/dynamic-base-form.component.d.ts +0 -46
- package/components/base/dynamic-base-select.component.d.ts +0 -15
- package/directives/async-submit.directive.d.ts +0 -31
- package/esm2020/ngx-dynamic-form/common-types.mjs +0 -2
- package/esm2020/ngx-dynamic-form/components/base/dynamic-base-form-array.component.mjs +0 -104
- package/esm2020/ngx-dynamic-form/components/base/dynamic-base-form-control-container.component.mjs +0 -127
- package/esm2020/ngx-dynamic-form/components/base/dynamic-base-form-control.component.mjs +0 -57
- package/esm2020/ngx-dynamic-form/components/base/dynamic-base-form-group.component.mjs +0 -75
- package/esm2020/ngx-dynamic-form/components/base/dynamic-base-form.component.mjs +0 -182
- package/esm2020/ngx-dynamic-form/components/base/dynamic-base-select.component.mjs +0 -66
- package/esm2020/ngx-dynamic-form/directives/async-submit.directive.mjs +0 -116
- package/esm2020/ngx-dynamic-form/ngx-dynamic-form.imports.mjs +0 -26
- package/esm2020/ngx-dynamic-form/ngx-dynamic-form.module.mjs +0 -116
- package/esm2020/ngx-dynamic-form/services/dynamic-form.service.mjs +0 -615
- package/esm2020/ngx-dynamic-form/utils/creators.mjs +0 -67
- package/esm2020/ngx-dynamic-form/utils/customizer.mjs +0 -28
- package/esm2020/ngx-dynamic-form/utils/dynamic-editor.model.mjs +0 -14
- package/esm2020/ngx-dynamic-form/utils/dynamic-form-array.model.mjs +0 -128
- package/esm2020/ngx-dynamic-form/utils/dynamic-form-group.model.mjs +0 -26
- package/esm2020/ngx-dynamic-form/utils/dynamic-select.model.mjs +0 -59
- package/esm2020/ngx-dynamic-form/utils/form-select-subject.mjs +0 -26
- package/esm2020/ngx-dynamic-form/utils/form-subject.mjs +0 -29
- package/esm2020/ngx-dynamic-form/utils/misc.mjs +0 -47
- package/esm2020/ngx-dynamic-form/utils/validation-errors.mjs +0 -22
- package/esm2020/ngx-dynamic-form/utils/validators.mjs +0 -56
- package/esm2020/public_api.mjs +0 -21
- package/esm2020/stemy-ngx-dynamic-form.mjs +0 -5
- package/fesm2015/stemy-ngx-dynamic-form.mjs +0 -1927
- package/fesm2015/stemy-ngx-dynamic-form.mjs.map +0 -1
- package/fesm2020/stemy-ngx-dynamic-form.mjs +0 -1893
- package/fesm2020/stemy-ngx-dynamic-form.mjs.map +0 -1
- package/fesm2022/stemy-ngx-dynamic-form-src-ngx-dynamic-form-nebular.mjs +0 -50
- package/fesm2022/stemy-ngx-dynamic-form-src-ngx-dynamic-form-nebular.mjs.map +0 -1
- package/imports.d.ts +0 -12
- package/ngx-dynamic-form/components/base/dynamic-base-form-array.component.d.ts +0 -38
- package/ngx-dynamic-form/components/base/dynamic-base-form-control-container.component.d.ts +0 -39
- package/ngx-dynamic-form/components/base/dynamic-base-form-control.component.d.ts +0 -26
- package/ngx-dynamic-form/components/base/dynamic-base-form-group.component.d.ts +0 -25
- package/ngx-dynamic-form/components/base/dynamic-base-form.component.d.ts +0 -46
- package/ngx-dynamic-form/components/base/dynamic-base-select.component.d.ts +0 -15
- package/ngx-dynamic-form/services/dynamic-form-layout.service.d.ts +0 -7
- package/ngx-dynamic-form/utils/creators.d.ts +0 -18
- package/ngx-dynamic-form/utils/dynamic-editor.model.d.ts +0 -11
- package/ngx-dynamic-form/utils/dynamic-form-array.model.d.ts +0 -69
- package/ngx-dynamic-form/utils/dynamic-form-group.model.d.ts +0 -14
- package/ngx-dynamic-form/utils/dynamic-select.model.d.ts +0 -39
- package/ngx-dynamic-form/utils/form-select-subject.d.ts +0 -6
- package/ngx-dynamic-form/utils/form-subject.d.ts +0 -10
- package/ngx-dynamic-form/utils/validators.d.ts +0 -8
- package/ngx-dynamic-form.imports.d.ts +0 -12
- package/ngx-dynamic-form.module.d.ts +0 -21
- package/services/dynamic-form.service.d.ts +0 -61
- package/src/ngx-dynamic-form/nebular/imports.d.ts +0 -4
- package/src/ngx-dynamic-form/nebular/index.d.ts +0 -5
- package/src/ngx-dynamic-form/nebular/ngx-dynamic-form.nebular.module.d.ts +0 -9
- package/src/ngx-dynamic-form/nebular/public_api.d.ts +0 -1
- package/stemy-ngx-dynamic-form.d.ts +0 -5
- package/ui-nebular/public_api.d.ts +0 -1
- package/utils/creators.d.ts +0 -18
- package/utils/customizer.d.ts +0 -14
- package/utils/dynamic-editor.model.d.ts +0 -11
- package/utils/dynamic-form-array.model.d.ts +0 -69
- package/utils/dynamic-form-group.model.d.ts +0 -14
- package/utils/dynamic-select.model.d.ts +0 -39
- package/utils/form-select-subject.d.ts +0 -6
- package/utils/form-subject.d.ts +0 -10
- package/utils/misc.d.ts +0 -11
- package/utils/validation-errors.d.ts +0 -11
- package/utils/validators.d.ts +0 -8
|
@@ -1,1927 +0,0 @@
|
|
|
1
|
-
import * as i1 from '@ng-dynamic-forms/core';
|
|
2
|
-
import { DynamicInputControlModel, DYNAMIC_FORM_CONTROL_TYPE_EDITOR, serializable, DynamicFormArrayGroupModel as DynamicFormArrayGroupModel$1, DynamicFormArrayModel as DynamicFormArrayModel$1, DynamicFormGroupModel as DynamicFormGroupModel$1, DynamicFormOption as DynamicFormOption$1, DynamicSelectModel as DynamicSelectModel$1, DynamicCheckboxModel, DynamicDatePickerModel, DynamicInputModel, DynamicTextAreaModel, DynamicFileUploadModel, DynamicFormService as DynamicFormService$1, DynamicFormValueControlModel, DynamicFormComponent, DynamicTemplateDirective, DynamicFormControlContainerComponent, DYNAMIC_FORM_CONTROL_TYPE_ARRAY, DynamicFormArrayComponent, DynamicFormControlComponent, DynamicFormGroupComponent, DYNAMIC_FORM_CONTROL_MAP_FN, DYNAMIC_VALIDATORS } from '@ng-dynamic-forms/core';
|
|
3
|
-
export { DYNAMIC_FORM_CONTROL_TYPE_ARRAY, DYNAMIC_FORM_CONTROL_TYPE_CHECKBOX, DYNAMIC_FORM_CONTROL_TYPE_CHECKBOX_GROUP, DYNAMIC_FORM_CONTROL_TYPE_DATEPICKER, DYNAMIC_FORM_CONTROL_TYPE_EDITOR, DYNAMIC_FORM_CONTROL_TYPE_FILE_UPLOAD, DYNAMIC_FORM_CONTROL_TYPE_GROUP, DYNAMIC_FORM_CONTROL_TYPE_INPUT, DYNAMIC_FORM_CONTROL_TYPE_RADIO_GROUP, DYNAMIC_FORM_CONTROL_TYPE_SELECT, DYNAMIC_FORM_CONTROL_TYPE_TEXTAREA, DynamicCheckboxGroupModel, DynamicCheckboxModel, DynamicDatePickerModel, DynamicFileUploadModel, DynamicFormControlComponent, DynamicFormControlModel, DynamicFormsCoreModule, DynamicInputModel, DynamicListDirective, DynamicRadioGroupModel, DynamicTemplateDirective, DynamicTextAreaModel } from '@ng-dynamic-forms/core';
|
|
4
|
-
import * as i2 from '@stemy/ngx-utils';
|
|
5
|
-
import { ObjectUtils, TimerUtils, cachedFactory, StringUtils, OpenApiService, TOASTER_SERVICE, ObservableUtils, EventsService, NgxUtilsModule } from '@stemy/ngx-utils';
|
|
6
|
-
import { __decorate, __awaiter } from 'tslib';
|
|
7
|
-
import { BehaviorSubject, of, isObservable, Subject, firstValueFrom, Subscription } from 'rxjs';
|
|
8
|
-
import { map, debounceTime, groupBy, mergeMap, first } from 'rxjs/operators';
|
|
9
|
-
import * as i0 from '@angular/core';
|
|
10
|
-
import { Injector, Injectable, Inject, EventEmitter, Directive, Input, Output, HostBinding, HostListener, QueryList, Component, ChangeDetectionStrategy, ContentChildren, ViewChildren, ViewContainerRef, ViewChild, forwardRef, NgModule } from '@angular/core';
|
|
11
|
-
import { FormGroup, FormArray, FormsModule, ReactiveFormsModule, NG_VALIDATORS } from '@angular/forms';
|
|
12
|
-
import { CommonModule } from '@angular/common';
|
|
13
|
-
|
|
14
|
-
class DynamicEditorModel extends DynamicInputControlModel {
|
|
15
|
-
constructor(config, layout) {
|
|
16
|
-
super(config, layout);
|
|
17
|
-
this.type = DYNAMIC_FORM_CONTROL_TYPE_EDITOR;
|
|
18
|
-
this.inputType = config.inputType || "javascript";
|
|
19
|
-
this.convertObject = config.convertObject !== false;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
__decorate([
|
|
23
|
-
serializable()
|
|
24
|
-
], DynamicEditorModel.prototype, "type", void 0);
|
|
25
|
-
|
|
26
|
-
class DynamicFormArrayGroupModel extends DynamicFormArrayGroupModel$1 {
|
|
27
|
-
constructor(context, group, index = -1) {
|
|
28
|
-
super(context, group, index);
|
|
29
|
-
this.context = context;
|
|
30
|
-
this.isHidden = false;
|
|
31
|
-
}
|
|
32
|
-
get hidden() {
|
|
33
|
-
return this.isHidden;
|
|
34
|
-
}
|
|
35
|
-
set hidden(value) {
|
|
36
|
-
var _a;
|
|
37
|
-
if (this.isHidden == value)
|
|
38
|
-
return;
|
|
39
|
-
this.isHidden = value || false;
|
|
40
|
-
(_a = this.context) === null || _a === void 0 ? void 0 : _a.filterGroups();
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
class DynamicFormArrayModel extends DynamicFormArrayModel$1 {
|
|
44
|
-
constructor(config, layout) {
|
|
45
|
-
super(config, layout);
|
|
46
|
-
this.config = config;
|
|
47
|
-
this.filteredGroups = new BehaviorSubject([]);
|
|
48
|
-
this.sortable = config.sortable || false;
|
|
49
|
-
this.useTabs = config.useTabs || false;
|
|
50
|
-
this.saveTab = ObjectUtils.isFunction(config.saveTab) ? config.saveTab : ((index, model, arrayModel) => {
|
|
51
|
-
arrayModel.tabIndex = index;
|
|
52
|
-
});
|
|
53
|
-
this.restoreTab = ObjectUtils.isFunction(config.restoreTab) ? config.restoreTab : ((model) => {
|
|
54
|
-
return model.tabIndex;
|
|
55
|
-
});
|
|
56
|
-
this.getTabLabel = ObjectUtils.isFunction(config.getTabLabel) ? config.getTabLabel : ((index) => {
|
|
57
|
-
return `${index + 1}`;
|
|
58
|
-
});
|
|
59
|
-
this.additional = config.additional || {};
|
|
60
|
-
this.tabIndex = 0;
|
|
61
|
-
this._sortBy = null;
|
|
62
|
-
this._sortDescending = false;
|
|
63
|
-
this._formArray = null;
|
|
64
|
-
}
|
|
65
|
-
get addItem() {
|
|
66
|
-
return this.config.addItem !== false;
|
|
67
|
-
}
|
|
68
|
-
get insertItem() {
|
|
69
|
-
return !this._sortBy && this.config.insertItem !== false;
|
|
70
|
-
}
|
|
71
|
-
get cloneItem() {
|
|
72
|
-
return this.config.cloneItem !== false;
|
|
73
|
-
}
|
|
74
|
-
get moveItem() {
|
|
75
|
-
return !this._sortBy && this.config.moveItem !== false;
|
|
76
|
-
}
|
|
77
|
-
get removeItem() {
|
|
78
|
-
return this.config.removeItem !== false;
|
|
79
|
-
}
|
|
80
|
-
get clearItems() {
|
|
81
|
-
return this.config.clearItems !== false;
|
|
82
|
-
}
|
|
83
|
-
get sortBy() {
|
|
84
|
-
return this._sortBy;
|
|
85
|
-
}
|
|
86
|
-
set sortBy(value) {
|
|
87
|
-
if (!this.sortable)
|
|
88
|
-
return;
|
|
89
|
-
value = value || null;
|
|
90
|
-
if (this._sortBy !== value) {
|
|
91
|
-
this._sortBy = value;
|
|
92
|
-
this._sortDescending = false;
|
|
93
|
-
}
|
|
94
|
-
else if (this._sortDescending) {
|
|
95
|
-
this._sortBy = null;
|
|
96
|
-
this._sortDescending = false;
|
|
97
|
-
}
|
|
98
|
-
else {
|
|
99
|
-
this._sortDescending = true;
|
|
100
|
-
}
|
|
101
|
-
this.filterGroups();
|
|
102
|
-
}
|
|
103
|
-
get sortDescending() {
|
|
104
|
-
return this._sortDescending;
|
|
105
|
-
}
|
|
106
|
-
get sortOrder() {
|
|
107
|
-
return this.sortDescending ? "desc" : "asc";
|
|
108
|
-
}
|
|
109
|
-
initialize(array) {
|
|
110
|
-
this._formArray = array || this._formArray;
|
|
111
|
-
this.filterGroups();
|
|
112
|
-
}
|
|
113
|
-
filterGroups() {
|
|
114
|
-
this._filterTimer = this._filterTimer || TimerUtils.createTimeout();
|
|
115
|
-
this._filterTimer.set(() => {
|
|
116
|
-
const filtered = this.groups.filter(g => !g.hidden);
|
|
117
|
-
if (this._sortBy && this._formArray) {
|
|
118
|
-
const compare = this._sortDescending
|
|
119
|
-
? (a, b) => this.compareModels(b, a)
|
|
120
|
-
: (a, b) => this.compareModels(a, b);
|
|
121
|
-
filtered.sort(compare);
|
|
122
|
-
}
|
|
123
|
-
this._filteredGroups = filtered;
|
|
124
|
-
this.filteredGroups.next(filtered);
|
|
125
|
-
}, 100);
|
|
126
|
-
}
|
|
127
|
-
getFiltered(index) {
|
|
128
|
-
return !this._filteredGroups ? null : this._filteredGroups[index];
|
|
129
|
-
}
|
|
130
|
-
insertGroup(index) {
|
|
131
|
-
const group = new DynamicFormArrayGroupModel(this, this.groupFactory());
|
|
132
|
-
this.groups.splice(index, 0, group);
|
|
133
|
-
this.groups.forEach((g, index) => g.index = index);
|
|
134
|
-
this.filterGroups();
|
|
135
|
-
return group;
|
|
136
|
-
}
|
|
137
|
-
moveGroup(index, step) {
|
|
138
|
-
super.moveGroup(index, step);
|
|
139
|
-
this.filterGroups();
|
|
140
|
-
}
|
|
141
|
-
removeGroup(index) {
|
|
142
|
-
super.removeGroup(index);
|
|
143
|
-
this.filterGroups();
|
|
144
|
-
}
|
|
145
|
-
compareModels(a, b) {
|
|
146
|
-
var _a, _b;
|
|
147
|
-
const aGroup = ((_a = this._formArray.at(a.index).get(this._sortBy)) === null || _a === void 0 ? void 0 : _a.value) || null;
|
|
148
|
-
const bGroup = ((_b = this._formArray.at(b.index).get(this._sortBy)) === null || _b === void 0 ? void 0 : _b.value) || null;
|
|
149
|
-
return ObjectUtils.compare(aGroup, bGroup);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
class DynamicFormGroupModel extends DynamicFormGroupModel$1 {
|
|
154
|
-
constructor(config, layout) {
|
|
155
|
-
super(config, layout);
|
|
156
|
-
const controls = [...config.group];
|
|
157
|
-
const groups = [];
|
|
158
|
-
const sets = config.fieldSets || [];
|
|
159
|
-
for (const fs of sets) {
|
|
160
|
-
const fields = [];
|
|
161
|
-
for (const f of fs.fields) {
|
|
162
|
-
const ix = controls.findIndex(c => c.id === f);
|
|
163
|
-
if (ix < 0)
|
|
164
|
-
continue;
|
|
165
|
-
fields.push(controls.splice(ix, 1)[0]);
|
|
166
|
-
}
|
|
167
|
-
if (fields.length === 0)
|
|
168
|
-
continue;
|
|
169
|
-
groups.push({ id: fs.id, legend: fs.legend, fields });
|
|
170
|
-
}
|
|
171
|
-
if (controls.length > 0) {
|
|
172
|
-
groups.unshift({ id: "root-controls", legend: config.legend, fields: controls });
|
|
173
|
-
}
|
|
174
|
-
this.groups = groups;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
const ignoredKeys = ["disabled", "label", "value", "classes"];
|
|
179
|
-
class DynamicFormOption extends DynamicFormOption$1 {
|
|
180
|
-
constructor(config) {
|
|
181
|
-
super(config);
|
|
182
|
-
this.classes = config.classes || "";
|
|
183
|
-
this.props = Object.keys(config).reduce((res, k) => {
|
|
184
|
-
if (ignoredKeys.indexOf(k) >= 0)
|
|
185
|
-
return res;
|
|
186
|
-
res[k] = config[k];
|
|
187
|
-
return res;
|
|
188
|
-
}, {});
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
class DynamicSelectModel extends DynamicSelectModel$1 {
|
|
192
|
-
constructor(config, layout) {
|
|
193
|
-
super(config, layout);
|
|
194
|
-
this.groupBy = config.groupBy || null;
|
|
195
|
-
this.inline = config.inline || false;
|
|
196
|
-
this.getClasses = ObjectUtils.isFunction(config.getClasses) ? config.getClasses : (() => "");
|
|
197
|
-
this.allowEmpty = config.allowEmpty || false;
|
|
198
|
-
this.mOptions = this.mOptions || [];
|
|
199
|
-
}
|
|
200
|
-
updateOptions() {
|
|
201
|
-
this.options$ = of(this.mOptions);
|
|
202
|
-
}
|
|
203
|
-
set options(options) {
|
|
204
|
-
if (Array.isArray(options)) {
|
|
205
|
-
this.mOptions = options.map(optionConfig => new DynamicFormOption(optionConfig));
|
|
206
|
-
this.updateOptions();
|
|
207
|
-
}
|
|
208
|
-
else if (isObservable(options)) {
|
|
209
|
-
this.options$ = options.pipe(map(optionsConfig => {
|
|
210
|
-
this.mOptions = optionsConfig.map(optionConfig => new DynamicFormOption(optionConfig));
|
|
211
|
-
return this.mOptions;
|
|
212
|
-
}));
|
|
213
|
-
}
|
|
214
|
-
else {
|
|
215
|
-
this.updateOptions();
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
get options() {
|
|
219
|
-
return this.mOptions;
|
|
220
|
-
}
|
|
221
|
-
insert(index, optionConfig) {
|
|
222
|
-
const option = new DynamicFormOption(optionConfig);
|
|
223
|
-
this.mOptions.splice(index, 0, option);
|
|
224
|
-
this.updateOptions();
|
|
225
|
-
return option;
|
|
226
|
-
}
|
|
227
|
-
remove(...indices) {
|
|
228
|
-
indices.forEach(index => this.mOptions.splice(index, 1));
|
|
229
|
-
this.updateOptions();
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
function createFormConfig(id, config) {
|
|
234
|
-
const res = (config || { id });
|
|
235
|
-
res.id = id;
|
|
236
|
-
res.label = ObjectUtils.isNullOrUndefined(config.label) ? id : config.label;
|
|
237
|
-
res.disabled = config.disabled || false;
|
|
238
|
-
res.hidden = config.hidden || false;
|
|
239
|
-
return res;
|
|
240
|
-
}
|
|
241
|
-
function createFormCheckbox(id, config, layout) {
|
|
242
|
-
const res = createFormConfig(id, config);
|
|
243
|
-
res.indeterminate = config.indeterminate || false;
|
|
244
|
-
return new DynamicCheckboxModel(res, layout);
|
|
245
|
-
}
|
|
246
|
-
function createFormDate(id, config, layout) {
|
|
247
|
-
const res = createFormConfig(id, config);
|
|
248
|
-
res.autoFocus = config.autoFocus || false;
|
|
249
|
-
res.focusedDate = config.focusedDate || new Date();
|
|
250
|
-
res.inline = config.inline || false;
|
|
251
|
-
return new DynamicDatePickerModel(res, layout);
|
|
252
|
-
}
|
|
253
|
-
function createFormEditor(id, config, layout) {
|
|
254
|
-
const res = createFormConfig(id, config);
|
|
255
|
-
return new DynamicEditorModel(res, layout);
|
|
256
|
-
}
|
|
257
|
-
function createFormArray(id, config, layout) {
|
|
258
|
-
const res = createFormConfig(id, config);
|
|
259
|
-
return new DynamicFormArrayModel(res, layout);
|
|
260
|
-
}
|
|
261
|
-
function createFormGroup(id, config, layout) {
|
|
262
|
-
const res = createFormConfig(id, config);
|
|
263
|
-
res.name = config.name || "";
|
|
264
|
-
return new DynamicFormGroupModel(res, layout);
|
|
265
|
-
}
|
|
266
|
-
function createFormInput(id, config, type = "text", layout) {
|
|
267
|
-
const res = createFormConfig(id, config);
|
|
268
|
-
res.inputType = config.inputType || type;
|
|
269
|
-
res.placeholder = config.placeholder || (config.inputType == "mask" ? "_" : "");
|
|
270
|
-
res.step = config.step || 1;
|
|
271
|
-
res.mask = config.mask || null;
|
|
272
|
-
return new DynamicInputModel(res, layout);
|
|
273
|
-
}
|
|
274
|
-
function createFormSelect(id, config, layout) {
|
|
275
|
-
const res = createFormConfig(id, config);
|
|
276
|
-
res.options = config.options || [];
|
|
277
|
-
return new DynamicSelectModel(res, layout);
|
|
278
|
-
}
|
|
279
|
-
function createFormTextarea(id, config, layout) {
|
|
280
|
-
const res = createFormConfig(id, config);
|
|
281
|
-
res.cols = config.cols || 10;
|
|
282
|
-
res.rows = config.rows || 3;
|
|
283
|
-
res.wrap = config.wrap || "soft";
|
|
284
|
-
return new DynamicTextAreaModel(res, layout);
|
|
285
|
-
}
|
|
286
|
-
function createFormFile(id, config, layout) {
|
|
287
|
-
const res = createFormConfig(id, config);
|
|
288
|
-
res.accept = config.accept || ["jpg", "jpeg", "png"];
|
|
289
|
-
res.multiple = config.multiple || false;
|
|
290
|
-
res.url = ObjectUtils.isString(config.url) ? config.url : "assets";
|
|
291
|
-
return new DynamicFileUploadModel(res, layout);
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
function getFormComponent(...providers) {
|
|
295
|
-
const factory = cachedFactory(providers);
|
|
296
|
-
return (model, injector) => {
|
|
297
|
-
const customizers = factory(injector);
|
|
298
|
-
for (const customizer of customizers) {
|
|
299
|
-
const component = customizer.acceptModel(model) ? customizer.getFormComponent(model) : null;
|
|
300
|
-
if (component) {
|
|
301
|
-
return component;
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
return null;
|
|
305
|
-
};
|
|
306
|
-
}
|
|
307
|
-
function customizeFormModel(...providers) {
|
|
308
|
-
const factory = cachedFactory(providers);
|
|
309
|
-
return (property, schema, model, config, injector) => __awaiter(this, void 0, void 0, function* () {
|
|
310
|
-
const customizers = factory(injector);
|
|
311
|
-
for (const customizer of customizers) {
|
|
312
|
-
const accept = customizer.acceptModel(model);
|
|
313
|
-
if (accept) {
|
|
314
|
-
return customizer.customizeModel(model, config, property, schema);
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
return model;
|
|
318
|
-
});
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
function isStringWithVal(val) {
|
|
322
|
-
return typeof val == "string" && val.length > 0;
|
|
323
|
-
}
|
|
324
|
-
function findRefs(property) {
|
|
325
|
-
var _a;
|
|
326
|
-
const refs = Array.isArray(property.allOf)
|
|
327
|
-
? property.allOf.map(o => o.$ref).filter(isStringWithVal)
|
|
328
|
-
: [(_a = property.items) === null || _a === void 0 ? void 0 : _a.$ref, property.$ref].filter(isStringWithVal);
|
|
329
|
-
return refs.map(t => t.split("/").pop());
|
|
330
|
-
}
|
|
331
|
-
function replaceSpecialChars(str, to = "-") {
|
|
332
|
-
return `${str}`.replace(/[&\/\\#, +()$~%.@'":*?<>{}]/g, to);
|
|
333
|
-
}
|
|
334
|
-
function mergeFormModels(formModels) {
|
|
335
|
-
const res = [];
|
|
336
|
-
for (const formModel of formModels) {
|
|
337
|
-
for (const subModel of formModel) {
|
|
338
|
-
const index = res.findIndex(t => t.id == subModel.id);
|
|
339
|
-
if (index >= 0) {
|
|
340
|
-
res[index] = subModel;
|
|
341
|
-
continue;
|
|
342
|
-
}
|
|
343
|
-
res.push(subModel);
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
return res;
|
|
347
|
-
}
|
|
348
|
-
function collectPathAble(start, getter) {
|
|
349
|
-
if (!start || !getter(start))
|
|
350
|
-
return [];
|
|
351
|
-
const parts = [];
|
|
352
|
-
let currentPath = start;
|
|
353
|
-
while (currentPath) {
|
|
354
|
-
const val = getter(currentPath);
|
|
355
|
-
if (val) {
|
|
356
|
-
parts.unshift(val);
|
|
357
|
-
}
|
|
358
|
-
currentPath = currentPath.parent;
|
|
359
|
-
}
|
|
360
|
-
return parts;
|
|
361
|
-
}
|
|
362
|
-
function getDynamicPath(start) {
|
|
363
|
-
return collectPathAble(start, t => t.id).join(".");
|
|
364
|
-
}
|
|
365
|
-
const MIN_INPUT_NUM = -999999999;
|
|
366
|
-
const MAX_INPUT_NUM = 999999999;
|
|
367
|
-
const EDITOR_FORMATS = ["php", "json", "html", "css", "scss"];
|
|
368
|
-
|
|
369
|
-
function validateJSON(control) {
|
|
370
|
-
const value = control.value;
|
|
371
|
-
if (!value)
|
|
372
|
-
return null;
|
|
373
|
-
try {
|
|
374
|
-
JSON.parse(value);
|
|
375
|
-
return null;
|
|
376
|
-
}
|
|
377
|
-
catch (e) {
|
|
378
|
-
return { json: true };
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
function validateRequiredTranslation(control) {
|
|
382
|
-
const value = control.value;
|
|
383
|
-
if (!value || value.length == 0)
|
|
384
|
-
return { requiredTranslation: true };
|
|
385
|
-
return value.findIndex(t => (t.lang == "de" || t.lang == "en") && !t.translation) < 0
|
|
386
|
-
? null
|
|
387
|
-
: { requiredTranslation: true };
|
|
388
|
-
}
|
|
389
|
-
function validatePhone(control) {
|
|
390
|
-
const value = control.value;
|
|
391
|
-
if (!value)
|
|
392
|
-
return Promise.resolve(null);
|
|
393
|
-
const phoneRegexp = /^(?:\d){10,12}$/;
|
|
394
|
-
return phoneRegexp.test(value) ? null : { phone: true };
|
|
395
|
-
}
|
|
396
|
-
function validateItemsMinLength(minLength) {
|
|
397
|
-
return (control) => {
|
|
398
|
-
const value = control.value;
|
|
399
|
-
return (Array.isArray(value) && value.every(v => typeof v == "string" && v.length >= minLength))
|
|
400
|
-
? null : { itemsMinLength: minLength };
|
|
401
|
-
};
|
|
402
|
-
}
|
|
403
|
-
function validateItemsMaxLength(maxLength) {
|
|
404
|
-
return (control) => {
|
|
405
|
-
const value = control.value;
|
|
406
|
-
return (Array.isArray(value) && value.every(v => typeof v == "string" && v.length <= maxLength))
|
|
407
|
-
? null : { itemsMaxLength: maxLength };
|
|
408
|
-
};
|
|
409
|
-
}
|
|
410
|
-
function validateItemsMinValue(min) {
|
|
411
|
-
return (control) => {
|
|
412
|
-
const value = control.value;
|
|
413
|
-
return (Array.isArray(value) && value.every(v => typeof v == "number" && v >= min))
|
|
414
|
-
? null : { itemsMinValue: min };
|
|
415
|
-
};
|
|
416
|
-
}
|
|
417
|
-
function validateItemsMaxValue(max) {
|
|
418
|
-
return (control) => {
|
|
419
|
-
const value = control.value;
|
|
420
|
-
return (Array.isArray(value) && value.every(v => typeof v == "number" && v <= max))
|
|
421
|
-
? null : { itemsMaxValue: max };
|
|
422
|
-
};
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
const indexLabels = ["$ix", "$pix"];
|
|
426
|
-
class FormSubject extends Subject {
|
|
427
|
-
constructor(notifyCallback) {
|
|
428
|
-
super();
|
|
429
|
-
this.notifyCallback = notifyCallback;
|
|
430
|
-
}
|
|
431
|
-
handleNotifiedValue(controlModel, control, val) {
|
|
432
|
-
val.then(v => this.next(v));
|
|
433
|
-
}
|
|
434
|
-
notify(controlModel, control, root) {
|
|
435
|
-
const indexes = {};
|
|
436
|
-
let path = controlModel;
|
|
437
|
-
let ix = 0;
|
|
438
|
-
while (path) {
|
|
439
|
-
if (!isNaN(path.index)) {
|
|
440
|
-
const key = indexLabels[ix++] || `$pix${ix}`;
|
|
441
|
-
indexes[key] = path.index;
|
|
442
|
-
}
|
|
443
|
-
path = path.parent;
|
|
444
|
-
}
|
|
445
|
-
let value = this.notifyCallback(controlModel, control, root, indexes);
|
|
446
|
-
if (!(value instanceof Promise)) {
|
|
447
|
-
value = Promise.resolve(value);
|
|
448
|
-
}
|
|
449
|
-
this.handleNotifiedValue(controlModel, control, value);
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
class FormSelectSubject extends FormSubject {
|
|
454
|
-
handleNotifiedValue(controlModel, control, val) {
|
|
455
|
-
val.then(options => {
|
|
456
|
-
var _a, _b;
|
|
457
|
-
if (options.length == 0) {
|
|
458
|
-
this.next(options);
|
|
459
|
-
return;
|
|
460
|
-
}
|
|
461
|
-
const currentVal = control.value;
|
|
462
|
-
if (controlModel.multiple) {
|
|
463
|
-
const correctVal = (currentVal || []).filter(t => options.findIndex(o => o.value == t) >= 0);
|
|
464
|
-
if (correctVal.length !== (currentVal === null || currentVal === void 0 ? void 0 : currentVal.length)) {
|
|
465
|
-
control.setValue(correctVal, { onlySelf: true, emitEvent: false });
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
else {
|
|
469
|
-
const option = options.find(t => t.value == currentVal);
|
|
470
|
-
if (!option) {
|
|
471
|
-
control.setValue(controlModel.allowEmpty ? null : (_b = (_a = options[0]) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : null, { onlySelf: true, emitEvent: false });
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
this.next(options);
|
|
475
|
-
});
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
function getFormValidationErrors(controls, parentPath = "") {
|
|
480
|
-
const errors = [];
|
|
481
|
-
Object.entries(controls).forEach(([name, control], ix) => {
|
|
482
|
-
const path = !parentPath ? name : `${parentPath}.${name}`;
|
|
483
|
-
if (control instanceof FormGroup) {
|
|
484
|
-
getFormValidationErrors(control.controls, path).forEach(error => errors.push(error));
|
|
485
|
-
return;
|
|
486
|
-
}
|
|
487
|
-
if (control instanceof FormArray) {
|
|
488
|
-
control.controls.forEach((control, ix) => {
|
|
489
|
-
getFormValidationErrors(control.controls, `${path}.${ix}`).forEach(error => errors.push(error));
|
|
490
|
-
});
|
|
491
|
-
return;
|
|
492
|
-
}
|
|
493
|
-
Object.entries(control.errors || {}).forEach(([errorKey, errorValue]) => {
|
|
494
|
-
errors.push({ control, path, errorKey, errorValue });
|
|
495
|
-
});
|
|
496
|
-
});
|
|
497
|
-
return errors;
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
class DynamicFormService extends DynamicFormService$1 {
|
|
501
|
-
constructor(cs, vs, openApi, injector) {
|
|
502
|
-
super(cs, vs);
|
|
503
|
-
this.openApi = openApi;
|
|
504
|
-
this.injector = injector;
|
|
505
|
-
}
|
|
506
|
-
get api() {
|
|
507
|
-
return this.openApi.api;
|
|
508
|
-
}
|
|
509
|
-
get language() {
|
|
510
|
-
return this.api.language;
|
|
511
|
-
}
|
|
512
|
-
patchGroup(value, formModel, formGroup) {
|
|
513
|
-
value = ObjectUtils.copy(value);
|
|
514
|
-
this.patchValueRecursive(value, formModel, formGroup);
|
|
515
|
-
formGroup.patchValue(value);
|
|
516
|
-
this.detectChanges();
|
|
517
|
-
}
|
|
518
|
-
patchForm(value, component) {
|
|
519
|
-
value = ObjectUtils.copy(value);
|
|
520
|
-
this.patchValueRecursive(value, component.model, component.group);
|
|
521
|
-
component.group.patchValue(value);
|
|
522
|
-
this.detectChanges(component);
|
|
523
|
-
}
|
|
524
|
-
serialize(formModel, formGroup) {
|
|
525
|
-
return this.serializeRecursive(formModel, formGroup);
|
|
526
|
-
}
|
|
527
|
-
notifyChanges(formModel, formGroup) {
|
|
528
|
-
this.notifyChangesRecursive(formModel, formGroup, formModel);
|
|
529
|
-
}
|
|
530
|
-
showErrors(form) {
|
|
531
|
-
this.showErrorsForGroup(form.group);
|
|
532
|
-
this.detectChanges(form);
|
|
533
|
-
}
|
|
534
|
-
getErrors(form) {
|
|
535
|
-
this.showErrors(form);
|
|
536
|
-
return new Promise(resolve => {
|
|
537
|
-
setTimeout(() => {
|
|
538
|
-
resolve(getFormValidationErrors(form.group.controls, ""));
|
|
539
|
-
}, 500);
|
|
540
|
-
});
|
|
541
|
-
}
|
|
542
|
-
patchValueRecursive(value, formModel, formGroup) {
|
|
543
|
-
if (!value)
|
|
544
|
-
return;
|
|
545
|
-
formModel === null || formModel === void 0 ? void 0 : formModel.forEach(subModel => {
|
|
546
|
-
const key = subModel.id;
|
|
547
|
-
const subValue = value[key];
|
|
548
|
-
const subControl = this.findControlByModel(subModel, formGroup);
|
|
549
|
-
if (subModel instanceof DynamicSelectModel && ObjectUtils.isObject(subValue)) {
|
|
550
|
-
value[key] = subValue.id || subValue._id || subValue;
|
|
551
|
-
return;
|
|
552
|
-
}
|
|
553
|
-
if (subModel instanceof DynamicDatePickerModel) {
|
|
554
|
-
value[key] = this.convertToDate(subValue);
|
|
555
|
-
return;
|
|
556
|
-
}
|
|
557
|
-
if (subModel instanceof DynamicFormArrayModel) {
|
|
558
|
-
const length = Array.isArray(subValue) ? subValue.length : 0;
|
|
559
|
-
const subArray = subControl;
|
|
560
|
-
while (subModel.size > length) {
|
|
561
|
-
this.removeFormArrayGroup(0, subArray, subModel);
|
|
562
|
-
}
|
|
563
|
-
while (subModel.size < length) {
|
|
564
|
-
this.insertFormArrayGroup(subModel.size, subArray, subModel);
|
|
565
|
-
}
|
|
566
|
-
for (let i = 0; i < length; i++) {
|
|
567
|
-
const itemModel = subModel.get(i);
|
|
568
|
-
this.patchValueRecursive(subValue[i], itemModel.group, subArray.at(i));
|
|
569
|
-
}
|
|
570
|
-
return;
|
|
571
|
-
}
|
|
572
|
-
if (subModel instanceof DynamicFormGroupModel) {
|
|
573
|
-
this.patchValueRecursive(subValue, subModel.group, subControl);
|
|
574
|
-
}
|
|
575
|
-
});
|
|
576
|
-
}
|
|
577
|
-
serializeRecursive(formModel, formGroup) {
|
|
578
|
-
var _a, _b, _c;
|
|
579
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
580
|
-
const result = {};
|
|
581
|
-
if (!formModel || !formGroup || !formGroup.value)
|
|
582
|
-
return result;
|
|
583
|
-
for (const i in formModel) {
|
|
584
|
-
const subModel = formModel[i];
|
|
585
|
-
const subControl = this.findControlByModel(subModel, formGroup);
|
|
586
|
-
const serializer = (_a = subModel.additional) === null || _a === void 0 ? void 0 : _a.serializer;
|
|
587
|
-
if (ObjectUtils.isFunction(serializer)) {
|
|
588
|
-
result[subModel.id] = yield serializer(subModel, subControl);
|
|
589
|
-
continue;
|
|
590
|
-
}
|
|
591
|
-
if (subModel.hidden && !((_b = subModel.additional) === null || _b === void 0 ? void 0 : _b.serialize))
|
|
592
|
-
continue;
|
|
593
|
-
if (subModel instanceof DynamicFormArrayModel) {
|
|
594
|
-
const length = Array.isArray(subControl.value) ? subControl.value.length : 0;
|
|
595
|
-
const subArray = subControl;
|
|
596
|
-
const resArray = [];
|
|
597
|
-
for (let i = 0; i < length; i++) {
|
|
598
|
-
const itemModel = subModel.get(i);
|
|
599
|
-
resArray.push(yield this.serializeRecursive(itemModel.group, subArray.at(i)));
|
|
600
|
-
}
|
|
601
|
-
result[subModel.id] = resArray;
|
|
602
|
-
continue;
|
|
603
|
-
}
|
|
604
|
-
if (subModel instanceof DynamicInputModel && !ObjectUtils.isNullOrUndefined(subControl.value)) {
|
|
605
|
-
result[subModel.id] = subModel.inputType == "number"
|
|
606
|
-
? (_c = parseFloat((`${subControl.value}` || "0").replace(/,/gi, "."))) !== null && _c !== void 0 ? _c : null
|
|
607
|
-
: subControl.value;
|
|
608
|
-
continue;
|
|
609
|
-
}
|
|
610
|
-
if (subModel instanceof DynamicFormGroupModel) {
|
|
611
|
-
result[subModel.id] = yield this.serializeRecursive(subModel.group, subControl);
|
|
612
|
-
continue;
|
|
613
|
-
}
|
|
614
|
-
result[subModel.id] = subControl.value;
|
|
615
|
-
}
|
|
616
|
-
return result;
|
|
617
|
-
});
|
|
618
|
-
}
|
|
619
|
-
notifyChangesRecursive(formModel, formGroup, root) {
|
|
620
|
-
if (!formModel || !formGroup)
|
|
621
|
-
return;
|
|
622
|
-
for (const i in formModel) {
|
|
623
|
-
const subModel = formModel[i];
|
|
624
|
-
const subControl = this.findControlByModel(subModel, formGroup);
|
|
625
|
-
if (subModel instanceof DynamicFormArrayModel) {
|
|
626
|
-
const length = Array.isArray(subControl.value) ? subControl.value.length : 0;
|
|
627
|
-
const subArray = subControl;
|
|
628
|
-
for (let i = 0; i < length; i++) {
|
|
629
|
-
const itemModel = subModel.get(i);
|
|
630
|
-
this.notifyChangesRecursive(itemModel.group, subArray.at(i), root);
|
|
631
|
-
}
|
|
632
|
-
continue;
|
|
633
|
-
}
|
|
634
|
-
if (subModel instanceof DynamicFormGroupModel) {
|
|
635
|
-
this.notifyChangesRecursive(subModel.group, subControl, root);
|
|
636
|
-
continue;
|
|
637
|
-
}
|
|
638
|
-
this.updateSelectOptions(subModel, subControl, root);
|
|
639
|
-
}
|
|
640
|
-
}
|
|
641
|
-
updateSelectOptions(formControlModel, formControl, root) {
|
|
642
|
-
if (formControlModel instanceof DynamicSelectModel) {
|
|
643
|
-
let options = formControlModel.options$;
|
|
644
|
-
if (options instanceof FormSubject) {
|
|
645
|
-
options.notify(formControlModel, formControl, root);
|
|
646
|
-
return;
|
|
647
|
-
}
|
|
648
|
-
while (options instanceof Subject && options.source) {
|
|
649
|
-
options = options.source;
|
|
650
|
-
if (options instanceof FormSubject) {
|
|
651
|
-
options.notify(formControlModel, formControl, root);
|
|
652
|
-
}
|
|
653
|
-
}
|
|
654
|
-
}
|
|
655
|
-
}
|
|
656
|
-
showErrorsForGroup(formGroup) {
|
|
657
|
-
if (!formGroup)
|
|
658
|
-
return;
|
|
659
|
-
formGroup.markAsTouched({ onlySelf: true });
|
|
660
|
-
const controls = Object.keys(formGroup.controls).map(id => formGroup.controls[id]);
|
|
661
|
-
this.showErrorsForControls(controls);
|
|
662
|
-
}
|
|
663
|
-
showErrorsForControls(controls) {
|
|
664
|
-
controls.forEach(control => {
|
|
665
|
-
if (control instanceof FormGroup) {
|
|
666
|
-
this.showErrorsForGroup(control);
|
|
667
|
-
return;
|
|
668
|
-
}
|
|
669
|
-
control.markAsTouched({ onlySelf: true });
|
|
670
|
-
if (control instanceof FormArray) {
|
|
671
|
-
this.showErrorsForControls(control.controls);
|
|
672
|
-
}
|
|
673
|
-
});
|
|
674
|
-
}
|
|
675
|
-
convertToDate(value) {
|
|
676
|
-
if (ObjectUtils.isNullOrUndefined(value))
|
|
677
|
-
return null;
|
|
678
|
-
const date = ObjectUtils.isDate(value)
|
|
679
|
-
? value
|
|
680
|
-
: new Date(value);
|
|
681
|
-
return isNaN(date) ? new Date() : date;
|
|
682
|
-
}
|
|
683
|
-
getFormModelForSchema(name, customizeModel) {
|
|
684
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
685
|
-
return (yield this.getFormGroupModelForSchema(name, customizeModel)).group;
|
|
686
|
-
});
|
|
687
|
-
}
|
|
688
|
-
getFormGroupModelForSchema(name, customizeModel) {
|
|
689
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
690
|
-
this.api.cache = {};
|
|
691
|
-
this.schemas = yield this.openApi.getSchemas();
|
|
692
|
-
const fieldSets = [];
|
|
693
|
-
const customizeModels = (property, schema, modelType, config) => __awaiter(this, void 0, void 0, function* () {
|
|
694
|
-
const model = new modelType(config);
|
|
695
|
-
if (model instanceof DynamicFormValueControlModel) {
|
|
696
|
-
model.value = (model instanceof DynamicDatePickerModel)
|
|
697
|
-
? this.convertToDate(property.default) : property.default;
|
|
698
|
-
}
|
|
699
|
-
if (!ObjectUtils.isFunction(customizeModel))
|
|
700
|
-
return [model];
|
|
701
|
-
let res = customizeModel(property, schema, model, config, this.injector);
|
|
702
|
-
if (!res)
|
|
703
|
-
return [model];
|
|
704
|
-
if (res instanceof Promise) {
|
|
705
|
-
res = yield res;
|
|
706
|
-
}
|
|
707
|
-
return Array.isArray(res) ? res : [res];
|
|
708
|
-
});
|
|
709
|
-
const schema = this.schemas[name];
|
|
710
|
-
const controls = yield this.getFormModelForSchemaDef(schema, fieldSets, customizeModels);
|
|
711
|
-
const idFields = [
|
|
712
|
-
createFormInput("id", { hidden: true }),
|
|
713
|
-
createFormInput("_id", { hidden: true })
|
|
714
|
-
].filter(t => !controls.some(c => c.id == t.id));
|
|
715
|
-
const config = {
|
|
716
|
-
id: "root",
|
|
717
|
-
group: [
|
|
718
|
-
// -- Hidden id fields --
|
|
719
|
-
...idFields,
|
|
720
|
-
// -- Main form controls --
|
|
721
|
-
...controls
|
|
722
|
-
],
|
|
723
|
-
fieldSets
|
|
724
|
-
};
|
|
725
|
-
const root = yield customizeModels({
|
|
726
|
-
id: "root",
|
|
727
|
-
type: "object",
|
|
728
|
-
properties: schema.properties
|
|
729
|
-
}, schema, DynamicFormGroupModel, config);
|
|
730
|
-
// Check if the customized root wrapper returned an array
|
|
731
|
-
if (Array.isArray(root)) {
|
|
732
|
-
controls.length = 0;
|
|
733
|
-
for (const model of root) {
|
|
734
|
-
if (model instanceof DynamicFormGroupModel && model.id === "root") {
|
|
735
|
-
return model;
|
|
736
|
-
}
|
|
737
|
-
else {
|
|
738
|
-
controls.push(model);
|
|
739
|
-
}
|
|
740
|
-
}
|
|
741
|
-
}
|
|
742
|
-
return new DynamicFormGroupModel(Object.assign(Object.assign({}, config), { group: controls }));
|
|
743
|
-
});
|
|
744
|
-
}
|
|
745
|
-
getFormModelForSchemaDef(schema, fieldSets, customizeModels) {
|
|
746
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
747
|
-
if (!schema)
|
|
748
|
-
return [];
|
|
749
|
-
const keys = Object.keys(schema.properties || {});
|
|
750
|
-
const controls = [];
|
|
751
|
-
for (const p of keys) {
|
|
752
|
-
const property = schema.properties[p];
|
|
753
|
-
const fsName = property.hidden ? null : String(property.fieldSet || "");
|
|
754
|
-
if (fsName) {
|
|
755
|
-
const fs = fieldSets.find(t => t.id === fsName);
|
|
756
|
-
if (fs) {
|
|
757
|
-
fs.fields.push(p);
|
|
758
|
-
}
|
|
759
|
-
else {
|
|
760
|
-
fieldSets.push({ id: fsName, legend: `legend.${fsName}`, fields: [p] });
|
|
761
|
-
}
|
|
762
|
-
}
|
|
763
|
-
const models = yield this.getFormControlModels(property, schema, customizeModels);
|
|
764
|
-
controls.push(...models);
|
|
765
|
-
}
|
|
766
|
-
return controls.filter(t => null !== t);
|
|
767
|
-
});
|
|
768
|
-
}
|
|
769
|
-
checkIsEditorProperty(property) {
|
|
770
|
-
if (!property.format)
|
|
771
|
-
return false;
|
|
772
|
-
return EDITOR_FORMATS.indexOf(property.format) >= 0 || property.format.endsWith("script");
|
|
773
|
-
}
|
|
774
|
-
getFormControlModels(property, schema, customizeModels) {
|
|
775
|
-
var _a;
|
|
776
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
777
|
-
const $enum = ((_a = property.items) === null || _a === void 0 ? void 0 : _a.enum) || property.enum;
|
|
778
|
-
if (Array.isArray($enum) || isStringWithVal(property.optionsPath) || isStringWithVal(property.endpoint)) {
|
|
779
|
-
return customizeModels(property, schema, DynamicSelectModel, this.getFormSelectConfig(property, schema));
|
|
780
|
-
}
|
|
781
|
-
switch (property.type) {
|
|
782
|
-
case "string":
|
|
783
|
-
case "number":
|
|
784
|
-
case "integer":
|
|
785
|
-
case "textarea":
|
|
786
|
-
if (this.checkIsEditorProperty(property)) {
|
|
787
|
-
return customizeModels(property, schema, DynamicEditorModel, this.getFormEditorConfig(property, schema));
|
|
788
|
-
}
|
|
789
|
-
if (property.format == "textarea") {
|
|
790
|
-
return customizeModels(property, schema, DynamicTextAreaModel, this.getFormTextareaConfig(property, schema));
|
|
791
|
-
}
|
|
792
|
-
if (property.format == "date") {
|
|
793
|
-
return customizeModels(property, schema, DynamicDatePickerModel, this.getFormDatepickerConfig(property, schema));
|
|
794
|
-
}
|
|
795
|
-
return customizeModels(property, schema, DynamicInputModel, this.getFormInputConfig(property, schema));
|
|
796
|
-
case "object":
|
|
797
|
-
return customizeModels(property, schema, DynamicEditorModel, this.getFormEditorConfig(property, schema));
|
|
798
|
-
case "boolean":
|
|
799
|
-
return customizeModels(property, schema, DynamicCheckboxModel, this.getFormCheckboxConfig(property, schema));
|
|
800
|
-
case "array":
|
|
801
|
-
if (findRefs(property).length > 0) {
|
|
802
|
-
return customizeModels(property, schema, DynamicFormArrayModel, yield this.getFormArrayConfig(property, schema, customizeModels));
|
|
803
|
-
}
|
|
804
|
-
else {
|
|
805
|
-
return customizeModels(property, schema, DynamicInputModel, this.getFormInputConfig(property, schema));
|
|
806
|
-
}
|
|
807
|
-
case "file":
|
|
808
|
-
return customizeModels(property, schema, DynamicFileUploadModel, this.getFormUploadConfig(property, schema));
|
|
809
|
-
}
|
|
810
|
-
if (findRefs(property).length > 0) {
|
|
811
|
-
return customizeModels(property, schema, DynamicFormGroupModel, yield this.getFormGroupConfig(property, schema, customizeModels));
|
|
812
|
-
}
|
|
813
|
-
return [];
|
|
814
|
-
});
|
|
815
|
-
}
|
|
816
|
-
findModelByPath(parent, path) {
|
|
817
|
-
if (path.length == 0)
|
|
818
|
-
return parent;
|
|
819
|
-
const next = path.shift();
|
|
820
|
-
if (Array.isArray(parent)) {
|
|
821
|
-
return this.findModelByPath(parent.find(t => t.id == next), path);
|
|
822
|
-
}
|
|
823
|
-
if (parent instanceof DynamicFormGroupModel || parent instanceof DynamicFormArrayGroupModel) {
|
|
824
|
-
return this.findModelByPath(parent.group.find(t => t.id == next), path);
|
|
825
|
-
}
|
|
826
|
-
if (parent instanceof DynamicFormArrayModel) {
|
|
827
|
-
return this.findModelByPath(parent.groups.find(t => t.index == next), path);
|
|
828
|
-
}
|
|
829
|
-
return parent;
|
|
830
|
-
}
|
|
831
|
-
getFormControlConfig(property, schema) {
|
|
832
|
-
const validators = this.getValidators(property, schema);
|
|
833
|
-
const errorMessages = Object.keys(validators).reduce((res, key) => {
|
|
834
|
-
res[key] = `error.${key}`;
|
|
835
|
-
return res;
|
|
836
|
-
}, {});
|
|
837
|
-
return {
|
|
838
|
-
id: property.id,
|
|
839
|
-
label: ObjectUtils.isString(property.label) ? property.label : property.id,
|
|
840
|
-
hidden: property.hidden,
|
|
841
|
-
disabled: property.disabled,
|
|
842
|
-
validators,
|
|
843
|
-
errorMessages,
|
|
844
|
-
additional: Object.assign({}, property)
|
|
845
|
-
};
|
|
846
|
-
}
|
|
847
|
-
getFormArrayConfig(property, schema, customizeModels) {
|
|
848
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
849
|
-
const fieldSets = [];
|
|
850
|
-
const subSchemas = findRefs(property).map(ref => this.schemas[ref]);
|
|
851
|
-
const subModels = yield Promise.all(subSchemas.map(s => this.getFormModelForSchemaDef(s, fieldSets, customizeModels)));
|
|
852
|
-
return Object.assign(this.getFormControlConfig(property, schema), {
|
|
853
|
-
groupFactory: () => mergeFormModels(ObjectUtils.copy(subModels)),
|
|
854
|
-
initialCount: property.initialCount || 0,
|
|
855
|
-
sortable: property.sortable || false,
|
|
856
|
-
useTabs: property.useTabs || false,
|
|
857
|
-
addItem: property.addItem !== false,
|
|
858
|
-
insertItem: property.insertItem !== false,
|
|
859
|
-
cloneItem: property.cloneItem !== false,
|
|
860
|
-
moveItem: property.moveItem !== false,
|
|
861
|
-
removeItem: property.removeItem !== false,
|
|
862
|
-
clearItems: property.clearItems !== false
|
|
863
|
-
});
|
|
864
|
-
});
|
|
865
|
-
}
|
|
866
|
-
getFormGroupConfig(property, schema, customizeModels) {
|
|
867
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
868
|
-
const fieldSets = [];
|
|
869
|
-
const subSchemas = findRefs(property).map(ref => this.schemas[ref]);
|
|
870
|
-
const subModels = yield Promise.all(subSchemas.map(s => this.getFormModelForSchemaDef(s, fieldSets, customizeModels)));
|
|
871
|
-
return Object.assign(this.getFormControlConfig(property, schema), {
|
|
872
|
-
fieldSets,
|
|
873
|
-
group: mergeFormModels(subModels)
|
|
874
|
-
});
|
|
875
|
-
});
|
|
876
|
-
}
|
|
877
|
-
getFormInputConfig(property, schema) {
|
|
878
|
-
var _a;
|
|
879
|
-
let inputType = StringUtils.has(property.id, "password", "Password") ? "password" : (property.format || ((_a = property.items) === null || _a === void 0 ? void 0 : _a.type) || property.type);
|
|
880
|
-
switch (inputType) {
|
|
881
|
-
case "string":
|
|
882
|
-
inputType = "text";
|
|
883
|
-
break;
|
|
884
|
-
case "boolean":
|
|
885
|
-
inputType = "checkbox";
|
|
886
|
-
break;
|
|
887
|
-
case "textarea":
|
|
888
|
-
inputType = "textarea";
|
|
889
|
-
break;
|
|
890
|
-
case "integer":
|
|
891
|
-
inputType = "number";
|
|
892
|
-
break;
|
|
893
|
-
}
|
|
894
|
-
const sub = property.type == "array" ? property.items || property : property;
|
|
895
|
-
return Object.assign(this.getFormControlConfig(property, schema), {
|
|
896
|
-
inputType,
|
|
897
|
-
autoComplete: property.autoComplete || "off",
|
|
898
|
-
multiple: property.type == "array",
|
|
899
|
-
accept: ObjectUtils.isString(property.accept) ? property.accept : null,
|
|
900
|
-
mask: ObjectUtils.isString(property.mask) ? property.mask : null,
|
|
901
|
-
pattern: ObjectUtils.isString(property.pattern) ? property.pattern : null,
|
|
902
|
-
step: isNaN(sub.step) ? (isNaN(property.step) ? 1 : property.step) : sub.step,
|
|
903
|
-
min: isNaN(sub.minimum) ? MIN_INPUT_NUM : sub.minimum,
|
|
904
|
-
max: isNaN(sub.maximum) ? MAX_INPUT_NUM : sub.maximum,
|
|
905
|
-
minLength: isNaN(sub.minLength) ? 0 : sub.minLength,
|
|
906
|
-
maxLength: isNaN(sub.maxLength) ? MAX_INPUT_NUM : sub.maxLength,
|
|
907
|
-
placeholder: property.placeholder || ""
|
|
908
|
-
});
|
|
909
|
-
}
|
|
910
|
-
getFormEditorConfig(property, schema) {
|
|
911
|
-
const sub = property.type == "array" ? property.items || property : property;
|
|
912
|
-
return Object.assign(this.getFormControlConfig(property, schema), {
|
|
913
|
-
inputType: property.format || "json",
|
|
914
|
-
convertObject: property.type !== "string",
|
|
915
|
-
autoComplete: property.autoComplete || "off",
|
|
916
|
-
multiple: property.type == "array",
|
|
917
|
-
accept: ObjectUtils.isString(property.accept) ? property.accept : null,
|
|
918
|
-
mask: ObjectUtils.isString(property.mask) ? property.mask : null,
|
|
919
|
-
pattern: ObjectUtils.isString(property.pattern) ? property.pattern : null,
|
|
920
|
-
step: isNaN(sub.step) ? (isNaN(property.step) ? 1 : property.step) : sub.step,
|
|
921
|
-
minLength: isNaN(sub.minLength) ? 0 : sub.minLength,
|
|
922
|
-
maxLength: isNaN(sub.maxLength) ? MAX_INPUT_NUM : sub.maxLength,
|
|
923
|
-
placeholder: property.placeholder || ""
|
|
924
|
-
});
|
|
925
|
-
}
|
|
926
|
-
getFormTextareaConfig(property, schema) {
|
|
927
|
-
return Object.assign(this.getFormControlConfig(property, schema), {
|
|
928
|
-
cols: property.cols || null,
|
|
929
|
-
rows: property.rows || 10,
|
|
930
|
-
wrap: property.wrap || false,
|
|
931
|
-
autoComplete: property.autoComplete || "off",
|
|
932
|
-
multiple: property.type == "array",
|
|
933
|
-
minLength: isNaN(property.minLength) ? 0 : property.minLength,
|
|
934
|
-
maxLength: isNaN(property.maxLength) ? MAX_INPUT_NUM : property.maxLength,
|
|
935
|
-
placeholder: property.placeholder || ""
|
|
936
|
-
});
|
|
937
|
-
}
|
|
938
|
-
getFormDatepickerConfig(property, schema) {
|
|
939
|
-
return Object.assign(this.getFormControlConfig(property, schema), {
|
|
940
|
-
format: property.dateFormat || "dd.MM.yyyy",
|
|
941
|
-
min: this.convertToDate(property.min),
|
|
942
|
-
max: this.convertToDate(property.max),
|
|
943
|
-
});
|
|
944
|
-
}
|
|
945
|
-
getFormSelectOptions(property, schema) {
|
|
946
|
-
var _a;
|
|
947
|
-
const $enum = ((_a = property.items) === null || _a === void 0 ? void 0 : _a.enum) || property.enum;
|
|
948
|
-
if (Array.isArray($enum)) {
|
|
949
|
-
return new FormSelectSubject((selectModel, formControl) => {
|
|
950
|
-
const options = $enum.map(value => {
|
|
951
|
-
const label = property.translatable ? `${property.id}.${value}` : `${value}`;
|
|
952
|
-
return { value, label };
|
|
953
|
-
});
|
|
954
|
-
return this.fixSelectOptions(selectModel, formControl, options);
|
|
955
|
-
});
|
|
956
|
-
}
|
|
957
|
-
if (isStringWithVal(property.optionsPath)) {
|
|
958
|
-
return new FormSelectSubject((selectModel, control, root, indexes) => __awaiter(this, void 0, void 0, function* () {
|
|
959
|
-
let path = property.optionsPath;
|
|
960
|
-
let target = control;
|
|
961
|
-
let model = selectModel;
|
|
962
|
-
if (path.startsWith("$root")) {
|
|
963
|
-
path = path.substring(5);
|
|
964
|
-
while (target.parent) {
|
|
965
|
-
target = target.parent;
|
|
966
|
-
}
|
|
967
|
-
model = root;
|
|
968
|
-
}
|
|
969
|
-
while (path.startsWith(".")) {
|
|
970
|
-
path = path.substring(1);
|
|
971
|
-
if (target.parent) {
|
|
972
|
-
target = target.parent;
|
|
973
|
-
}
|
|
974
|
-
model = model.parent || root;
|
|
975
|
-
}
|
|
976
|
-
Object.keys(indexes).forEach(key => {
|
|
977
|
-
path = path.replace(key, indexes[key]);
|
|
978
|
-
});
|
|
979
|
-
model = this.findModelByPath(model, path.split("."));
|
|
980
|
-
const modelOptions = model instanceof DynamicSelectModel
|
|
981
|
-
? yield firstValueFrom(model.options$) :
|
|
982
|
-
[];
|
|
983
|
-
const value = ObjectUtils.getValue(target.value, path);
|
|
984
|
-
const options = (!ObjectUtils.isArray(value) ? [] : value).map(value => {
|
|
985
|
-
const modelOption = modelOptions.find(t => t.value == value);
|
|
986
|
-
return { value, label: (modelOption === null || modelOption === void 0 ? void 0 : modelOption.label) || value };
|
|
987
|
-
});
|
|
988
|
-
return this.fixSelectOptions(selectModel, control, options);
|
|
989
|
-
}));
|
|
990
|
-
}
|
|
991
|
-
return new FormSelectSubject((selectModel, control) => __awaiter(this, void 0, void 0, function* () {
|
|
992
|
-
var _b;
|
|
993
|
-
const entries = Object.entries(((_b = control.root) === null || _b === void 0 ? void 0 : _b.value) || {});
|
|
994
|
-
const endpoint = entries.reduce((res, [key, value]) => {
|
|
995
|
-
return res.replace(new RegExp(`$${key}`, "gi"), `${value}`);
|
|
996
|
-
}, `${property.endpoint}`);
|
|
997
|
-
this.api.cache[endpoint] = this.api.cache[endpoint] || this.api.list(endpoint, this.api.makeListParams(1, -1)).then(result => {
|
|
998
|
-
const items = ObjectUtils.isArray(result)
|
|
999
|
-
? result
|
|
1000
|
-
: (ObjectUtils.isArray(result.items) ? result.items : []);
|
|
1001
|
-
return items.map(i => {
|
|
1002
|
-
const item = ObjectUtils.isObject(i) ? i : { id: i };
|
|
1003
|
-
return Object.assign(Object.assign({}, item), { value: item.id || item._id, label: item[property.labelField] || item.label || item.id || item._id });
|
|
1004
|
-
});
|
|
1005
|
-
});
|
|
1006
|
-
const options = (yield this.api.cache[endpoint]).map(t => Object.assign({}, t));
|
|
1007
|
-
return this.fixSelectOptions(selectModel, control, options);
|
|
1008
|
-
}));
|
|
1009
|
-
}
|
|
1010
|
-
getFormSelectConfig(property, schema) {
|
|
1011
|
-
return Object.assign(this.getFormControlConfig(property, schema), {
|
|
1012
|
-
options: this.getFormSelectOptions(property, schema),
|
|
1013
|
-
multiple: property.type == "array",
|
|
1014
|
-
groupBy: property.groupBy,
|
|
1015
|
-
inline: property.inline,
|
|
1016
|
-
allowEmpty: property.allowEmpty,
|
|
1017
|
-
});
|
|
1018
|
-
}
|
|
1019
|
-
getFormUploadConfig(property, schema) {
|
|
1020
|
-
const url = this.api.url(property.url || "assets");
|
|
1021
|
-
const { accept, autoUpload, maxSize, minSize, removeUrl, showFileList } = property;
|
|
1022
|
-
return Object.assign(this.getFormControlConfig(property, schema), {
|
|
1023
|
-
url,
|
|
1024
|
-
accept,
|
|
1025
|
-
autoUpload,
|
|
1026
|
-
maxSize,
|
|
1027
|
-
minSize,
|
|
1028
|
-
removeUrl,
|
|
1029
|
-
showFileList
|
|
1030
|
-
});
|
|
1031
|
-
}
|
|
1032
|
-
getFormCheckboxConfig(property, schema) {
|
|
1033
|
-
return Object.assign(this.getFormControlConfig(property, schema), {
|
|
1034
|
-
indeterminate: property.indeterminate || false
|
|
1035
|
-
});
|
|
1036
|
-
}
|
|
1037
|
-
cloneFormArrayGroup(index, formArray, formArrayModel) {
|
|
1038
|
-
this.insertFormArrayGroup(index, formArray, formArrayModel);
|
|
1039
|
-
this.patchGroup(formArray.at(index + 1).value, formArrayModel.groups[index].group, formArray.at(index));
|
|
1040
|
-
formArrayModel.filterGroups();
|
|
1041
|
-
}
|
|
1042
|
-
fixSelectOptions(model, control, options) {
|
|
1043
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1044
|
-
if (!options)
|
|
1045
|
-
return [];
|
|
1046
|
-
for (const option of options) {
|
|
1047
|
-
option.classes = [option.classes, model.getClasses(option, model, control, this.injector)].filter(isStringWithVal).join(" ");
|
|
1048
|
-
option.label = yield this.language.getTranslation(option.label);
|
|
1049
|
-
}
|
|
1050
|
-
return options;
|
|
1051
|
-
});
|
|
1052
|
-
}
|
|
1053
|
-
getValidators(property, schema) {
|
|
1054
|
-
const validators = {};
|
|
1055
|
-
if (ObjectUtils.isArray(schema.required) && schema.required.indexOf(property.id) >= 0) {
|
|
1056
|
-
validators.required = null;
|
|
1057
|
-
}
|
|
1058
|
-
this.addPropertyValidators(validators, property);
|
|
1059
|
-
this.addItemsValidators(validators, property.items);
|
|
1060
|
-
return validators;
|
|
1061
|
-
}
|
|
1062
|
-
addPropertyValidators(validators, property) {
|
|
1063
|
-
if (!property)
|
|
1064
|
-
return;
|
|
1065
|
-
if (!isNaN(property.minLength)) {
|
|
1066
|
-
validators.minLength = property.minLength;
|
|
1067
|
-
}
|
|
1068
|
-
if (!isNaN(property.maxLength)) {
|
|
1069
|
-
validators.maxLength = property.maxLength;
|
|
1070
|
-
}
|
|
1071
|
-
if (!isNaN(property.minimum)) {
|
|
1072
|
-
validators.min = property.minimum;
|
|
1073
|
-
}
|
|
1074
|
-
if (!isNaN(property.maximum)) {
|
|
1075
|
-
validators.max = property.maximum;
|
|
1076
|
-
}
|
|
1077
|
-
switch (property.format) {
|
|
1078
|
-
case "email":
|
|
1079
|
-
validators.email = null;
|
|
1080
|
-
break;
|
|
1081
|
-
}
|
|
1082
|
-
}
|
|
1083
|
-
addItemsValidators(validators, items) {
|
|
1084
|
-
if (!items)
|
|
1085
|
-
return;
|
|
1086
|
-
if (!isNaN(items.minLength)) {
|
|
1087
|
-
validators.itemsMinLength = items.minLength;
|
|
1088
|
-
}
|
|
1089
|
-
if (!isNaN(items.maxLength)) {
|
|
1090
|
-
validators.itemsMaxLength = items.maxLength;
|
|
1091
|
-
}
|
|
1092
|
-
if (!isNaN(items.minimum)) {
|
|
1093
|
-
validators.itemsMinValue = items.minimum;
|
|
1094
|
-
}
|
|
1095
|
-
if (!isNaN(items.maximum)) {
|
|
1096
|
-
validators.itemsMaxValue = items.maximum;
|
|
1097
|
-
}
|
|
1098
|
-
}
|
|
1099
|
-
}
|
|
1100
|
-
DynamicFormService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: DynamicFormService, deps: [{ token: i1.DynamicFormComponentService }, { token: i1.DynamicFormValidationService }, { token: OpenApiService }, { token: Injector }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1101
|
-
DynamicFormService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: DynamicFormService });
|
|
1102
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: DynamicFormService, decorators: [{
|
|
1103
|
-
type: Injectable
|
|
1104
|
-
}], ctorParameters: function () {
|
|
1105
|
-
return [{ type: i1.DynamicFormComponentService }, { type: i1.DynamicFormValidationService }, { type: i2.OpenApiService, decorators: [{
|
|
1106
|
-
type: Inject,
|
|
1107
|
-
args: [OpenApiService]
|
|
1108
|
-
}] }, { type: i0.Injector, decorators: [{
|
|
1109
|
-
type: Inject,
|
|
1110
|
-
args: [Injector]
|
|
1111
|
-
}] }];
|
|
1112
|
-
} });
|
|
1113
|
-
|
|
1114
|
-
class AsyncSubmitDirective {
|
|
1115
|
-
constructor(toaster, cdr, elem, renderer) {
|
|
1116
|
-
this.toaster = toaster;
|
|
1117
|
-
this.cdr = cdr;
|
|
1118
|
-
this.elem = elem;
|
|
1119
|
-
this.renderer = renderer;
|
|
1120
|
-
this.onSuccess = new EventEmitter();
|
|
1121
|
-
this.onError = new EventEmitter();
|
|
1122
|
-
if (elem.nativeElement.tagName !== "BUTTON")
|
|
1123
|
-
return;
|
|
1124
|
-
renderer.setAttribute(elem.nativeElement, "type", "button");
|
|
1125
|
-
}
|
|
1126
|
-
get isDisabled() {
|
|
1127
|
-
return this.disabled;
|
|
1128
|
-
}
|
|
1129
|
-
set isDisabled(value) {
|
|
1130
|
-
this.disabled = value;
|
|
1131
|
-
if (value) {
|
|
1132
|
-
this.renderer.setAttribute(this.elem.nativeElement, "disabled", "disabled");
|
|
1133
|
-
return;
|
|
1134
|
-
}
|
|
1135
|
-
this.renderer.removeAttribute(this.elem.nativeElement, "disabled");
|
|
1136
|
-
}
|
|
1137
|
-
get isLoading() {
|
|
1138
|
-
return this.loading;
|
|
1139
|
-
}
|
|
1140
|
-
ngOnInit() {
|
|
1141
|
-
if (!this.form)
|
|
1142
|
-
return;
|
|
1143
|
-
this.isDisabled = this.form.status !== "VALID";
|
|
1144
|
-
this.cdr.detectChanges();
|
|
1145
|
-
this.onStatusChange = this.form.onStatusChange.subscribe(() => {
|
|
1146
|
-
this.isDisabled = this.form.status !== "VALID";
|
|
1147
|
-
this.cdr.detectChanges();
|
|
1148
|
-
if (!this.callback || this.form.status == "PENDING")
|
|
1149
|
-
return;
|
|
1150
|
-
if (!this.disabled) {
|
|
1151
|
-
this.callback();
|
|
1152
|
-
}
|
|
1153
|
-
this.callback = null;
|
|
1154
|
-
});
|
|
1155
|
-
this.onSubmit = this.form.onSubmit.pipe(debounceTime(200)).subscribe(() => this.callMethod());
|
|
1156
|
-
}
|
|
1157
|
-
ngOnDestroy() {
|
|
1158
|
-
if (this.onStatusChange)
|
|
1159
|
-
this.onStatusChange.unsubscribe();
|
|
1160
|
-
if (this.onSubmit)
|
|
1161
|
-
this.onSubmit.unsubscribe();
|
|
1162
|
-
}
|
|
1163
|
-
click() {
|
|
1164
|
-
this.callback = () => this.callMethod();
|
|
1165
|
-
if (this.form.status === "INVALID") {
|
|
1166
|
-
console.log(getFormValidationErrors(this.form.group.controls));
|
|
1167
|
-
}
|
|
1168
|
-
if (this.form.status !== "VALID" && this.form.status !== "INVALID")
|
|
1169
|
-
return;
|
|
1170
|
-
this.callback();
|
|
1171
|
-
this.callback = null;
|
|
1172
|
-
}
|
|
1173
|
-
callMethod() {
|
|
1174
|
-
if (this.loading)
|
|
1175
|
-
return;
|
|
1176
|
-
this.loading = true;
|
|
1177
|
-
this.method(this.form, this.context).then(result => {
|
|
1178
|
-
this.loading = false;
|
|
1179
|
-
if (result) {
|
|
1180
|
-
this.onSuccess.emit(result);
|
|
1181
|
-
this.toaster.success(result.message, result.context);
|
|
1182
|
-
}
|
|
1183
|
-
}, reason => {
|
|
1184
|
-
if (!reason || !reason.message)
|
|
1185
|
-
throw new Error("Reason must implement IAsyncMessage interface");
|
|
1186
|
-
this.loading = false;
|
|
1187
|
-
this.onError.emit(reason);
|
|
1188
|
-
this.toaster.error(reason.message, reason.context);
|
|
1189
|
-
});
|
|
1190
|
-
}
|
|
1191
|
-
}
|
|
1192
|
-
AsyncSubmitDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: AsyncSubmitDirective, deps: [{ token: TOASTER_SERVICE }, { token: i0.ChangeDetectorRef }, { token: i0.ElementRef }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Directive });
|
|
1193
|
-
AsyncSubmitDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.8", type: AsyncSubmitDirective, selector: "[async-submit]", inputs: { method: ["async-submit", "method"], form: "form", context: "context" }, outputs: { onSuccess: "onSuccess", onError: "onError" }, host: { listeners: { "click": "click()" }, properties: { "class.disabled": "this.isDisabled", "class.loading": "this.isLoading" } }, exportAs: ["async-submit"], ngImport: i0 });
|
|
1194
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: AsyncSubmitDirective, decorators: [{
|
|
1195
|
-
type: Directive,
|
|
1196
|
-
args: [{
|
|
1197
|
-
selector: "[async-submit]",
|
|
1198
|
-
exportAs: "async-submit"
|
|
1199
|
-
}]
|
|
1200
|
-
}], ctorParameters: function () {
|
|
1201
|
-
return [{ type: undefined, decorators: [{
|
|
1202
|
-
type: Inject,
|
|
1203
|
-
args: [TOASTER_SERVICE]
|
|
1204
|
-
}] }, { type: i0.ChangeDetectorRef }, { type: i0.ElementRef }, { type: i0.Renderer2 }];
|
|
1205
|
-
}, propDecorators: { method: [{
|
|
1206
|
-
type: Input,
|
|
1207
|
-
args: ["async-submit"]
|
|
1208
|
-
}], form: [{
|
|
1209
|
-
type: Input
|
|
1210
|
-
}], context: [{
|
|
1211
|
-
type: Input
|
|
1212
|
-
}], onSuccess: [{
|
|
1213
|
-
type: Output
|
|
1214
|
-
}], onError: [{
|
|
1215
|
-
type: Output
|
|
1216
|
-
}], isDisabled: [{
|
|
1217
|
-
type: HostBinding,
|
|
1218
|
-
args: ["class.disabled"]
|
|
1219
|
-
}], isLoading: [{
|
|
1220
|
-
type: HostBinding,
|
|
1221
|
-
args: ["class.loading"]
|
|
1222
|
-
}], click: [{
|
|
1223
|
-
type: HostListener,
|
|
1224
|
-
args: ["click"]
|
|
1225
|
-
}] } });
|
|
1226
|
-
|
|
1227
|
-
class DynamicBaseFormComponent extends DynamicFormComponent {
|
|
1228
|
-
constructor(formService, events, changeDetectorRef, componentService) {
|
|
1229
|
-
super(changeDetectorRef, componentService);
|
|
1230
|
-
this.formService = formService;
|
|
1231
|
-
this.events = events;
|
|
1232
|
-
this.blur = new EventEmitter();
|
|
1233
|
-
this.change = new EventEmitter();
|
|
1234
|
-
this.focus = new EventEmitter();
|
|
1235
|
-
this.onValueChange = new EventEmitter();
|
|
1236
|
-
this.onStatusChange = new EventEmitter();
|
|
1237
|
-
this.onSubmit = new EventEmitter();
|
|
1238
|
-
this.onDetectChanges = new EventEmitter();
|
|
1239
|
-
this.templates = new QueryList();
|
|
1240
|
-
this.subscription = new Subscription();
|
|
1241
|
-
this.groupSubscription = new Subscription();
|
|
1242
|
-
this.labelPrefix = "label";
|
|
1243
|
-
this.getComponentType = () => null;
|
|
1244
|
-
}
|
|
1245
|
-
get status() {
|
|
1246
|
-
return !this.group ? null : this.group.status;
|
|
1247
|
-
}
|
|
1248
|
-
submit() {
|
|
1249
|
-
this.onSubmit.emit(this);
|
|
1250
|
-
}
|
|
1251
|
-
ngOnChanges(changes) {
|
|
1252
|
-
var _a;
|
|
1253
|
-
this.groupSubscription.unsubscribe();
|
|
1254
|
-
if (this.group) {
|
|
1255
|
-
this.groupSubscription = ObservableUtils.multiSubscription(this.group.statusChanges.subscribe(() => {
|
|
1256
|
-
this.onStatusChange.emit(this);
|
|
1257
|
-
}), this.group.valueChanges.pipe(debounceTime(500)).subscribe(() => {
|
|
1258
|
-
this.formService.notifyChanges(this.model, this.group);
|
|
1259
|
-
}), this.change.pipe(groupBy(ev => ev.model))
|
|
1260
|
-
.pipe(mergeMap(t => t.pipe(debounceTime(500))))
|
|
1261
|
-
.subscribe(ev => {
|
|
1262
|
-
this.onValueChange.emit(Object.assign(Object.assign({}, ev), { form: this }));
|
|
1263
|
-
}));
|
|
1264
|
-
}
|
|
1265
|
-
if (changes.groupModel) {
|
|
1266
|
-
this.model = (_a = this.groupModel) === null || _a === void 0 ? void 0 : _a.group;
|
|
1267
|
-
}
|
|
1268
|
-
if (changes.model) {
|
|
1269
|
-
this.groupModel = new DynamicFormGroupModel({ id: "root", group: this.model });
|
|
1270
|
-
}
|
|
1271
|
-
}
|
|
1272
|
-
ngAfterViewInit() {
|
|
1273
|
-
this.subscription = ObservableUtils.multiSubscription(ObservableUtils.subscribe({
|
|
1274
|
-
subjects: [this.contentTemplates.changes, this.viewTemplates.changes],
|
|
1275
|
-
cb: () => {
|
|
1276
|
-
const templates = this.contentTemplates.toArray().concat(this.viewTemplates.toArray());
|
|
1277
|
-
this.templates.reset(templates);
|
|
1278
|
-
}
|
|
1279
|
-
}), this.events.languageChanged.subscribe(() => {
|
|
1280
|
-
this.formService.notifyChanges(this.model, this.group);
|
|
1281
|
-
this.formService.detectChanges(this);
|
|
1282
|
-
}));
|
|
1283
|
-
}
|
|
1284
|
-
ngOnDestroy() {
|
|
1285
|
-
super.ngOnDestroy();
|
|
1286
|
-
this.subscription.unsubscribe();
|
|
1287
|
-
this.groupSubscription.unsubscribe();
|
|
1288
|
-
}
|
|
1289
|
-
detectChanges() {
|
|
1290
|
-
super.detectChanges();
|
|
1291
|
-
this.onDetectChanges.emit(this);
|
|
1292
|
-
}
|
|
1293
|
-
insertFormArrayGroup(index, formArray, formArrayModel) {
|
|
1294
|
-
this.formService.insertFormArrayGroup(index, formArray, formArrayModel);
|
|
1295
|
-
this.detectChanges();
|
|
1296
|
-
}
|
|
1297
|
-
cloneFormArrayGroup(index, formArray, formArrayModel) {
|
|
1298
|
-
this.formService.cloneFormArrayGroup(index, formArray, formArrayModel);
|
|
1299
|
-
this.detectChanges();
|
|
1300
|
-
}
|
|
1301
|
-
removeFormArrayGroup(index, formArray, formArrayModel) {
|
|
1302
|
-
this.formService.removeFormArrayGroup(index, formArray, formArrayModel);
|
|
1303
|
-
this.detectChanges();
|
|
1304
|
-
}
|
|
1305
|
-
moveFormArrayGroup(index, step, formArray, formArrayModel) {
|
|
1306
|
-
this.formService.moveFormArrayGroup(index, step, formArray, formArrayModel);
|
|
1307
|
-
this.detectChanges();
|
|
1308
|
-
}
|
|
1309
|
-
clearFormArray(formArray, formArrayModel) {
|
|
1310
|
-
this.formService.clearFormArray(formArray, formArrayModel);
|
|
1311
|
-
this.detectChanges();
|
|
1312
|
-
}
|
|
1313
|
-
getClass(model) {
|
|
1314
|
-
const parts = collectPathAble(model, p => p.id);
|
|
1315
|
-
if (parts.length == 0)
|
|
1316
|
-
return "";
|
|
1317
|
-
if (model instanceof DynamicFormGroupModel) {
|
|
1318
|
-
return `form-group-${parts.join("-")}`;
|
|
1319
|
-
}
|
|
1320
|
-
return `form-control-${parts.join("-")}`;
|
|
1321
|
-
}
|
|
1322
|
-
validate(showErrors = true) {
|
|
1323
|
-
if (!this.group)
|
|
1324
|
-
return Promise.resolve();
|
|
1325
|
-
return new Promise((resolve, reject) => {
|
|
1326
|
-
this.group.statusChanges.pipe(first(status => status == "VALID" || status == "INVALID")).subscribe(status => {
|
|
1327
|
-
if (showErrors) {
|
|
1328
|
-
this.formService.showErrors(this);
|
|
1329
|
-
}
|
|
1330
|
-
if (status == "VALID") {
|
|
1331
|
-
resolve(null);
|
|
1332
|
-
return;
|
|
1333
|
-
}
|
|
1334
|
-
reject(null);
|
|
1335
|
-
});
|
|
1336
|
-
this.group.updateValueAndValidity();
|
|
1337
|
-
});
|
|
1338
|
-
}
|
|
1339
|
-
serialize(validate) {
|
|
1340
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1341
|
-
if (!this.group)
|
|
1342
|
-
return null;
|
|
1343
|
-
if (validate) {
|
|
1344
|
-
yield this.validate();
|
|
1345
|
-
}
|
|
1346
|
-
return yield this.formService.serialize(this.model, this.group);
|
|
1347
|
-
});
|
|
1348
|
-
}
|
|
1349
|
-
}
|
|
1350
|
-
DynamicBaseFormComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: DynamicBaseFormComponent, deps: [{ token: DynamicFormService }, { token: EventsService }, { token: i0.ChangeDetectorRef }, { token: i1.DynamicFormComponentService }], target: i0.ɵɵFactoryTarget.Component });
|
|
1351
|
-
DynamicBaseFormComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.8", type: DynamicBaseFormComponent, selector: "dynamic-base-form", inputs: { group: "group", groupModel: "groupModel", model: "model", layout: "layout", labelPrefix: "labelPrefix", getComponentType: "getComponentType" }, outputs: { blur: "blur", change: "change", focus: "focus", onValueChange: "onValueChange", onStatusChange: "onStatusChange", onSubmit: "onSubmit", onDetectChanges: "onDetectChanges" }, queries: [{ propertyName: "contentTemplates", predicate: DynamicTemplateDirective }], viewQueries: [{ propertyName: "viewTemplates", predicate: DynamicTemplateDirective, descendants: true }], usesInheritance: true, usesOnChanges: true, ngImport: i0, template: "", isInline: true, changeDetection: i0.ChangeDetectionStrategy.Default });
|
|
1352
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: DynamicBaseFormComponent, decorators: [{
|
|
1353
|
-
type: Component,
|
|
1354
|
-
args: [{
|
|
1355
|
-
selector: "dynamic-base-form",
|
|
1356
|
-
template: "",
|
|
1357
|
-
changeDetection: ChangeDetectionStrategy.Default
|
|
1358
|
-
}]
|
|
1359
|
-
}], ctorParameters: function () {
|
|
1360
|
-
return [{ type: DynamicFormService, decorators: [{
|
|
1361
|
-
type: Inject,
|
|
1362
|
-
args: [DynamicFormService]
|
|
1363
|
-
}] }, { type: i2.EventsService, decorators: [{
|
|
1364
|
-
type: Inject,
|
|
1365
|
-
args: [EventsService]
|
|
1366
|
-
}] }, { type: i0.ChangeDetectorRef }, { type: i1.DynamicFormComponentService }];
|
|
1367
|
-
}, propDecorators: { group: [{
|
|
1368
|
-
type: Input
|
|
1369
|
-
}], groupModel: [{
|
|
1370
|
-
type: Input
|
|
1371
|
-
}], model: [{
|
|
1372
|
-
type: Input
|
|
1373
|
-
}], layout: [{
|
|
1374
|
-
type: Input
|
|
1375
|
-
}], labelPrefix: [{
|
|
1376
|
-
type: Input
|
|
1377
|
-
}], getComponentType: [{
|
|
1378
|
-
type: Input
|
|
1379
|
-
}], blur: [{
|
|
1380
|
-
type: Output
|
|
1381
|
-
}], change: [{
|
|
1382
|
-
type: Output
|
|
1383
|
-
}], focus: [{
|
|
1384
|
-
type: Output
|
|
1385
|
-
}], contentTemplates: [{
|
|
1386
|
-
type: ContentChildren,
|
|
1387
|
-
args: [DynamicTemplateDirective]
|
|
1388
|
-
}], viewTemplates: [{
|
|
1389
|
-
type: ViewChildren,
|
|
1390
|
-
args: [DynamicTemplateDirective]
|
|
1391
|
-
}], onValueChange: [{
|
|
1392
|
-
type: Output
|
|
1393
|
-
}], onStatusChange: [{
|
|
1394
|
-
type: Output
|
|
1395
|
-
}], onSubmit: [{
|
|
1396
|
-
type: Output
|
|
1397
|
-
}], onDetectChanges: [{
|
|
1398
|
-
type: Output
|
|
1399
|
-
}] } });
|
|
1400
|
-
|
|
1401
|
-
class DynamicBaseFormControlContainerComponent extends DynamicFormControlContainerComponent {
|
|
1402
|
-
constructor(form, cdr, injector, cfr, layoutService, validationService, componentService, relationService) {
|
|
1403
|
-
super(cdr, cfr, layoutService, validationService, componentService, relationService);
|
|
1404
|
-
this.form = form;
|
|
1405
|
-
this.cdr = cdr;
|
|
1406
|
-
this.injector = injector;
|
|
1407
|
-
this.context = null;
|
|
1408
|
-
this.blur = new EventEmitter();
|
|
1409
|
-
this.change = new EventEmitter();
|
|
1410
|
-
this.focus = new EventEmitter();
|
|
1411
|
-
}
|
|
1412
|
-
get componentType() {
|
|
1413
|
-
var _a, _b, _c;
|
|
1414
|
-
return (_c = (_b = (_a = this.form).getComponentType) === null || _b === void 0 ? void 0 : _b.call(_a, this.model, this.injector)) !== null && _c !== void 0 ? _c : this.componentService.getCustomComponentType(this.model);
|
|
1415
|
-
}
|
|
1416
|
-
get startTemplate() {
|
|
1417
|
-
return (this.model.type == DYNAMIC_FORM_CONTROL_TYPE_ARRAY)
|
|
1418
|
-
? this.layoutService.getAlignedTemplate(this.model, this.templates, "ARRAY_START")
|
|
1419
|
-
: this.layoutService.getStartTemplate(this.model, this.templates);
|
|
1420
|
-
}
|
|
1421
|
-
get endTemplate() {
|
|
1422
|
-
return (this.model.type == DYNAMIC_FORM_CONTROL_TYPE_ARRAY)
|
|
1423
|
-
? this.layoutService.getAlignedTemplate(this.model, this.templates, "ARRAY_END")
|
|
1424
|
-
: this.layoutService.getEndTemplate(this.model, this.templates);
|
|
1425
|
-
}
|
|
1426
|
-
get formService() {
|
|
1427
|
-
return this.form.formService;
|
|
1428
|
-
}
|
|
1429
|
-
ngOnInit() {
|
|
1430
|
-
super.ngOnInit();
|
|
1431
|
-
this.onDetectChanges = this.form.onDetectChanges.subscribe(() => {
|
|
1432
|
-
this.changeDetectorRef.detectChanges();
|
|
1433
|
-
});
|
|
1434
|
-
}
|
|
1435
|
-
ngOnDestroy() {
|
|
1436
|
-
super.ngOnDestroy();
|
|
1437
|
-
this.onDetectChanges.unsubscribe();
|
|
1438
|
-
}
|
|
1439
|
-
getLabel() {
|
|
1440
|
-
var _a;
|
|
1441
|
-
const label = collectPathAble(this.model, p => p.label);
|
|
1442
|
-
if (label.length == 0)
|
|
1443
|
-
return "";
|
|
1444
|
-
if ((_a = this.form) === null || _a === void 0 ? void 0 : _a.labelPrefix) {
|
|
1445
|
-
label.unshift(this.form.labelPrefix);
|
|
1446
|
-
}
|
|
1447
|
-
return label.join(".");
|
|
1448
|
-
}
|
|
1449
|
-
getLabelIcon() {
|
|
1450
|
-
if (this.context instanceof DynamicFormArrayGroupModel) {
|
|
1451
|
-
const arrayModel = this.context.context;
|
|
1452
|
-
if (arrayModel && arrayModel.sortBy == this.model.id) {
|
|
1453
|
-
return arrayModel.sortOrder;
|
|
1454
|
-
}
|
|
1455
|
-
}
|
|
1456
|
-
return null;
|
|
1457
|
-
}
|
|
1458
|
-
clickLabel() {
|
|
1459
|
-
if (this.context instanceof DynamicFormArrayGroupModel) {
|
|
1460
|
-
const arrayModel = this.context.context;
|
|
1461
|
-
if (arrayModel) {
|
|
1462
|
-
arrayModel.sortBy = this.model.id;
|
|
1463
|
-
}
|
|
1464
|
-
}
|
|
1465
|
-
}
|
|
1466
|
-
createFormControlComponent() {
|
|
1467
|
-
var _a;
|
|
1468
|
-
super.createFormControlComponent();
|
|
1469
|
-
const component = (_a = this.componentRef) === null || _a === void 0 ? void 0 : _a.instance;
|
|
1470
|
-
if (!component || !ObjectUtils.isFunction(component.initialize))
|
|
1471
|
-
return;
|
|
1472
|
-
component.initialize(this.changeDetectorRef);
|
|
1473
|
-
}
|
|
1474
|
-
}
|
|
1475
|
-
DynamicBaseFormControlContainerComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: DynamicBaseFormControlContainerComponent, deps: [{ token: DynamicBaseFormComponent }, { token: i0.ChangeDetectorRef }, { token: i0.Injector }, { token: i0.ComponentFactoryResolver }, { token: i1.DynamicFormLayoutService }, { token: i1.DynamicFormValidationService }, { token: i1.DynamicFormComponentService }, { token: i1.DynamicFormRelationService }], target: i0.ɵɵFactoryTarget.Component });
|
|
1476
|
-
DynamicBaseFormControlContainerComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.8", type: DynamicBaseFormControlContainerComponent, selector: "dynamic-base-form-control", inputs: { context: "context", group: "group", hostClass: "hostClass", inputTemplateList: ["templates", "inputTemplateList"], layout: "layout", model: "model" }, outputs: { blur: "blur", change: "change", focus: "focus" }, host: { properties: { "class": "this.klass" } }, providers: [
|
|
1477
|
-
{ provide: DynamicFormControlContainerComponent, useExisting: DynamicBaseFormControlContainerComponent }
|
|
1478
|
-
], queries: [{ propertyName: "contentTemplateList", predicate: DynamicTemplateDirective }], viewQueries: [{ propertyName: "componentViewContainerRef", first: true, predicate: ["componentViewContainer"], descendants: true, read: ViewContainerRef, static: true }], usesInheritance: true, ngImport: i0, template: "", isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1479
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: DynamicBaseFormControlContainerComponent, decorators: [{
|
|
1480
|
-
type: Component,
|
|
1481
|
-
args: [{
|
|
1482
|
-
selector: "dynamic-base-form-control",
|
|
1483
|
-
template: "",
|
|
1484
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
1485
|
-
providers: [
|
|
1486
|
-
{ provide: DynamicFormControlContainerComponent, useExisting: DynamicBaseFormControlContainerComponent }
|
|
1487
|
-
]
|
|
1488
|
-
}]
|
|
1489
|
-
}], ctorParameters: function () { return [{ type: DynamicBaseFormComponent }, { type: i0.ChangeDetectorRef }, { type: i0.Injector }, { type: i0.ComponentFactoryResolver }, { type: i1.DynamicFormLayoutService }, { type: i1.DynamicFormValidationService }, { type: i1.DynamicFormComponentService }, { type: i1.DynamicFormRelationService }]; }, propDecorators: { contentTemplateList: [{
|
|
1490
|
-
type: ContentChildren,
|
|
1491
|
-
args: [DynamicTemplateDirective]
|
|
1492
|
-
}], klass: [{
|
|
1493
|
-
type: HostBinding,
|
|
1494
|
-
args: ["class"]
|
|
1495
|
-
}], context: [{
|
|
1496
|
-
type: Input
|
|
1497
|
-
}], group: [{
|
|
1498
|
-
type: Input
|
|
1499
|
-
}], hostClass: [{
|
|
1500
|
-
type: Input
|
|
1501
|
-
}], inputTemplateList: [{
|
|
1502
|
-
type: Input,
|
|
1503
|
-
args: ["templates"]
|
|
1504
|
-
}], layout: [{
|
|
1505
|
-
type: Input
|
|
1506
|
-
}], model: [{
|
|
1507
|
-
type: Input
|
|
1508
|
-
}], blur: [{
|
|
1509
|
-
type: Output
|
|
1510
|
-
}], change: [{
|
|
1511
|
-
type: Output
|
|
1512
|
-
}], focus: [{
|
|
1513
|
-
type: Output
|
|
1514
|
-
}], componentViewContainerRef: [{
|
|
1515
|
-
type: ViewChild,
|
|
1516
|
-
args: ["componentViewContainer", {
|
|
1517
|
-
read: ViewContainerRef,
|
|
1518
|
-
static: true
|
|
1519
|
-
}]
|
|
1520
|
-
}] } });
|
|
1521
|
-
|
|
1522
|
-
class DynamicBaseFormArrayComponent extends DynamicFormArrayComponent {
|
|
1523
|
-
constructor(layoutService, validationService, form, injector, cdr) {
|
|
1524
|
-
super(layoutService, validationService);
|
|
1525
|
-
this.form = form;
|
|
1526
|
-
this.injector = injector;
|
|
1527
|
-
this.cdr = cdr;
|
|
1528
|
-
this.blur = new EventEmitter();
|
|
1529
|
-
this.change = new EventEmitter();
|
|
1530
|
-
this.customEvent = new EventEmitter();
|
|
1531
|
-
this.focus = new EventEmitter();
|
|
1532
|
-
}
|
|
1533
|
-
get useTabs() {
|
|
1534
|
-
var _a;
|
|
1535
|
-
return (_a = this.model) === null || _a === void 0 ? void 0 : _a.useTabs;
|
|
1536
|
-
}
|
|
1537
|
-
initialize(cdr) {
|
|
1538
|
-
this.subscription = this.model.filteredGroups.subscribe(filteredGroups => {
|
|
1539
|
-
this.updateGroups(filteredGroups);
|
|
1540
|
-
});
|
|
1541
|
-
this.model.initialize(this.array);
|
|
1542
|
-
}
|
|
1543
|
-
ngOnDestroy() {
|
|
1544
|
-
if (this.subscription)
|
|
1545
|
-
this.subscription.unsubscribe();
|
|
1546
|
-
}
|
|
1547
|
-
saveTab(index) {
|
|
1548
|
-
this.model.saveTab(index, this.model.getFiltered(index), this.model, this.injector);
|
|
1549
|
-
}
|
|
1550
|
-
restoreTab() {
|
|
1551
|
-
return this.model.restoreTab(this.model, this.injector);
|
|
1552
|
-
}
|
|
1553
|
-
getTabLabel(index, model) {
|
|
1554
|
-
return this.model.getTabLabel(index, model, this.model, this.array, this.injector);
|
|
1555
|
-
}
|
|
1556
|
-
getClass(context, place, model) {
|
|
1557
|
-
var _a;
|
|
1558
|
-
return [
|
|
1559
|
-
context == "element" ? this.getModelClass(model) : null,
|
|
1560
|
-
context == "element" ? this.getAdditionalClass(model) : null,
|
|
1561
|
-
super.getClass(context, place, model),
|
|
1562
|
-
model instanceof DynamicFormValueControlModel ? (_a = model.additional) === null || _a === void 0 ? void 0 : _a.classes : null
|
|
1563
|
-
].filter(cls => !!cls).join(" ");
|
|
1564
|
-
}
|
|
1565
|
-
getModelClass(model) {
|
|
1566
|
-
const parts = collectPathAble(model, p => p.id);
|
|
1567
|
-
if (parts.length == 0)
|
|
1568
|
-
return "";
|
|
1569
|
-
if (model instanceof DynamicFormGroupModel$1) {
|
|
1570
|
-
return `form-group-${parts.join("-")}`;
|
|
1571
|
-
}
|
|
1572
|
-
return `form-control-${parts.join("-")}`;
|
|
1573
|
-
}
|
|
1574
|
-
getAdditionalClass(model) {
|
|
1575
|
-
var _a, _b;
|
|
1576
|
-
if (model instanceof DynamicFormArrayModel) {
|
|
1577
|
-
return (_a = model.additional) === null || _a === void 0 ? void 0 : _a.classes;
|
|
1578
|
-
}
|
|
1579
|
-
if (model instanceof DynamicFormValueControlModel) {
|
|
1580
|
-
return (_b = model.additional) === null || _b === void 0 ? void 0 : _b.classes;
|
|
1581
|
-
}
|
|
1582
|
-
return null;
|
|
1583
|
-
}
|
|
1584
|
-
updateGroups(filteredGroups) {
|
|
1585
|
-
this.cdr.detectChanges();
|
|
1586
|
-
this.components.forEach(t => t.cdr.detectChanges());
|
|
1587
|
-
}
|
|
1588
|
-
}
|
|
1589
|
-
DynamicBaseFormArrayComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: DynamicBaseFormArrayComponent, deps: [{ token: i1.DynamicFormLayoutService }, { token: i1.DynamicFormValidationService }, { token: DynamicBaseFormComponent }, { token: i0.Injector }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
1590
|
-
DynamicBaseFormArrayComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.8", type: DynamicBaseFormArrayComponent, selector: "dynamic-base-form-array", inputs: { formLayout: "formLayout", group: "group", layout: "layout", model: "model", templates: "templates" }, outputs: { blur: "blur", change: "change", customEvent: "customEvent", focus: "focus" }, viewQueries: [{ propertyName: "components", predicate: i0.forwardRef(function () { return DynamicBaseFormControlContainerComponent; }), descendants: true }], usesInheritance: true, ngImport: i0, template: "", isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1591
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: DynamicBaseFormArrayComponent, decorators: [{
|
|
1592
|
-
type: Component,
|
|
1593
|
-
args: [{
|
|
1594
|
-
selector: "dynamic-base-form-array",
|
|
1595
|
-
template: "",
|
|
1596
|
-
changeDetection: ChangeDetectionStrategy.OnPush
|
|
1597
|
-
}]
|
|
1598
|
-
}], ctorParameters: function () { return [{ type: i1.DynamicFormLayoutService }, { type: i1.DynamicFormValidationService }, { type: DynamicBaseFormComponent }, { type: i0.Injector }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { formLayout: [{
|
|
1599
|
-
type: Input
|
|
1600
|
-
}], group: [{
|
|
1601
|
-
type: Input
|
|
1602
|
-
}], layout: [{
|
|
1603
|
-
type: Input
|
|
1604
|
-
}], model: [{
|
|
1605
|
-
type: Input
|
|
1606
|
-
}], templates: [{
|
|
1607
|
-
type: Input
|
|
1608
|
-
}], blur: [{
|
|
1609
|
-
type: Output
|
|
1610
|
-
}], change: [{
|
|
1611
|
-
type: Output
|
|
1612
|
-
}], customEvent: [{
|
|
1613
|
-
type: Output
|
|
1614
|
-
}], focus: [{
|
|
1615
|
-
type: Output
|
|
1616
|
-
}], components: [{
|
|
1617
|
-
type: ViewChildren,
|
|
1618
|
-
args: [forwardRef(() => DynamicBaseFormControlContainerComponent)]
|
|
1619
|
-
}] } });
|
|
1620
|
-
|
|
1621
|
-
class DynamicBaseFormControlComponent extends DynamicFormControlComponent {
|
|
1622
|
-
constructor(layoutService, validationService, form, injector, cdr) {
|
|
1623
|
-
super(layoutService, validationService);
|
|
1624
|
-
this.form = form;
|
|
1625
|
-
this.injector = injector;
|
|
1626
|
-
this.cdr = cdr;
|
|
1627
|
-
this.blur = new EventEmitter();
|
|
1628
|
-
this.change = new EventEmitter();
|
|
1629
|
-
this.focus = new EventEmitter();
|
|
1630
|
-
}
|
|
1631
|
-
ngAfterViewInit() {
|
|
1632
|
-
this.subscription = this.control.valueChanges.pipe(debounceTime(500)).subscribe(value => {
|
|
1633
|
-
this.onValueChanged(value);
|
|
1634
|
-
});
|
|
1635
|
-
}
|
|
1636
|
-
ngOnDestroy() {
|
|
1637
|
-
if (!this.subscription)
|
|
1638
|
-
return;
|
|
1639
|
-
this.subscription.unsubscribe();
|
|
1640
|
-
}
|
|
1641
|
-
submit() {
|
|
1642
|
-
this.form.submit();
|
|
1643
|
-
}
|
|
1644
|
-
onValueChanged(value) {
|
|
1645
|
-
}
|
|
1646
|
-
}
|
|
1647
|
-
DynamicBaseFormControlComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: DynamicBaseFormControlComponent, deps: [{ token: i1.DynamicFormLayoutService }, { token: i1.DynamicFormValidationService }, { token: DynamicBaseFormComponent }, { token: i0.Injector }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
1648
|
-
DynamicBaseFormControlComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.8", type: DynamicBaseFormControlComponent, selector: "dynamic-base-form-control", inputs: { formLayout: "formLayout", group: "group", layout: "layout", model: "model" }, outputs: { blur: "blur", change: "change", focus: "focus" }, usesInheritance: true, ngImport: i0, template: "", isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1649
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: DynamicBaseFormControlComponent, decorators: [{
|
|
1650
|
-
type: Component,
|
|
1651
|
-
args: [{
|
|
1652
|
-
selector: "dynamic-base-form-control",
|
|
1653
|
-
template: "",
|
|
1654
|
-
changeDetection: ChangeDetectionStrategy.OnPush
|
|
1655
|
-
}]
|
|
1656
|
-
}], ctorParameters: function () { return [{ type: i1.DynamicFormLayoutService }, { type: i1.DynamicFormValidationService }, { type: DynamicBaseFormComponent }, { type: i0.Injector }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { formLayout: [{
|
|
1657
|
-
type: Input
|
|
1658
|
-
}], group: [{
|
|
1659
|
-
type: Input
|
|
1660
|
-
}], layout: [{
|
|
1661
|
-
type: Input
|
|
1662
|
-
}], model: [{
|
|
1663
|
-
type: Input
|
|
1664
|
-
}], blur: [{
|
|
1665
|
-
type: Output
|
|
1666
|
-
}], change: [{
|
|
1667
|
-
type: Output
|
|
1668
|
-
}], focus: [{
|
|
1669
|
-
type: Output
|
|
1670
|
-
}] } });
|
|
1671
|
-
|
|
1672
|
-
class DynamicBaseFormGroupComponent extends DynamicFormGroupComponent {
|
|
1673
|
-
constructor(layoutService, validationService) {
|
|
1674
|
-
super(layoutService, validationService);
|
|
1675
|
-
this.layoutService = layoutService;
|
|
1676
|
-
this.validationService = validationService;
|
|
1677
|
-
this.blur = new EventEmitter();
|
|
1678
|
-
this.change = new EventEmitter();
|
|
1679
|
-
this.customEvent = new EventEmitter();
|
|
1680
|
-
this.focus = new EventEmitter();
|
|
1681
|
-
}
|
|
1682
|
-
getClass(context, place, model) {
|
|
1683
|
-
return [
|
|
1684
|
-
context == "element" ? this.getModelClass(model) : null,
|
|
1685
|
-
context == "element" ? this.getAdditionalClass(model) : null,
|
|
1686
|
-
super.getClass(context, place, model)
|
|
1687
|
-
].filter(cls => !!cls).join(" ");
|
|
1688
|
-
}
|
|
1689
|
-
getModelClass(model) {
|
|
1690
|
-
const parts = collectPathAble(model, p => p.id);
|
|
1691
|
-
if (parts.length == 0)
|
|
1692
|
-
return "";
|
|
1693
|
-
if (model instanceof DynamicFormGroupModel) {
|
|
1694
|
-
return `form-group-${parts.join("-")}`;
|
|
1695
|
-
}
|
|
1696
|
-
return `form-control-${parts.join("-")}`;
|
|
1697
|
-
}
|
|
1698
|
-
getAdditionalClass(model) {
|
|
1699
|
-
var _a, _b;
|
|
1700
|
-
if (model instanceof DynamicFormArrayModel) {
|
|
1701
|
-
return (_a = model.additional) === null || _a === void 0 ? void 0 : _a.classes;
|
|
1702
|
-
}
|
|
1703
|
-
if (model instanceof DynamicFormValueControlModel) {
|
|
1704
|
-
return (_b = model.additional) === null || _b === void 0 ? void 0 : _b.classes;
|
|
1705
|
-
}
|
|
1706
|
-
return null;
|
|
1707
|
-
}
|
|
1708
|
-
}
|
|
1709
|
-
DynamicBaseFormGroupComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: DynamicBaseFormGroupComponent, deps: [{ token: i1.DynamicFormLayoutService }, { token: i1.DynamicFormValidationService }], target: i0.ɵɵFactoryTarget.Component });
|
|
1710
|
-
DynamicBaseFormGroupComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.8", type: DynamicBaseFormGroupComponent, selector: "dynamic-base-form-group", inputs: { formLayout: "formLayout", group: "group", layout: "layout", model: "model", templates: "templates" }, outputs: { blur: "blur", change: "change", customEvent: "customEvent", focus: "focus" }, viewQueries: [{ propertyName: "components", predicate: i0.forwardRef(function () { return DynamicFormControlContainerComponent; }), descendants: true }], usesInheritance: true, ngImport: i0, template: "", isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1711
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: DynamicBaseFormGroupComponent, decorators: [{
|
|
1712
|
-
type: Component,
|
|
1713
|
-
args: [{
|
|
1714
|
-
selector: "dynamic-base-form-group",
|
|
1715
|
-
template: "",
|
|
1716
|
-
changeDetection: ChangeDetectionStrategy.OnPush
|
|
1717
|
-
}]
|
|
1718
|
-
}], ctorParameters: function () { return [{ type: i1.DynamicFormLayoutService }, { type: i1.DynamicFormValidationService }]; }, propDecorators: { formLayout: [{
|
|
1719
|
-
type: Input
|
|
1720
|
-
}], group: [{
|
|
1721
|
-
type: Input
|
|
1722
|
-
}], layout: [{
|
|
1723
|
-
type: Input
|
|
1724
|
-
}], model: [{
|
|
1725
|
-
type: Input
|
|
1726
|
-
}], templates: [{
|
|
1727
|
-
type: Input
|
|
1728
|
-
}], blur: [{
|
|
1729
|
-
type: Output
|
|
1730
|
-
}], change: [{
|
|
1731
|
-
type: Output
|
|
1732
|
-
}], customEvent: [{
|
|
1733
|
-
type: Output
|
|
1734
|
-
}], focus: [{
|
|
1735
|
-
type: Output
|
|
1736
|
-
}], components: [{
|
|
1737
|
-
type: ViewChildren,
|
|
1738
|
-
args: [forwardRef(() => DynamicFormControlContainerComponent)]
|
|
1739
|
-
}] } });
|
|
1740
|
-
|
|
1741
|
-
class DynamicBaseSelectComponent extends DynamicBaseFormControlComponent {
|
|
1742
|
-
ngOnInit() {
|
|
1743
|
-
this.groups$ = new BehaviorSubject([]);
|
|
1744
|
-
this.subscription = this.model.options$.subscribe(options => {
|
|
1745
|
-
const groupBy = this.model.inline || !this.model.multiple ? this.model.groupBy : null;
|
|
1746
|
-
const grouped = options.reduce((res, option) => {
|
|
1747
|
-
const key = replaceSpecialChars(groupBy ? option.props[this.model.groupBy] || "default" : "default", "-");
|
|
1748
|
-
res[key] = res[key] || [];
|
|
1749
|
-
res[key].push(option);
|
|
1750
|
-
return res;
|
|
1751
|
-
}, {});
|
|
1752
|
-
const groups = Object.keys(grouped).map(group => {
|
|
1753
|
-
return {
|
|
1754
|
-
group,
|
|
1755
|
-
options: grouped[group]
|
|
1756
|
-
};
|
|
1757
|
-
});
|
|
1758
|
-
this.hasOptions = groups.length > 0;
|
|
1759
|
-
this.groups$.next(groups);
|
|
1760
|
-
this.cdr.detectChanges();
|
|
1761
|
-
});
|
|
1762
|
-
}
|
|
1763
|
-
ngOnDestroy() {
|
|
1764
|
-
if (this.subscription)
|
|
1765
|
-
this.subscription.unsubscribe();
|
|
1766
|
-
}
|
|
1767
|
-
isSelected(option) {
|
|
1768
|
-
var _a;
|
|
1769
|
-
if (this.model.multiple) {
|
|
1770
|
-
return ((_a = this.control.value) === null || _a === void 0 ? void 0 : _a.indexOf(option.value)) >= 0;
|
|
1771
|
-
}
|
|
1772
|
-
return this.control.value == option.value;
|
|
1773
|
-
}
|
|
1774
|
-
selectToggle(option, state) {
|
|
1775
|
-
if (this.model.multiple) {
|
|
1776
|
-
const value = Array.from(this.control.value || []);
|
|
1777
|
-
const index = value.indexOf(option.value);
|
|
1778
|
-
if (index >= 0) {
|
|
1779
|
-
value.splice(index, 1);
|
|
1780
|
-
}
|
|
1781
|
-
if (state) {
|
|
1782
|
-
value.push(option.value);
|
|
1783
|
-
}
|
|
1784
|
-
this.control.setValue(value);
|
|
1785
|
-
this.onChange(value);
|
|
1786
|
-
return;
|
|
1787
|
-
}
|
|
1788
|
-
this.control.setValue(option.value);
|
|
1789
|
-
this.onChange(option.value);
|
|
1790
|
-
}
|
|
1791
|
-
}
|
|
1792
|
-
DynamicBaseSelectComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: DynamicBaseSelectComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
1793
|
-
DynamicBaseSelectComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.8", type: DynamicBaseSelectComponent, selector: "dynamic-base-select", usesInheritance: true, ngImport: i0, template: "", isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1794
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: DynamicBaseSelectComponent, decorators: [{
|
|
1795
|
-
type: Component,
|
|
1796
|
-
args: [{
|
|
1797
|
-
selector: "dynamic-base-select",
|
|
1798
|
-
template: "",
|
|
1799
|
-
changeDetection: ChangeDetectionStrategy.OnPush
|
|
1800
|
-
}]
|
|
1801
|
-
}] });
|
|
1802
|
-
|
|
1803
|
-
// --- Components ---
|
|
1804
|
-
const components = [
|
|
1805
|
-
DynamicBaseFormComponent,
|
|
1806
|
-
DynamicBaseFormArrayComponent,
|
|
1807
|
-
DynamicBaseFormControlComponent,
|
|
1808
|
-
DynamicBaseFormControlContainerComponent,
|
|
1809
|
-
DynamicBaseFormGroupComponent,
|
|
1810
|
-
DynamicBaseSelectComponent
|
|
1811
|
-
];
|
|
1812
|
-
// --- Directives ---
|
|
1813
|
-
const directives = [
|
|
1814
|
-
AsyncSubmitDirective,
|
|
1815
|
-
];
|
|
1816
|
-
// --- Pipes ---
|
|
1817
|
-
const pipes = [];
|
|
1818
|
-
function defaultFormControlProvider() {
|
|
1819
|
-
return () => null;
|
|
1820
|
-
}
|
|
1821
|
-
|
|
1822
|
-
class NgxDynamicFormModule {
|
|
1823
|
-
static forRoot(config) {
|
|
1824
|
-
return {
|
|
1825
|
-
ngModule: NgxDynamicFormModule,
|
|
1826
|
-
providers: [
|
|
1827
|
-
DynamicFormService,
|
|
1828
|
-
{
|
|
1829
|
-
provide: DynamicFormService$1,
|
|
1830
|
-
useExisting: DynamicFormService
|
|
1831
|
-
},
|
|
1832
|
-
{
|
|
1833
|
-
provide: DYNAMIC_FORM_CONTROL_MAP_FN,
|
|
1834
|
-
useFactory: ((config === null || config === void 0 ? void 0 : config.controlProvider) || defaultFormControlProvider),
|
|
1835
|
-
deps: [Injector]
|
|
1836
|
-
}
|
|
1837
|
-
]
|
|
1838
|
-
};
|
|
1839
|
-
}
|
|
1840
|
-
}
|
|
1841
|
-
NgxDynamicFormModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: NgxDynamicFormModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
1842
|
-
NgxDynamicFormModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: NgxDynamicFormModule, declarations: [DynamicBaseFormComponent, DynamicBaseFormArrayComponent, DynamicBaseFormControlComponent, DynamicBaseFormControlContainerComponent, DynamicBaseFormGroupComponent, DynamicBaseSelectComponent, AsyncSubmitDirective], imports: [CommonModule,
|
|
1843
|
-
FormsModule,
|
|
1844
|
-
ReactiveFormsModule,
|
|
1845
|
-
NgxUtilsModule], exports: [DynamicBaseFormComponent, DynamicBaseFormArrayComponent, DynamicBaseFormControlComponent, DynamicBaseFormControlContainerComponent, DynamicBaseFormGroupComponent, DynamicBaseSelectComponent, AsyncSubmitDirective, FormsModule,
|
|
1846
|
-
ReactiveFormsModule,
|
|
1847
|
-
NgxUtilsModule] });
|
|
1848
|
-
NgxDynamicFormModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: NgxDynamicFormModule, providers: [
|
|
1849
|
-
...pipes,
|
|
1850
|
-
{ provide: NG_VALIDATORS, useValue: validateJSON, multi: true },
|
|
1851
|
-
{ provide: NG_VALIDATORS, useValue: validateRequiredTranslation, multi: true },
|
|
1852
|
-
{ provide: NG_VALIDATORS, useValue: validateItemsMinLength, multi: true },
|
|
1853
|
-
{ provide: NG_VALIDATORS, useValue: validateItemsMaxLength, multi: true },
|
|
1854
|
-
{ provide: NG_VALIDATORS, useValue: validateItemsMinValue, multi: true },
|
|
1855
|
-
{ provide: NG_VALIDATORS, useValue: validateItemsMaxValue, multi: true },
|
|
1856
|
-
{
|
|
1857
|
-
provide: DYNAMIC_VALIDATORS,
|
|
1858
|
-
useValue: new Map([
|
|
1859
|
-
["json", validateJSON],
|
|
1860
|
-
["requiredTranslation", validateRequiredTranslation],
|
|
1861
|
-
["phone", validatePhone],
|
|
1862
|
-
["itemsMinLength", validateItemsMinLength],
|
|
1863
|
-
["itemsMaxLength", validateItemsMaxLength],
|
|
1864
|
-
["itemsMinValue", validateItemsMinValue],
|
|
1865
|
-
["itemsMaxValue", validateItemsMaxValue],
|
|
1866
|
-
])
|
|
1867
|
-
}
|
|
1868
|
-
], imports: [[
|
|
1869
|
-
CommonModule,
|
|
1870
|
-
FormsModule,
|
|
1871
|
-
ReactiveFormsModule,
|
|
1872
|
-
NgxUtilsModule
|
|
1873
|
-
], FormsModule,
|
|
1874
|
-
ReactiveFormsModule,
|
|
1875
|
-
NgxUtilsModule] });
|
|
1876
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: NgxDynamicFormModule, decorators: [{
|
|
1877
|
-
type: NgModule,
|
|
1878
|
-
args: [{
|
|
1879
|
-
declarations: [
|
|
1880
|
-
...components,
|
|
1881
|
-
...directives,
|
|
1882
|
-
...pipes
|
|
1883
|
-
],
|
|
1884
|
-
imports: [
|
|
1885
|
-
CommonModule,
|
|
1886
|
-
FormsModule,
|
|
1887
|
-
ReactiveFormsModule,
|
|
1888
|
-
NgxUtilsModule
|
|
1889
|
-
],
|
|
1890
|
-
exports: [
|
|
1891
|
-
...components,
|
|
1892
|
-
...directives,
|
|
1893
|
-
...pipes,
|
|
1894
|
-
FormsModule,
|
|
1895
|
-
ReactiveFormsModule,
|
|
1896
|
-
NgxUtilsModule
|
|
1897
|
-
],
|
|
1898
|
-
providers: [
|
|
1899
|
-
...pipes,
|
|
1900
|
-
{ provide: NG_VALIDATORS, useValue: validateJSON, multi: true },
|
|
1901
|
-
{ provide: NG_VALIDATORS, useValue: validateRequiredTranslation, multi: true },
|
|
1902
|
-
{ provide: NG_VALIDATORS, useValue: validateItemsMinLength, multi: true },
|
|
1903
|
-
{ provide: NG_VALIDATORS, useValue: validateItemsMaxLength, multi: true },
|
|
1904
|
-
{ provide: NG_VALIDATORS, useValue: validateItemsMinValue, multi: true },
|
|
1905
|
-
{ provide: NG_VALIDATORS, useValue: validateItemsMaxValue, multi: true },
|
|
1906
|
-
{
|
|
1907
|
-
provide: DYNAMIC_VALIDATORS,
|
|
1908
|
-
useValue: new Map([
|
|
1909
|
-
["json", validateJSON],
|
|
1910
|
-
["requiredTranslation", validateRequiredTranslation],
|
|
1911
|
-
["phone", validatePhone],
|
|
1912
|
-
["itemsMinLength", validateItemsMinLength],
|
|
1913
|
-
["itemsMaxLength", validateItemsMaxLength],
|
|
1914
|
-
["itemsMinValue", validateItemsMinValue],
|
|
1915
|
-
["itemsMaxValue", validateItemsMaxValue],
|
|
1916
|
-
])
|
|
1917
|
-
}
|
|
1918
|
-
]
|
|
1919
|
-
}]
|
|
1920
|
-
}] });
|
|
1921
|
-
|
|
1922
|
-
/**
|
|
1923
|
-
* Generated bundle index. Do not edit.
|
|
1924
|
-
*/
|
|
1925
|
-
|
|
1926
|
-
export { AsyncSubmitDirective, DynamicBaseFormArrayComponent, DynamicBaseFormComponent, DynamicBaseFormControlComponent, DynamicBaseFormControlContainerComponent, DynamicBaseFormGroupComponent, DynamicBaseSelectComponent, DynamicEditorModel, DynamicFormArrayGroupModel, DynamicFormArrayModel, DynamicFormGroupModel, DynamicFormOption, DynamicFormService, DynamicSelectModel, EDITOR_FORMATS, FormSelectSubject, FormSubject, MAX_INPUT_NUM, MIN_INPUT_NUM, NgxDynamicFormModule, collectPathAble, createFormArray, createFormCheckbox, createFormDate, createFormEditor, createFormFile, createFormGroup, createFormInput, createFormSelect, createFormTextarea, customizeFormModel, getDynamicPath, getFormComponent, mergeFormModels, replaceSpecialChars, validateItemsMaxLength, validateItemsMaxValue, validateItemsMinLength, validateItemsMinValue, validateJSON, validatePhone, validateRequiredTranslation };
|
|
1927
|
-
//# sourceMappingURL=stemy-ngx-dynamic-form.mjs.map
|