@messaia/cdk 13.3.4 → 13.3.5-rc03
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/esm2020/lib/base/components/generic-form-base.component.mjs +15 -13
- package/esm2020/lib/forms/components/generic-form/generic-form.component.mjs +1 -1
- package/esm2020/lib/forms/constants/constants.mjs +3 -2
- package/esm2020/lib/forms/forms.module.mjs +4 -4
- package/esm2020/lib/forms/functions/decorators.mjs +72 -113
- package/esm2020/lib/forms/functions/functions.mjs +3 -26
- package/esm2020/lib/forms/models/form-field-group-definition.mjs +12 -0
- package/fesm2015/messaia-cdk.mjs +121 -183
- package/fesm2015/messaia-cdk.mjs.map +1 -1
- package/fesm2020/messaia-cdk.mjs +120 -180
- package/fesm2020/messaia-cdk.mjs.map +1 -1
- package/lib/base/components/generic-form-base.component.d.ts +2 -2
- package/lib/forms/components/generic-form/generic-form.component.d.ts +2 -2
- package/lib/forms/constants/constants.d.ts +2 -1
- package/lib/forms/forms.module.d.ts +3 -3
- package/lib/forms/functions/decorators.d.ts +17 -5
- package/lib/forms/functions/functions.d.ts +2 -9
- package/lib/forms/models/{form-field-group.d.ts → form-field-group-definition.d.ts} +5 -2
- package/package.json +1 -1
- package/esm2020/lib/forms/models/form-field-group.mjs +0 -12
package/fesm2020/messaia-cdk.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import { HttpParams, HttpClient, HttpRequest, HttpHeaders, HttpEventType, HttpRe
|
|
|
5
5
|
import * as i0 from '@angular/core';
|
|
6
6
|
import { Directive, Input, Pipe, HostListener, Component, NgModule, Injectable, Injector, ViewEncapsulation, COMPILER_OPTIONS, CompilerFactory, Compiler, ContentChildren, Optional, SkipSelf, NgZone, ElementRef, ViewChildren, ViewChild, forwardRef, ContentChild, EventEmitter, ViewContainerRef, Output, LOCALE_ID, Inject, HostBinding, Self, Attribute, SecurityContext } from '@angular/core';
|
|
7
7
|
import * as i1 from '@angular/forms';
|
|
8
|
-
import { FormControlName, FormControlDirective, FormGroup
|
|
8
|
+
import { FormControlName, FormControlDirective, FormGroup, NG_VALUE_ACCESSOR, FormArray, FormControl, NG_ASYNC_VALIDATORS, NG_VALIDATORS, AbstractControl, FormBuilder, FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|
9
9
|
import * as i1$2 from '@angular/material/dialog';
|
|
10
10
|
import { MatDialogConfig, MatDialog, MatDialogModule } from '@angular/material/dialog';
|
|
11
11
|
import { MatExpansionPanel } from '@angular/material/expansion';
|
|
@@ -3128,48 +3128,16 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImpor
|
|
|
3128
3128
|
args: [MatExpansionPanel]
|
|
3129
3129
|
}] } });
|
|
3130
3130
|
|
|
3131
|
-
const
|
|
3131
|
+
const formFieldsMetadataKey = Symbol('vdFormFields');
|
|
3132
|
+
const formFieldGroupsMetadataKey = Symbol('vdFormFieldGroup');
|
|
3132
3133
|
|
|
3133
|
-
class FormFieldGroup {
|
|
3134
|
-
/**
|
|
3135
|
-
* constructor
|
|
3136
|
-
* @param init
|
|
3137
|
-
*/
|
|
3138
|
-
constructor(init) {
|
|
3139
|
-
this.name = 'details';
|
|
3140
|
-
this.fields = [];
|
|
3141
|
-
Object.assign(this, init);
|
|
3142
|
-
}
|
|
3143
|
-
}
|
|
3144
|
-
|
|
3145
|
-
/**
|
|
3146
|
-
* Gets poperties decoarated with @FormField grouped by row
|
|
3147
|
-
* @param origin
|
|
3148
|
-
* @returns
|
|
3149
|
-
* @deprecated
|
|
3150
|
-
*/
|
|
3151
|
-
function getFormGroupsOld(origin) {
|
|
3152
|
-
return Reflect.getMetadata(formFieldGroupMetadataKey, origin);
|
|
3153
|
-
}
|
|
3154
3134
|
/**
|
|
3155
3135
|
* Gets poperties decoarated with @FormField grouped by row
|
|
3156
3136
|
* @param origin
|
|
3157
3137
|
* @returns
|
|
3158
3138
|
*/
|
|
3159
3139
|
function getFormGroups(origin) {
|
|
3160
|
-
|
|
3161
|
-
return Array.from(grouped).map(([_, value]) => new FormFieldGroup({
|
|
3162
|
-
name: value[0].groupName || null,
|
|
3163
|
-
header: value[0].groupHeader,
|
|
3164
|
-
fields: value,
|
|
3165
|
-
groups: Object.values((value).reduce(function (r, a) {
|
|
3166
|
-
r[a.row] = (r[a.row] || []);
|
|
3167
|
-
r[a.row].push(a);
|
|
3168
|
-
r[a.row].forEach((x, i) => x.index = x.index || i);
|
|
3169
|
-
Utils.sortArray(r[a.row], 'index');
|
|
3170
|
-
return r;
|
|
3171
|
-
}, Object.create(null)))
|
|
3172
|
-
}));
|
|
3140
|
+
return Reflect.getMetadata(formFieldGroupsMetadataKey, origin);
|
|
3173
3141
|
}
|
|
3174
3142
|
|
|
3175
3143
|
// @dynamic
|
|
@@ -3470,12 +3438,14 @@ class GenericFormBaseComponent extends BaseComponent {
|
|
|
3470
3438
|
validateForm(form = null) {
|
|
3471
3439
|
var form = form || this.form;
|
|
3472
3440
|
/* Set the form as submitted */
|
|
3473
|
-
if (form && form instanceof FormGroup
|
|
3441
|
+
if (form && form instanceof FormGroup) {
|
|
3474
3442
|
/* Set form as submitted */
|
|
3475
3443
|
form['submitted'] = true;
|
|
3476
3444
|
/* Update value and validity */
|
|
3477
3445
|
form.updateValueAndValidity();
|
|
3478
3446
|
}
|
|
3447
|
+
/* Print some debug information */
|
|
3448
|
+
this.debugForm(form);
|
|
3479
3449
|
}
|
|
3480
3450
|
/**
|
|
3481
3451
|
* Validates the form
|
|
@@ -3483,9 +3453,7 @@ class GenericFormBaseComponent extends BaseComponent {
|
|
|
3483
3453
|
*/
|
|
3484
3454
|
isFormValid(form = null) {
|
|
3485
3455
|
/* Print some debug information */
|
|
3486
|
-
|
|
3487
|
-
this.debugForm(form);
|
|
3488
|
-
}
|
|
3456
|
+
this.debugForm(form);
|
|
3489
3457
|
/* If the form ist not valid.. */
|
|
3490
3458
|
if (!form.valid) {
|
|
3491
3459
|
/* Mark invalid controls as dirtty and touched */
|
|
@@ -3559,15 +3527,17 @@ class GenericFormBaseComponent extends BaseComponent {
|
|
|
3559
3527
|
* @param form
|
|
3560
3528
|
*/
|
|
3561
3529
|
debugForm(form = null) {
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3530
|
+
if (this.debug) {
|
|
3531
|
+
console.log('Form:', form);
|
|
3532
|
+
Object.keys(form.controls).forEach(key => {
|
|
3533
|
+
const controlErrors = form.controls[key].errors;
|
|
3534
|
+
if (controlErrors != null) {
|
|
3535
|
+
Object.keys(controlErrors).forEach(keyError => {
|
|
3536
|
+
console.log('Key control: ' + key + ', keyError: ' + keyError + ', err value: ', controlErrors[keyError]);
|
|
3537
|
+
});
|
|
3538
|
+
}
|
|
3539
|
+
});
|
|
3540
|
+
}
|
|
3571
3541
|
}
|
|
3572
3542
|
/**
|
|
3573
3543
|
* Add toolbar menu items
|
|
@@ -6987,10 +6957,10 @@ function isResetControl(controlName, control, options) {
|
|
|
6987
6957
|
isReset = control instanceof FormControl;
|
|
6988
6958
|
break;
|
|
6989
6959
|
case ResetFormType.ControlsAndFormGroupsOnly:
|
|
6990
|
-
isReset = control instanceof FormControl || control instanceof FormGroup
|
|
6960
|
+
isReset = control instanceof FormControl || control instanceof FormGroup;
|
|
6991
6961
|
break;
|
|
6992
6962
|
case ResetFormType.FormGroupsOnly:
|
|
6993
|
-
isReset = control instanceof FormGroup
|
|
6963
|
+
isReset = control instanceof FormGroup;
|
|
6994
6964
|
break;
|
|
6995
6965
|
case ResetFormType.FormArraysOnly:
|
|
6996
6966
|
isReset = control instanceof FormArray;
|
|
@@ -7031,7 +7001,7 @@ function getNestedOptions(controlName, options) {
|
|
|
7031
7001
|
return undefined;
|
|
7032
7002
|
}
|
|
7033
7003
|
|
|
7034
|
-
class RxFormGroup extends FormGroup
|
|
7004
|
+
class RxFormGroup extends FormGroup {
|
|
7035
7005
|
constructor(model, entityObject, controls, validatorOrOpts, asyncValidator) {
|
|
7036
7006
|
super(controls, validatorOrOpts, asyncValidator);
|
|
7037
7007
|
this.model = model;
|
|
@@ -7098,7 +7068,7 @@ class RxFormGroup extends FormGroup$1 {
|
|
|
7098
7068
|
let isDirty = false;
|
|
7099
7069
|
for (let name in this.value) {
|
|
7100
7070
|
let currentValue = this.modelInstance[name];
|
|
7101
|
-
if (!(this.controls[name] instanceof FormGroup
|
|
7071
|
+
if (!(this.controls[name] instanceof FormGroup || this.controls[name] instanceof FormArray)) {
|
|
7102
7072
|
isDirty = ApplicationUtil.notEqualTo(this.baseObject[name], currentValue);
|
|
7103
7073
|
}
|
|
7104
7074
|
else if (this.controls[name] instanceof RxFormGroup)
|
|
@@ -7117,7 +7087,7 @@ class RxFormGroup extends FormGroup$1 {
|
|
|
7117
7087
|
resetForm(options) {
|
|
7118
7088
|
for (let name in this.controls) {
|
|
7119
7089
|
if (isResetControl(name, this.controls[name], options)) {
|
|
7120
|
-
if (this.controls[name] instanceof FormGroup
|
|
7090
|
+
if (this.controls[name] instanceof FormGroup)
|
|
7121
7091
|
this.controls[name].resetForm(getNestedOptions(name, options));
|
|
7122
7092
|
else if (this.controls[name] instanceof FormArray) {
|
|
7123
7093
|
this.controls[name].resetForm(options && options.value ? options.value[name] : undefined);
|
|
@@ -7133,7 +7103,7 @@ class RxFormGroup extends FormGroup$1 {
|
|
|
7133
7103
|
}
|
|
7134
7104
|
commit() {
|
|
7135
7105
|
for (let name in this.controls) {
|
|
7136
|
-
if (this.controls[name] instanceof FormGroup
|
|
7106
|
+
if (this.controls[name] instanceof FormGroup)
|
|
7137
7107
|
this.controls[name].commit();
|
|
7138
7108
|
else if (this.controls[name] instanceof FormArray) {
|
|
7139
7109
|
this.controls[name].commit();
|
|
@@ -7164,7 +7134,7 @@ class RxFormGroup extends FormGroup$1 {
|
|
|
7164
7134
|
getErrorSummary(onlyMessage) {
|
|
7165
7135
|
let jObject = {};
|
|
7166
7136
|
Object.keys(this.controls).forEach(columnName => {
|
|
7167
|
-
if (this.controls[columnName] instanceof FormGroup
|
|
7137
|
+
if (this.controls[columnName] instanceof FormGroup) {
|
|
7168
7138
|
let error = this.controls[columnName].getErrorSummary(false);
|
|
7169
7139
|
if (Object.keys(error).length > 0)
|
|
7170
7140
|
jObject[columnName] = error;
|
|
@@ -7197,7 +7167,7 @@ class RxFormGroup extends FormGroup$1 {
|
|
|
7197
7167
|
}
|
|
7198
7168
|
valueChangedSync() {
|
|
7199
7169
|
Object.keys(this.controls).forEach(columnName => {
|
|
7200
|
-
if (!(this.controls[columnName] instanceof FormArray || this.controls[columnName] instanceof RxFormArray) && !(this.controls[columnName] instanceof FormGroup
|
|
7170
|
+
if (!(this.controls[columnName] instanceof FormArray || this.controls[columnName] instanceof RxFormArray) && !(this.controls[columnName] instanceof FormGroup || this.controls[columnName] instanceof RxFormGroup) && !(this.entityObject[columnName] instanceof FormControl || this.entityObject[columnName] instanceof RxFormControl) && this.controls[columnName].getControlValue && ApplicationUtil.notEqualTo(this.controls[columnName].getControlValue(), this.entityObject[columnName])) {
|
|
7201
7171
|
this.controls[columnName].setValue(this.entityObject[columnName], { updateChanged: true });
|
|
7202
7172
|
}
|
|
7203
7173
|
else if ((this.controls[columnName] instanceof FormArray || this.controls[columnName] instanceof RxFormArray)) {
|
|
@@ -7212,7 +7182,7 @@ class RxFormGroup extends FormGroup$1 {
|
|
|
7212
7182
|
}
|
|
7213
7183
|
refreshDisable() {
|
|
7214
7184
|
Object.keys(this.controls).forEach(columnName => {
|
|
7215
|
-
if (!(this.controls[columnName] instanceof FormArray || this.controls[columnName] instanceof RxFormArray) && !(this.controls[columnName] instanceof FormGroup
|
|
7185
|
+
if (!(this.controls[columnName] instanceof FormArray || this.controls[columnName] instanceof RxFormArray) && !(this.controls[columnName] instanceof FormGroup || this.controls[columnName] instanceof RxFormGroup)) {
|
|
7216
7186
|
this.controls[columnName].refresh();
|
|
7217
7187
|
}
|
|
7218
7188
|
else if ((this.controls[columnName] instanceof RxFormGroup)) {
|
|
@@ -7222,7 +7192,7 @@ class RxFormGroup extends FormGroup$1 {
|
|
|
7222
7192
|
}
|
|
7223
7193
|
bindErrorMessages() {
|
|
7224
7194
|
Object.keys(this.controls).forEach(columnName => {
|
|
7225
|
-
if (!(this.controls[columnName] instanceof FormArray || this.controls[columnName] instanceof RxFormArray) && !(this.controls[columnName] instanceof FormGroup
|
|
7195
|
+
if (!(this.controls[columnName] instanceof FormArray || this.controls[columnName] instanceof RxFormArray) && !(this.controls[columnName] instanceof FormGroup || this.controls[columnName] instanceof RxFormGroup)) {
|
|
7226
7196
|
this.controls[columnName].bindError();
|
|
7227
7197
|
}
|
|
7228
7198
|
else if ((this.controls[columnName] instanceof RxFormGroup)) {
|
|
@@ -7241,7 +7211,7 @@ class RxFormGroup extends FormGroup$1 {
|
|
|
7241
7211
|
for (let formGroup of formArray.controls)
|
|
7242
7212
|
formGroup.submitted = value;
|
|
7243
7213
|
}
|
|
7244
|
-
else if (this.controls[columnName] instanceof FormGroup
|
|
7214
|
+
else if (this.controls[columnName] instanceof FormGroup) {
|
|
7245
7215
|
this.controls[columnName].submitted = value;
|
|
7246
7216
|
}
|
|
7247
7217
|
else
|
|
@@ -7278,7 +7248,7 @@ class RxFormGroup extends FormGroup$1 {
|
|
|
7278
7248
|
setBackEndErrors(errors) {
|
|
7279
7249
|
Object.keys(errors).forEach(controlName => {
|
|
7280
7250
|
if (this.controls[controlName]) {
|
|
7281
|
-
if (this.controls[controlName] instanceof FormGroup
|
|
7251
|
+
if (this.controls[controlName] instanceof FormGroup)
|
|
7282
7252
|
this.controls[controlName].setBackEndErrors(errors[controlName]);
|
|
7283
7253
|
else
|
|
7284
7254
|
this.controls[controlName].setBackEndErrors(errors[controlName]);
|
|
@@ -7289,7 +7259,7 @@ class RxFormGroup extends FormGroup$1 {
|
|
|
7289
7259
|
let clearErrors = errors ? Object.keys(errors) : Object.keys(this.controls);
|
|
7290
7260
|
clearErrors.forEach(controlName => {
|
|
7291
7261
|
if (this.controls[controlName]) {
|
|
7292
|
-
if (this.controls[controlName] instanceof FormGroup
|
|
7262
|
+
if (this.controls[controlName] instanceof FormGroup)
|
|
7293
7263
|
errors ? this.controls[controlName].clearBackEndErrors(errors[controlName]) : this.controls[controlName].clearBackEndErrors();
|
|
7294
7264
|
else
|
|
7295
7265
|
errors ? this.controls[controlName].clearBackEndErrors(errors[controlName]) : this.controls[controlName].clearBackEndErrors();
|
|
@@ -9479,7 +9449,7 @@ class RxwebFormDirective extends BaseDirective {
|
|
|
9479
9449
|
}
|
|
9480
9450
|
updateValueAndValidity(controls) {
|
|
9481
9451
|
Object.keys(controls).forEach(key => {
|
|
9482
|
-
if (controls[key] instanceof FormGroup
|
|
9452
|
+
if (controls[key] instanceof FormGroup)
|
|
9483
9453
|
this.updateValueAndValidity(controls[key].controls);
|
|
9484
9454
|
else if (controls[key] instanceof FormArray)
|
|
9485
9455
|
this.updateValueAndValidity(controls[key].controls);
|
|
@@ -9516,7 +9486,7 @@ class RxwebFormDirective extends BaseDirective {
|
|
|
9516
9486
|
}
|
|
9517
9487
|
});
|
|
9518
9488
|
}
|
|
9519
|
-
else if (formControl instanceof FormGroup
|
|
9489
|
+
else if (formControl instanceof FormGroup) {
|
|
9520
9490
|
this.expressionProcessor(formControl.controls, `${fieldName}.`);
|
|
9521
9491
|
}
|
|
9522
9492
|
else if (formControl instanceof FormArray) {
|
|
@@ -9533,7 +9503,7 @@ class RxwebFormDirective extends BaseDirective {
|
|
|
9533
9503
|
if (this.validationRule.conditionalValidationProps && this.validationRule.conditionalValidationProps[fieldName]) {
|
|
9534
9504
|
controls[fieldName][CONDITIONAL_VALIDATOR] = conditionalChangeValidator(this.validationRule.conditionalValidationProps[fieldName]);
|
|
9535
9505
|
}
|
|
9536
|
-
else if (controls[fieldName] instanceof FormGroup
|
|
9506
|
+
else if (controls[fieldName] instanceof FormGroup && this.validationRule.conditionalObjectProps) {
|
|
9537
9507
|
var fields = this.validationRule.conditionalObjectProps.filter(t => t.objectPropName == fieldName);
|
|
9538
9508
|
let nestedFormGroup = controls[fieldName];
|
|
9539
9509
|
let propWiseConditionalControls = {};
|
|
@@ -10998,10 +10968,10 @@ class RxFormBuilder extends BaseFormBuilder {
|
|
|
10998
10968
|
}
|
|
10999
10969
|
else if (typeof prop == OBJECT_STRING && !(prop instanceof FormControl || prop instanceof RxFormControl)) {
|
|
11000
10970
|
let formGroup = (prop instanceof FormArray) ? prop.controls[0] : prop;
|
|
11001
|
-
if (!formGroup.model && (prop instanceof FormGroup
|
|
10971
|
+
if (!formGroup.model && (prop instanceof FormGroup || prop instanceof RxFormGroup)) {
|
|
11002
10972
|
formGroup = this.group(formGroup.controls);
|
|
11003
10973
|
}
|
|
11004
|
-
if (prop instanceof FormGroup
|
|
10974
|
+
if (prop instanceof FormGroup || prop instanceof RxFormGroup) {
|
|
11005
10975
|
entityObject[propName] = prop;
|
|
11006
10976
|
defaultContainer.initPropertyObject(propName, OBJECT_PROPERTY, formGroup.model, modelInstance);
|
|
11007
10977
|
}
|
|
@@ -11142,7 +11112,7 @@ class RxFormBuilder extends BaseFormBuilder {
|
|
|
11142
11112
|
break;
|
|
11143
11113
|
case OBJECT_PROPERTY:
|
|
11144
11114
|
let objectValue = entityObject[property.name];
|
|
11145
|
-
if (objectValue && objectValue instanceof Object && !(objectValue instanceof FormGroup
|
|
11115
|
+
if (objectValue && objectValue instanceof Object && !(objectValue instanceof FormGroup || objectValue instanceof RxFormGroup)) {
|
|
11146
11116
|
this.isNestedBinding = this.isNested = true;
|
|
11147
11117
|
if (instanceContainer && instanceContainer.conditionalObjectProps)
|
|
11148
11118
|
this.conditionalObjectProps = instanceContainer.conditionalObjectProps.filter(t => t.objectPropName == property.name);
|
|
@@ -11157,7 +11127,7 @@ class RxFormBuilder extends BaseFormBuilder {
|
|
|
11157
11127
|
this.builderConfigurationConditionalObjectProps = [];
|
|
11158
11128
|
this.isNestedBinding = this.isNested = false;
|
|
11159
11129
|
}
|
|
11160
|
-
else if (objectValue instanceof FormGroup
|
|
11130
|
+
else if (objectValue instanceof FormGroup || objectValue instanceof RxFormGroup)
|
|
11161
11131
|
formGroupObject[property.name] = objectValue;
|
|
11162
11132
|
break;
|
|
11163
11133
|
case ARRAY_PROPERTY:
|
|
@@ -14478,12 +14448,24 @@ class FormFieldDefinition {
|
|
|
14478
14448
|
}
|
|
14479
14449
|
}
|
|
14480
14450
|
|
|
14451
|
+
class FormFieldGroupDefinition {
|
|
14452
|
+
/**
|
|
14453
|
+
* constructor
|
|
14454
|
+
* @param init
|
|
14455
|
+
*/
|
|
14456
|
+
constructor(init) {
|
|
14457
|
+
this.name = 'details';
|
|
14458
|
+
this.fields = [];
|
|
14459
|
+
Object.assign(this, init);
|
|
14460
|
+
}
|
|
14461
|
+
}
|
|
14462
|
+
|
|
14481
14463
|
/**
|
|
14482
14464
|
* Property decorator to create form fields
|
|
14483
14465
|
* @param args
|
|
14484
14466
|
* @returns
|
|
14485
14467
|
*/
|
|
14486
|
-
function
|
|
14468
|
+
function FormField(args) {
|
|
14487
14469
|
return function (target, propertyKey) {
|
|
14488
14470
|
/* Get property name */
|
|
14489
14471
|
var propertyName = args.name || propertyKey;
|
|
@@ -14534,132 +14516,90 @@ function FormFieldOld(args) {
|
|
|
14534
14516
|
break;
|
|
14535
14517
|
}
|
|
14536
14518
|
}
|
|
14537
|
-
/* Get
|
|
14538
|
-
|
|
14539
|
-
/*
|
|
14540
|
-
|
|
14541
|
-
/*
|
|
14542
|
-
|
|
14543
|
-
group.fields.push(formField);
|
|
14544
|
-
}
|
|
14545
|
-
/* Create a new group */
|
|
14546
|
-
else {
|
|
14547
|
-
group = new FormFieldGroup({ name: formField.groupName || null, header: formField.groupHeader, fields: [formField] });
|
|
14548
|
-
formFieldGroups.push(group);
|
|
14549
|
-
}
|
|
14550
|
-
/* Sort the fields by row */
|
|
14551
|
-
group.fields = group.fields?.sort((a, b) => (a.row || 0 > b.row || 0) ? 1 : ((b.row || 0 > a.row || 0) ? -1 : 0)) || [];
|
|
14519
|
+
/* Get old form fields */
|
|
14520
|
+
const previousFormFields = Reflect.getMetadata(formFieldsMetadataKey, target);
|
|
14521
|
+
/* Create a copy of the result */
|
|
14522
|
+
let formFields = previousFormFields ? previousFormFields.concat([formField]) : [formField];
|
|
14523
|
+
/* Override the result in the metadata */
|
|
14524
|
+
Reflect.defineMetadata(formFieldsMetadataKey, formFields, target);
|
|
14552
14525
|
/* Group the fields */
|
|
14553
|
-
|
|
14554
|
-
|
|
14555
|
-
|
|
14556
|
-
|
|
14557
|
-
|
|
14558
|
-
|
|
14559
|
-
|
|
14526
|
+
var groups = Array.from(Utils.groupArrayBy(formFields, x => x.groupName))
|
|
14527
|
+
.map(([_, value]) => new FormFieldGroupDefinition({
|
|
14528
|
+
name: value[0].groupName || null,
|
|
14529
|
+
header: value[0].groupHeader,
|
|
14530
|
+
fields: value,
|
|
14531
|
+
groups: Object.values((value).reduce(function (r, a) {
|
|
14532
|
+
r[a.row] = (r[a.row] || []);
|
|
14533
|
+
r[a.row].push(a);
|
|
14534
|
+
r[a.row].forEach((x, i) => x.index = x.index || i);
|
|
14535
|
+
Utils.sortArray(r[a.row], 'index');
|
|
14536
|
+
return r;
|
|
14537
|
+
}, Object.create(null)))
|
|
14538
|
+
}));
|
|
14539
|
+
/* Override the result in the metadata */
|
|
14540
|
+
Reflect.defineMetadata(formFieldGroupsMetadataKey, groups, target);
|
|
14560
14541
|
};
|
|
14561
14542
|
}
|
|
14562
14543
|
/**
|
|
14563
14544
|
* Property decorator to create form fields
|
|
14564
|
-
* @param
|
|
14545
|
+
* @param type
|
|
14546
|
+
* @param header
|
|
14547
|
+
* @param init
|
|
14565
14548
|
* @returns
|
|
14566
14549
|
*/
|
|
14567
|
-
function
|
|
14550
|
+
function FormFieldGroup(type, header, init) {
|
|
14568
14551
|
return function (target, propertyKey) {
|
|
14569
|
-
/*
|
|
14570
|
-
var
|
|
14571
|
-
|
|
14572
|
-
|
|
14573
|
-
|
|
14574
|
-
|
|
14575
|
-
|
|
14576
|
-
|
|
14577
|
-
|
|
14578
|
-
|
|
14579
|
-
|
|
14580
|
-
|
|
14581
|
-
|
|
14582
|
-
|
|
14583
|
-
|
|
14584
|
-
|
|
14585
|
-
|
|
14586
|
-
|
|
14587
|
-
|
|
14588
|
-
|
|
14589
|
-
|
|
14590
|
-
|
|
14591
|
-
}
|
|
14592
|
-
/* Type TextArea */
|
|
14593
|
-
else if (formField.rows) {
|
|
14594
|
-
formField.type || (formField.type = FormFieldType.TextArea);
|
|
14595
|
-
}
|
|
14596
|
-
/* Type File */
|
|
14597
|
-
else if (formField.filePath) {
|
|
14598
|
-
formField.type || (formField.type = FormFieldType.File);
|
|
14599
|
-
}
|
|
14600
|
-
/* Other types */
|
|
14601
|
-
else {
|
|
14602
|
-
switch (propertyType.toLowerCase()) {
|
|
14603
|
-
case 'number':
|
|
14604
|
-
formField.type || (formField.type = FormFieldType.Text);
|
|
14605
|
-
formField.inputType || (formField.inputType = 'number');
|
|
14606
|
-
break;
|
|
14607
|
-
case 'date':
|
|
14608
|
-
formField.type || (formField.type = FormFieldType.Date);
|
|
14609
|
-
break;
|
|
14610
|
-
case 'boolean':
|
|
14611
|
-
formField.type || (formField.type = FormFieldType.Checkbox);
|
|
14612
|
-
break;
|
|
14613
|
-
default:
|
|
14614
|
-
formField.type || (formField.type = FormFieldType.Text);
|
|
14615
|
-
break;
|
|
14616
|
-
}
|
|
14617
|
-
}
|
|
14618
|
-
/* Get old form fields */
|
|
14619
|
-
const previousFormFields = Reflect.getMetadata(formFieldGroupMetadataKey, target);
|
|
14552
|
+
/* Create an instance of the group object */
|
|
14553
|
+
var instance = Reflect.construct(type, []);
|
|
14554
|
+
console.log('instance', instance);
|
|
14555
|
+
/* Get from groups */
|
|
14556
|
+
var groups = getFormGroups(instance);
|
|
14557
|
+
console.log('groups', groups);
|
|
14558
|
+
/* Get the fields from the groups */
|
|
14559
|
+
groups?.forEach(x => {
|
|
14560
|
+
Object.assign(x, {
|
|
14561
|
+
name: propertyKey,
|
|
14562
|
+
header: header,
|
|
14563
|
+
type: type,
|
|
14564
|
+
instance: init || instance
|
|
14565
|
+
});
|
|
14566
|
+
/* Set the name of the group in the fields */
|
|
14567
|
+
x.fields.forEach(y => Object.assign(y, {
|
|
14568
|
+
groupName: propertyKey,
|
|
14569
|
+
groupHeader: header
|
|
14570
|
+
}));
|
|
14571
|
+
});
|
|
14572
|
+
/* Get old form field groups */
|
|
14573
|
+
const previousGroups = Reflect.getMetadata(formFieldGroupsMetadataKey, target);
|
|
14620
14574
|
/* Create a copy of the result */
|
|
14621
|
-
let
|
|
14575
|
+
let combinedGroups = previousGroups ? previousGroups.concat(groups) : groups;
|
|
14576
|
+
console.log('combinedGroups', combinedGroups);
|
|
14622
14577
|
/* Override the result in the metadata */
|
|
14623
|
-
Reflect.defineMetadata(
|
|
14578
|
+
Reflect.defineMetadata(formFieldGroupsMetadataKey, combinedGroups, target);
|
|
14624
14579
|
};
|
|
14625
14580
|
}
|
|
14626
14581
|
/**
|
|
14627
14582
|
* Property decorator to create form fields
|
|
14628
|
-
* @param
|
|
14583
|
+
* @param type
|
|
14584
|
+
* @param header
|
|
14585
|
+
* @param init
|
|
14629
14586
|
* @returns
|
|
14630
14587
|
*/
|
|
14631
|
-
function
|
|
14588
|
+
function FormFieldGroup2(type, header, init) {
|
|
14632
14589
|
return function (target, propertyKey) {
|
|
14633
|
-
|
|
14634
|
-
|
|
14635
|
-
|
|
14636
|
-
|
|
14637
|
-
|
|
14638
|
-
|
|
14639
|
-
|
|
14640
|
-
|
|
14641
|
-
|
|
14642
|
-
|
|
14643
|
-
|
|
14644
|
-
|
|
14645
|
-
|
|
14646
|
-
group.fields.push(...fields);
|
|
14647
|
-
}
|
|
14648
|
-
/* Create the new group */
|
|
14649
|
-
else {
|
|
14650
|
-
group = new FormFieldGroup({ name: name, header: header, fields: fields });
|
|
14651
|
-
formFieldGroups.push(group);
|
|
14652
|
-
}
|
|
14653
|
-
/* Sort the fields by row */
|
|
14654
|
-
group.fields = group?.fields?.sort((a, b) => (a.row || 0 > b.row || 0) ? 1 : ((b.row || 0 > a.row || 0) ? -1 : 0)) || [];
|
|
14655
|
-
/* Group the fields */
|
|
14656
|
-
group.groups = Object.values((group.fields).reduce(function (r, a) {
|
|
14657
|
-
r[a.row] = r[a.row] || [];
|
|
14658
|
-
r[a.row].push(a);
|
|
14659
|
-
return r;
|
|
14660
|
-
}, Object.create(null)));
|
|
14661
|
-
/* Add new table column */
|
|
14662
|
-
Reflect.defineMetadata(formFieldGroupMetadataKey, formFieldGroups, target);
|
|
14590
|
+
console.log('target2', target);
|
|
14591
|
+
};
|
|
14592
|
+
}
|
|
14593
|
+
/**
|
|
14594
|
+
* Property decorator to create form fields
|
|
14595
|
+
* @param type
|
|
14596
|
+
* @param header
|
|
14597
|
+
* @param init
|
|
14598
|
+
* @returns
|
|
14599
|
+
*/
|
|
14600
|
+
function FormFieldGroup3(type, header) {
|
|
14601
|
+
return function (target, propertyKey) {
|
|
14602
|
+
console.log('target3', target);
|
|
14663
14603
|
};
|
|
14664
14604
|
}
|
|
14665
14605
|
|
|
@@ -16865,5 +16805,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImpor
|
|
|
16865
16805
|
* Generated bundle index. Do not edit.
|
|
16866
16806
|
*/
|
|
16867
16807
|
|
|
16868
|
-
export { AbstractMatFormField, ActionMenuItem, Api, AppSetting, AppStorage, AsyncValidationDirective, AuditEntity, AuditUser, AuthHelper, AuthUser, BaseComponent, BaseDirective, BaseEntity, BaseInterceptor, BaseService, CachingInterceptor, Column, Common, ContextHelper, DataSourceFilterDirective, DataSourcePipe, DisableControlDirective, Display, DynamicBuilder, DynamicComponentCompiler, EnumPipe, EnumService, EqualValidator, ErrorMessageBindingStrategy, FileControlDirective, FileService, FileSizePipe, FilterClearComponent, FilterDateComponent, FilterInputComponent, FilterPipe, FilterSelectComponent, FirstLetterPipe, FormBuilderConfiguration, FormField, FormFieldDefinition, FormFieldGroup,
|
|
16808
|
+
export { AbstractMatFormField, ActionMenuItem, Api, AppSetting, AppStorage, AsyncValidationDirective, AuditEntity, AuditUser, AuthHelper, AuthUser, BaseComponent, BaseDirective, BaseEntity, BaseInterceptor, BaseService, CachingInterceptor, Column, Common, ContextHelper, DataSourceFilterDirective, DataSourcePipe, DisableControlDirective, Display, DynamicBuilder, DynamicComponentCompiler, EnumPipe, EnumService, EqualValidator, ErrorMessageBindingStrategy, FileControlDirective, FileService, FileSizePipe, FilterClearComponent, FilterDateComponent, FilterInputComponent, FilterPipe, FilterSelectComponent, FirstLetterPipe, FormBuilderConfiguration, FormField, FormFieldDefinition, FormFieldGroup, FormFieldGroup2, FormFieldGroup3, FormFieldGroupDefinition, FormFieldType, GenericFormBaseComponent, GenericFormComponent, GenericListComponent, GenericReactiveFormComponent, GenericService, HtmlControlTemplateDirective, IAbstractControl, ImageFileControlDirective, IpVersion, KeyValue, KeysPipe, LoadingScreenInterceptor, LoadingScreenService, MatFormFieldEditorDirective, MatFormFieldReadonlyDirective, Menu, MenuItem, MenuItemService, MenuResolve, MenuScope, MenuService, MessageType, MonthNamePipe, NativeElementInjectorDirective, NumericValueType, OnlyNumberDirective, OrderPipe, Pagination, PlaceholderPipe, PrintService, RUNTIME_COMPILER_PROVIDERS, ReactiveFormConfig, ReactiveTypedFormsModule, ResetFormType, RxFormArray, RxFormBuilder, RxFormControl, RxFormControlDirective, RxFormGroup, RxReactiveFormsModule, RxwebFormDirective, RxwebValidators, SafeHtmlPipe, Salutation, SaveAction, ServiceLocator, SubMenuResolve, SuffixButton, Table, TableColumn, TableColumnType, TableDataSource, TableDefinition, TableMenuItem, TableStaticDataSource, TimePipe, TitleCase, TruncatePipe, TypedForm, TypedFormBuilder, UniqueValidatorDirective, Utils, ValidationAlphabetLocale, ValueAccessorBase, ValuesPipe, VdAlertDialogComponent, VdAutocompleteOptionDirective, VdBaseModule, VdChipDirective, VdChipsComponent, VdChipsModule, VdCodeDirective, VdCommonModule, VdConfirmDialogComponent, VdCustomDirective, VdDialogActionsDirective, VdDialogComponent, VdDialogContentDirective, VdDialogService, VdDialogTitleDirective, VdDialogsModule, VdDynamicTableComponent, VdEditorDirective, VdFileDirective, VdFileInputComponent, VdFileModule, VdFilterOptionDirective, VdFormToolbarComponent, VdFormToolbarMenuComponent, VdFormsModule, VdGenericFormComponent, VdHttpModule, VdLayoutCardOverComponent, VdLayoutCloseDirective, VdLayoutComponent, VdLayoutFooterComponent, VdLayoutManageListCloseDirective, VdLayoutManageListComponent, VdLayoutManageListOpenDirective, VdLayoutManageListToggleDirective, VdLayoutModule, VdLayoutNavComponent, VdLayoutNavListCloseDirective, VdLayoutNavListComponent, VdLayoutNavListOpenDirective, VdLayoutNavListToggleDirective, VdLayoutOpenDirective, VdLayoutToggleDirective, VdListToolbarComponent, VdListToolbarMenuComponent, VdMediaModule, VdMediaService, VdMediaToggleDirective, VdMenuComponent, VdMenuModule, VdNavigationDrawerComponent, VdNavigationDrawerMenuDirective, VdNavigationDrawerToolbarDirective, VdPromptDialogComponent, VdSearchBoxComponent, VdSearchInputComponent, VdSearchModule, VdSelectComponent, VdSelectModule, VdSelectOptionDirective, VdSelectTriggerDirective, VdTableModule, allOf, allOfAsync, alpha, alphaAsync, alphaNumeric, alphaNumericAsync, and, ascii, async, blacklist, choice, choiceAsync, compare, compose, contains, containsAsync, createCompiler, creditCard, creditCardAsync, cusip, custom, customAsync, dataUri, date, dateAsync, different, digit, disable, elementClass, email, endsWith, endsWithAsync, error, escape, even, extension, extensionAsync, factor, factorAsync, file, fileAsync, fileSize, fileSizeAsync, formFieldsMetadataKey as formFieldGroupMetadataKey, formFieldGroupsMetadataKey as formFieldsMetadataKey, getEndpoint, getFormGroups, getTableDefinition, greaterThan, greaterThanAsync, greaterThanEqualTo, greaterThanEqualToAsync, grid, headerMetadataKey, hexColor, image, imageAsync, json, latLong, latitude, leapYear, lessThan, lessThanAsync, lessThanEqualTo, lessThanEqualToAsync, longitude, lowerCase, ltrim, mac, mask, maxDate, maxDateAsync, maxLength, maxLengthAsync, maxNumber, maxNumberAsync, maxTime, maxTimeAsync, minDate, minDateAsync, minLength, minLengthAsync, minNumber, minNumberAsync, minTime, minTimeAsync, mixinControlValueAccessor, mixinDisabled, model, noneOf, noneOfAsync, not, notEmpty, numeric, numericAsync, odd, oneOf, oneOfAsync, or, password, passwordAsync, pattern, patternAsync, port, prefix, primeNumber, prop, propArray, propObject, range, rangeAsync, required, requiredTrue, rtrim, rule, sanitize, startsWith, startsWithAsync, stripLow, suffix, time, timeAsync, toBoolean, toDate, toDouble, toFloat, toInt, toString, trim, unique, upperCase, url, urlAsync, whitelist };
|
|
16869
16809
|
//# sourceMappingURL=messaia-cdk.mjs.map
|