mmhglobal-dynamicform 2.0.0 → 2.0.2
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/README.md +9 -0
- package/esm2020/lib/components/fieldbase.component.mjs +7 -1
- package/esm2020/lib/services/main.service.mjs +7 -3
- package/esm2020/lib/zgrid/zgrid.component.mjs +13 -1
- package/esm2020/lib/ztextarea/ztextarea.component.mjs +6 -2
- package/esm2020/lib/zudf/zudf.component.mjs +16 -6
- package/fesm2015/mmhglobal-dynamicform.mjs +40 -9
- package/fesm2015/mmhglobal-dynamicform.mjs.map +1 -1
- package/fesm2020/mmhglobal-dynamicform.mjs +40 -8
- package/fesm2020/mmhglobal-dynamicform.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -472,6 +472,12 @@ class FieldBase {
|
|
|
472
472
|
this.setRequire = (status) => {
|
|
473
473
|
this.componentProperties.isRequired = status;
|
|
474
474
|
ZComponentHelper.changeValidator(status, this.group, this.data.Value, this.componentProperties, Validators.required);
|
|
475
|
+
if (this.data.Type === 'ztexteditor') {
|
|
476
|
+
ZComponentHelper.changeValidator(status, this.group, this.data.Value, this.componentProperties, ZComponentHelper.requiredValidator_WithoutWhiteSpaces_TextEditor);
|
|
477
|
+
}
|
|
478
|
+
else {
|
|
479
|
+
ZComponentHelper.changeValidator(status, this.group, this.data.Value, this.componentProperties, ZComponentHelper.requiredValidator_WithoutWhiteSpaces);
|
|
480
|
+
}
|
|
475
481
|
};
|
|
476
482
|
}
|
|
477
483
|
initComponent() {
|
|
@@ -2450,8 +2456,10 @@ class MainService {
|
|
|
2450
2456
|
const referenceId = group.parentReferenceId || "0";
|
|
2451
2457
|
//const pathSegment = this.router.url.split("/");
|
|
2452
2458
|
//const lastSegment = pathSegment[pathSegment.length - 1];
|
|
2453
|
-
const
|
|
2454
|
-
const
|
|
2459
|
+
const currentNavigationParam = this.getNavigationCurrentParam();
|
|
2460
|
+
const navigationSegments = currentNavigationParam ? currentNavigationParam.split('/') : null;
|
|
2461
|
+
const defaultAction = group.isCloneNew ? 'new' : 'edit';
|
|
2462
|
+
const actionSegment = group.isCloneNew ? (navigationSegments ? navigationSegments[navigationSegments.length - 1] : 'new') : defaultAction;
|
|
2455
2463
|
if (group.isListForm) {
|
|
2456
2464
|
this.tryUpdateGroupTrigger(false);
|
|
2457
2465
|
this.setNavigationParams([referenceId, 'new']);
|
|
@@ -2741,6 +2749,8 @@ class MainService {
|
|
|
2741
2749
|
}
|
|
2742
2750
|
if (!fg.valid) {
|
|
2743
2751
|
this.componentErrorHandler.showFormGroupErrorMessage(group, fg);
|
|
2752
|
+
fg.markAsTouched();
|
|
2753
|
+
fg.markAllAsTouched();
|
|
2744
2754
|
return false;
|
|
2745
2755
|
}
|
|
2746
2756
|
return true;
|
|
@@ -7482,7 +7492,7 @@ class ZtextareaComponent extends InputFieldBase {
|
|
|
7482
7492
|
super.focusOnDefault(this.focus.bind(this));
|
|
7483
7493
|
}
|
|
7484
7494
|
setCharCounterDisplayStr() {
|
|
7485
|
-
const characterCount = this.group.zModel[this.data.Value]
|
|
7495
|
+
const characterCount = ZComponentHelper.getValueWithoutContinuousSpaces(this.group.zModel[this.data.Value]).length;
|
|
7486
7496
|
this.charCounterDisplayStr = `${characterCount} ${this.data.MaxLength ? (' / ' + this.data.MaxLength) : ''}`;
|
|
7487
7497
|
}
|
|
7488
7498
|
onChange(event, fieldValue) {
|
|
@@ -8967,6 +8977,12 @@ class ZgridComponent extends DataListingFieldBase {
|
|
|
8967
8977
|
const validators = [];
|
|
8968
8978
|
if (col.IsRequired) {
|
|
8969
8979
|
validators.push(Validators.required);
|
|
8980
|
+
if (col.Type === 'ztexteditor') {
|
|
8981
|
+
validators.push(ZComponentHelper.requiredValidator_WithoutWhiteSpaces_TextEditor);
|
|
8982
|
+
}
|
|
8983
|
+
else {
|
|
8984
|
+
validators.push(ZComponentHelper.requiredValidator_WithoutWhiteSpaces);
|
|
8985
|
+
}
|
|
8970
8986
|
}
|
|
8971
8987
|
if (col.ValidatorPattern) {
|
|
8972
8988
|
validators.push(Validators.pattern(col.ValidatorPattern));
|
|
@@ -9034,6 +9050,12 @@ class ZgridComponent extends DataListingFieldBase {
|
|
|
9034
9050
|
const validators = [];
|
|
9035
9051
|
if (col.IsRequired) {
|
|
9036
9052
|
validators.push(Validators.required);
|
|
9053
|
+
if (col.Type === 'ztexteditor') {
|
|
9054
|
+
validators.push(ZComponentHelper.requiredValidator_WithoutWhiteSpaces_TextEditor);
|
|
9055
|
+
}
|
|
9056
|
+
else {
|
|
9057
|
+
validators.push(ZComponentHelper.requiredValidator_WithoutWhiteSpaces);
|
|
9058
|
+
}
|
|
9037
9059
|
}
|
|
9038
9060
|
if (col.ValidatorPattern) {
|
|
9039
9061
|
validators.push(Validators.pattern(col.ValidatorPattern));
|
|
@@ -11605,6 +11627,12 @@ class ZudfComponent {
|
|
|
11605
11627
|
this.setRequire = (status) => {
|
|
11606
11628
|
this.componentProperties.isRequired = status;
|
|
11607
11629
|
ZComponentHelper.changeValidator(status, this.group, this.data.Value, this.componentProperties, Validators.required);
|
|
11630
|
+
if (this.data.Type === 'ztexteditor') {
|
|
11631
|
+
ZComponentHelper.changeValidator(status, this.group, this.data.Value, this.componentProperties, ZComponentHelper.requiredValidator_WithoutWhiteSpaces_TextEditor);
|
|
11632
|
+
}
|
|
11633
|
+
else {
|
|
11634
|
+
ZComponentHelper.changeValidator(status, this.group, this.data.Value, this.componentProperties, ZComponentHelper.requiredValidator_WithoutWhiteSpaces);
|
|
11635
|
+
}
|
|
11608
11636
|
};
|
|
11609
11637
|
}
|
|
11610
11638
|
ngOnInit() {
|
|
@@ -11805,7 +11833,7 @@ class ZudfComponent {
|
|
|
11805
11833
|
}
|
|
11806
11834
|
else {
|
|
11807
11835
|
// before generate FormControl, we need to add 2 attribute to the field when render.
|
|
11808
|
-
// this for later on, we can easily know this field belong to which zudf and under which container.
|
|
11836
|
+
// this for later on, we can easily know this field belong to which zudf and under which container.
|
|
11809
11837
|
if (containerName) {
|
|
11810
11838
|
field['containerName'] = containerName;
|
|
11811
11839
|
;
|
|
@@ -11824,7 +11852,7 @@ class ZudfComponent {
|
|
|
11824
11852
|
zudfGroup[containerName].push(field.Value);
|
|
11825
11853
|
}
|
|
11826
11854
|
}
|
|
11827
|
-
// set the list of dropdown option to the variable
|
|
11855
|
+
// set the list of dropdown option to the variable
|
|
11828
11856
|
if (this.isDropdownType(field.Type) && field.ZDataOptionName && field.DropdownOptions) {
|
|
11829
11857
|
this.group.zData[field.ZDataOptionName] = Object.assign([], eval('this.' + field.DropdownOptions));
|
|
11830
11858
|
}
|
|
@@ -11847,7 +11875,7 @@ class ZudfComponent {
|
|
|
11847
11875
|
if (!zudfGroup['fieldRequiredDefaultUser']) {
|
|
11848
11876
|
zudfGroup['fieldRequiredDefaultUser'] = [];
|
|
11849
11877
|
}
|
|
11850
|
-
// keep a list of default user need to be filled in the scope
|
|
11878
|
+
// keep a list of default user need to be filled in the scope
|
|
11851
11879
|
zudfGroup['fieldRequiredDefaultUser'].push({
|
|
11852
11880
|
fieldName: field.Name,
|
|
11853
11881
|
childFields: field.ChildFields
|
|
@@ -11957,7 +11985,7 @@ class ZudfComponent {
|
|
|
11957
11985
|
updatedModelData[prefixedPropertyName] = updatedNestedObject;
|
|
11958
11986
|
}
|
|
11959
11987
|
else {
|
|
11960
|
-
// Add the property to the output object with the component prefix
|
|
11988
|
+
// Add the property to the output object with the component prefix
|
|
11961
11989
|
let prefixedPropertyName;
|
|
11962
11990
|
if (containerPrefix) {
|
|
11963
11991
|
prefixedPropertyName = `${this.componentPrefix}_${containerPrefix}_${propertyName}`;
|
|
@@ -12192,7 +12220,7 @@ class ZudfComponent {
|
|
|
12192
12220
|
}
|
|
12193
12221
|
}
|
|
12194
12222
|
clearContainerRelatedFieldValue(group, containerName) {
|
|
12195
|
-
// after set to grid, clear the zmodel.
|
|
12223
|
+
// after set to grid, clear the zmodel.
|
|
12196
12224
|
this.clearContainerFieldElementValue(containerName);
|
|
12197
12225
|
}
|
|
12198
12226
|
removeGridRow(gridValue, gridDataSource, dataItem, index) {
|
|
@@ -12220,6 +12248,10 @@ class ZudfComponent {
|
|
|
12220
12248
|
for (const key of Object.keys(fg.controls)) {
|
|
12221
12249
|
this.setContainerFieldErrorAsNull(fg, key);
|
|
12222
12250
|
}
|
|
12251
|
+
// Check is the formgroup value again.
|
|
12252
|
+
if (fg.valid) {
|
|
12253
|
+
return true;
|
|
12254
|
+
}
|
|
12223
12255
|
// Show the error message for the form
|
|
12224
12256
|
this.componentErrorHandlerService.showFormGroupErrorMessage(this.group, fg);
|
|
12225
12257
|
// Return false to indicate that the form is not valid
|