mmhglobal-dynamicform 2.7.2 → 2.8.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.
@@ -163,16 +163,14 @@ class ComponentErrorHandlerService {
163
163
  errorMessage = `Enter a valid email address for {{T_FieldName}}`;
164
164
  break;
165
165
  case 'min':
166
- case 'max':
167
- errorMessage = '';
168
- break;
169
166
  case 'minError':
170
167
  errorMessage = `{{T_FieldName}} must be equal or more than {{T_MinValue}}`;
171
- Object.assign(translationVariables, { T_MinValue: errorDetail[errorType].minValue });
168
+ Object.assign(translationVariables, { T_MinValue: errorDetail[errorType].minValue || errorDetail[errorType].min });
172
169
  break;
170
+ case 'max':
173
171
  case 'maxError':
174
172
  errorMessage = `{{T_FieldName}} must be equal or less than {{T_MaxValue}}`;
175
- Object.assign(translationVariables, { T_MaxValue: errorDetail[errorType].maxValue });
173
+ Object.assign(translationVariables, { T_MaxValue: errorDetail[errorType].maxValue || errorDetail[errorType].max });
176
174
  break;
177
175
  default:
178
176
  console.warn(`Field Error is not properly handled : ${ZComponentHelper.getFieldLabel(fields, controlName)}`);
@@ -497,11 +495,13 @@ class FieldBase {
497
495
  }
498
496
  };
499
497
  }
500
- initComponent() {
498
+ initComponent(options) {
501
499
  this.isLoading = true;
502
500
  this.componentProperties = this.componentProperties || new ZComponentProperties();
503
501
  ZComponentHelper.setComponentProperties(this);
504
- ZComponentHelper.registerComponent(this);
502
+ if (!(options && options.isRegisterComponent == false)) {
503
+ ZComponentHelper.registerComponent(this);
504
+ }
505
505
  this.componentService.setComponentAdditionalProperties(this);
506
506
  this.componentService.setCompStylesByIndex(this);
507
507
  this.data.ComponentStyleType = this.data.ComponentStyleType || "style1";
@@ -5565,6 +5565,12 @@ class InputFieldBase extends FieldBase {
5565
5565
  setAddOnValue(addOns) {
5566
5566
  this.triggerContainerEvent.emit({ type: 'setAddOnValue', data: addOns });
5567
5567
  }
5568
+ setMinValue(newValue) {
5569
+ this.triggerContainerEvent.emit({ type: 'setMinValue', newValue: newValue });
5570
+ }
5571
+ setMaxValue(newValue) {
5572
+ this.triggerContainerEvent.emit({ type: 'setMaxValue', newValue: newValue });
5573
+ }
5568
5574
  triggerEvent(type, target, event, fieldValue) {
5569
5575
  if (target) {
5570
5576
  this.group.subject.next({
@@ -7457,10 +7463,12 @@ class ZnumericComponent extends InputFieldBase {
7457
7463
  }
7458
7464
  ngOnInit() {
7459
7465
  super.setupInnerField();
7460
- this.minValue = this.data.MinValue;
7461
- this.maxValue = this.data.MaxValue;
7466
+ this.setInitMinAndMaxValue();
7462
7467
  super.focusOnDefault(this.focus.bind(this));
7463
7468
  }
7469
+ ngOnDestroy() {
7470
+ this.removeMinAndMaxValidator();
7471
+ }
7464
7472
  ngAfterViewInit() {
7465
7473
  this.componentService.decrementComponentCounterForField(this.data);
7466
7474
  }
@@ -7483,6 +7491,50 @@ class ZnumericComponent extends InputFieldBase {
7483
7491
  }
7484
7492
  return false;
7485
7493
  }
7494
+ setInitMinAndMaxValue() {
7495
+ if (typeof this.data.MinValue == 'string' && this.data.MinValue.toString().startsWith('group.')) {
7496
+ this.minValue = ZComponentHelper.getGroupValue(this.data.MinValue.toString(), this.group);
7497
+ }
7498
+ else {
7499
+ this.minValue = this.data.MinValue;
7500
+ }
7501
+ if (typeof this.data.MaxValue == 'string' && this.data.MaxValue.toString().startsWith('group.')) {
7502
+ this.maxValue = ZComponentHelper.getGroupValue(this.data.MaxValue.toString(), this.group);
7503
+ }
7504
+ else {
7505
+ this.maxValue = this.data.MaxValue;
7506
+ }
7507
+ this.addMinAndMaxValidator();
7508
+ }
7509
+ addMinAndMaxValidator() {
7510
+ // Setup form validator for ionic components only (Kendo component will be auto setup)
7511
+ if (this.isMobileScreen()) {
7512
+ const control = this.form.controls[this.data.Value];
7513
+ if (this.minValue != undefined) {
7514
+ this.minValidator = Validators.min(Number(this.minValue));
7515
+ control.addValidators(this.minValidator);
7516
+ }
7517
+ if (this.maxValue != undefined) {
7518
+ this.maxValidator = Validators.max(Number(this.maxValue));
7519
+ control.addValidators(this.maxValidator);
7520
+ }
7521
+ control.updateValueAndValidity();
7522
+ }
7523
+ }
7524
+ removeMinAndMaxValidator() {
7525
+ this.minValue = null;
7526
+ this.maxValue = null;
7527
+ const control = this.form.controls[this.data.Value];
7528
+ if (this.isMobileScreen()) {
7529
+ if (control.hasValidator(this.minValidator)) {
7530
+ control.removeValidators(this.minValidator);
7531
+ }
7532
+ if (control.hasValidator(this.maxValidator)) {
7533
+ control.removeValidators(this.maxValidator);
7534
+ }
7535
+ }
7536
+ control.updateValueAndValidity();
7537
+ }
7486
7538
  }
7487
7539
  ZnumericComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: ZnumericComponent, deps: [{ token: ZComponentService }], target: i0.ɵɵFactoryTarget.Component });
7488
7540
  ZnumericComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.4.0", type: ZnumericComponent, selector: "app-znumeric", viewQueries: [{ propertyName: "numeric", first: true, predicate: ["numeric"], descendants: true }], usesInheritance: true, ngImport: i0, template: "<div [formGroup]=\"form\" class=\"znumeric-container e1tag-style\" [style]=\"componentProperties.style.style\">\r\n <ion-input *ngIf=\"isMobileScreen()\" #znumericField [id]=\"data.Value\" type=\"number\"\r\n [autocorrect]=\"data.AutoCorrect ? 'on' : 'off'\"\r\n [min]=\"minValue\"\r\n [max]=\"maxValue\"\r\n [step]=\"data.StepValue\"\r\n [inputmode]=\"inputMode\"\r\n [formControlName]=\"data.Value\"\r\n [attr.disabled]=\"(!!componentProperties.isReadOnlyField ? group[componentProperties.isReadOnlyField] : componentProperties.isReadOnly)\"\r\n [placeholder]=\"data.PlaceHolder\"\r\n [value]=\"0 | znumeric : form : data\"\r\n [class.left-aligned]=\"this.data.RightAlign === false\"\r\n [style]=\"componentProperties.style.style1\" class=\"e1tag-style1\">\r\n </ion-input>\r\n <kendo-numerictextbox *ngIf=\"!isMobileScreen()\"\r\n [spinners]=\"data.ShowSpinners\"\r\n [autoCorrect]=\"data.AutoCorrect\"\r\n [formControlName]=\"data.Value\"\r\n [class.disabled]=\"(!!componentProperties.isReadOnlyField ? group[componentProperties.isReadOnlyField] : componentProperties.isReadOnly)\"\r\n [readonly]=\"(!!componentProperties.isReadOnlyField ? group[componentProperties.isReadOnlyField] : componentProperties.isReadOnly)\"\r\n [min]=\"minValue\"\r\n [max]=\"maxValue\"\r\n [step]=\"data.StepValue\"\r\n [format]=\"data.FormatOptions\" [id]=\"data.Value\"\r\n [placeholder]=\"data.PlaceHolder\"\r\n class=\"input-field e1tag-style1\"\r\n [value]=\"0 | znumeric : form : data\"\r\n (valueChange)=\"onChange(null, $event)\"\r\n [style]=\"componentProperties.style.style1\"\r\n [decimals]=\"data.DecimalPlace\"\r\n [class.left-aligned]=\"this.data.RightAlign === false\"\r\n #numeric>\r\n </kendo-numerictextbox>\r\n</div>\r\n", styles: [":host ::ng-deep kendo-numerictextbox:focus-within{box-shadow:0 0 3px 1px var(--ion-color-primary)}:host ::ng-deep kendo-numerictextbox>input{text-align:right}:host ::ng-deep kendo-numerictextbox.left-aligned>input{text-align:left}.item.sc-ion-label-md-h,.item .sc-ion-label-md-h{font-weight:var(--z-label-weight);color:var(--z-label-color);text-shadow:var(--z-label-shadow)}.k-numerictextbox{color:var(--z-text-color)}\n"], components: [{ type: i2$1.IonInput, selector: "ion-input", inputs: ["accept", "autocapitalize", "autocomplete", "autocorrect", "autofocus", "clearInput", "clearOnEdit", "color", "debounce", "disabled", "enterkeyhint", "inputmode", "max", "maxlength", "min", "minlength", "mode", "multiple", "name", "pattern", "placeholder", "readonly", "required", "size", "spellcheck", "step", "type", "value"] }, { type: i3$4.NumericTextBoxComponent, selector: "kendo-numerictextbox", inputs: ["focusableId", "disabled", "readonly", "title", "autoCorrect", "format", "max", "min", "decimals", "placeholder", "step", "spinners", "rangeValidation", "tabindex", "tabIndex", "changeValueOnScroll", "selectOnFocus", "value", "maxlength", "size", "rounded", "fillMode"], outputs: ["valueChange", "focus", "blur"], exportAs: ["kendoNumericTextBox"] }], directives: [{ type: i4$1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i4$1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i5$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2$1.NumericValueAccessor, selector: "ion-input[type=number]" }, { type: i4$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i4$1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }], pipes: { "znumeric": ZNumericParser } });
@@ -8118,7 +8170,7 @@ class ZInputContainerComponent extends FieldBase {
8118
8170
  this.ztexteditor_type = ['ztexteditor'];
8119
8171
  }
8120
8172
  ngOnInit() {
8121
- super.initComponent().pipe(tap(() => {
8173
+ super.initComponent({ isRegisterComponent: false }).pipe(tap(() => {
8122
8174
  this.setAddOnValue();
8123
8175
  this.componentService.setEditMode(this);
8124
8176
  this.data.zlayout = this.data.zlayout || (this.containerField ? this.containerField.zlayout : "row");