mmhglobal-dynamicform 2.1.1 → 2.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/README.md +6 -0
- package/esm2020/lib/services/zcomponent.service.mjs +19 -2
- package/esm2020/lib/zselectmultiple/zselectmultiple.component.mjs +9 -3
- package/esm2020/lib/zudf/zudf.component.mjs +39 -10
- package/fesm2015/mmhglobal-dynamicform.mjs +62 -9
- package/fesm2015/mmhglobal-dynamicform.mjs.map +1 -1
- package/fesm2020/mmhglobal-dynamicform.mjs +61 -9
- package/fesm2020/mmhglobal-dynamicform.mjs.map +1 -1
- package/lib/services/zcomponent.service.d.ts +5 -0
- package/lib/zselectmultiple/zselectmultiple.component.d.ts +3 -1
- package/lib/zudf/zudf.component.d.ts +2 -1
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@ import * as i0 from '@angular/core';
|
|
|
2
2
|
import { Injectable, Component, Input, Directive, ViewChild, Inject, HostListener, Pipe, ViewContainerRef, TemplateRef, EventEmitter, Output, NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
|
3
3
|
import * as i1$1 from '@angular/router';
|
|
4
4
|
import { NavigationStart, NavigationEnd, NavigationError, RouterModule } from '@angular/router';
|
|
5
|
-
import { of, switchMap, forkJoin, tap,
|
|
5
|
+
import { of, switchMap, forkJoin, tap, Subject, BehaviorSubject, map as map$1, isObservable, interval, takeWhile, from, delay as delay$1, filter as filter$1, first } from 'rxjs';
|
|
6
6
|
import { map, tap as tap$1, switchMap as switchMap$1, delay, take, filter, concatMap } from 'rxjs/operators';
|
|
7
7
|
import * as i2 from 'mmhglobal-zcore';
|
|
8
8
|
import { ZComponentHelper, ZComponentProperties, ZGroup, MESSAGETYPE, ZSelectPostApiParams, UploadMetaData, DefaultPageSettingParams, ZCoreModule } from 'mmhglobal-zcore';
|
|
@@ -204,6 +204,8 @@ class ZComponentService {
|
|
|
204
204
|
this.componentObjectService = componentObjectService;
|
|
205
205
|
this.translateService = translateService;
|
|
206
206
|
this.zcoreService = zcoreService;
|
|
207
|
+
this.componentCounter = 0;
|
|
208
|
+
this.componentLoadSubject = new Subject();
|
|
207
209
|
this.DEFAULT_ISEDIT = true;
|
|
208
210
|
//#region DateTime Conversion
|
|
209
211
|
this.timePickerDateType = ['zuidatetime', 'ztime', 'zuitime'];
|
|
@@ -440,6 +442,21 @@ class ZComponentService {
|
|
|
440
442
|
const result = `${(Math.abs(num) / 60).toString().padStart(2, '0')}:00`;
|
|
441
443
|
return `${prefix}${result}`;
|
|
442
444
|
}
|
|
445
|
+
//#endregion
|
|
446
|
+
//#region track component loaded
|
|
447
|
+
get componentLoaded$() {
|
|
448
|
+
return this.componentLoadSubject.asObservable();
|
|
449
|
+
}
|
|
450
|
+
incrementComponentCounter() {
|
|
451
|
+
this.componentCounter++;
|
|
452
|
+
}
|
|
453
|
+
decrementComponentCounter() {
|
|
454
|
+
this.componentCounter--;
|
|
455
|
+
if (this.componentCounter === 0) {
|
|
456
|
+
this.componentLoadSubject.next();
|
|
457
|
+
this.componentLoadSubject.complete();
|
|
458
|
+
}
|
|
459
|
+
}
|
|
443
460
|
}
|
|
444
461
|
ZComponentService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: ZComponentService, deps: [{ token: i1.ComponentObjectService }, { token: i2.TranslationService }, { token: i2.ZCoreService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
445
462
|
ZComponentService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: ZComponentService, providedIn: 'root' });
|
|
@@ -6545,11 +6562,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
|
|
|
6545
6562
|
|
|
6546
6563
|
/********** Angular **********/
|
|
6547
6564
|
class ZselectmultipleComponent extends InputFieldBase {
|
|
6548
|
-
constructor(resourceApiService, webApiService, cacheService,
|
|
6549
|
-
super(
|
|
6565
|
+
constructor(resourceApiService, webApiService, cacheService, componentService) {
|
|
6566
|
+
super(componentService);
|
|
6550
6567
|
this.resourceApiService = resourceApiService;
|
|
6551
6568
|
this.webApiService = webApiService;
|
|
6552
6569
|
this.cacheService = cacheService;
|
|
6570
|
+
this.componentService = componentService;
|
|
6553
6571
|
this.items = [];
|
|
6554
6572
|
this.infinitezData = [];
|
|
6555
6573
|
this.infiniteSearchText = null;
|
|
@@ -6690,6 +6708,11 @@ class ZselectmultipleComponent extends InputFieldBase {
|
|
|
6690
6708
|
}
|
|
6691
6709
|
super.focusOnDefault(this.focus.bind(this));
|
|
6692
6710
|
}
|
|
6711
|
+
ngAfterViewInit() {
|
|
6712
|
+
if (this.data.SubType === 'zudf') {
|
|
6713
|
+
this.componentService.decrementComponentCounter();
|
|
6714
|
+
}
|
|
6715
|
+
}
|
|
6693
6716
|
// Auto select first option (if required & only 1 option)
|
|
6694
6717
|
autoSelectFirstOption(required, data, zModelPropertyName, id) {
|
|
6695
6718
|
if (ZComponentHelper.isNullUndefinedEmpty(id) && required) {
|
|
@@ -11491,13 +11514,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
|
|
|
11491
11514
|
|
|
11492
11515
|
/********** Angular **********/
|
|
11493
11516
|
class ZudfComponent extends ContainerFieldBase {
|
|
11494
|
-
constructor(
|
|
11495
|
-
super(
|
|
11517
|
+
constructor(alertService, authService, fieldService, toastService, componentErrorHandlerService, componentService, cdr) {
|
|
11518
|
+
super(componentService);
|
|
11496
11519
|
this.alertService = alertService;
|
|
11497
11520
|
this.authService = authService;
|
|
11498
11521
|
this.fieldService = fieldService;
|
|
11499
11522
|
this.toastService = toastService;
|
|
11500
11523
|
this.componentErrorHandlerService = componentErrorHandlerService;
|
|
11524
|
+
this.componentService = componentService;
|
|
11501
11525
|
this.cdr = cdr;
|
|
11502
11526
|
// formFields: any[]; // populate using field element.
|
|
11503
11527
|
this.componentProperties = new ZComponentProperties();
|
|
@@ -11532,8 +11556,14 @@ class ZudfComponent extends ContainerFieldBase {
|
|
|
11532
11556
|
obs = this.fieldService.getFormFieldCode(fieldName, 'FormField', this, 'fields');
|
|
11533
11557
|
}
|
|
11534
11558
|
super.initComponent().pipe(switchMap$1(() => obs), switchMap$1((field) => {
|
|
11559
|
+
if (this.data.FieldElementCode) {
|
|
11560
|
+
// use obs value only if FieldElementCode is set. if nto default as null.
|
|
11561
|
+
this.data.Value = field;
|
|
11562
|
+
}
|
|
11563
|
+
else {
|
|
11564
|
+
this.data.Value = null;
|
|
11565
|
+
}
|
|
11535
11566
|
// Store initial data value and set component scope and prefix
|
|
11536
|
-
this.data.Value = field;
|
|
11537
11567
|
this.initialDataValue = this.data.Value;
|
|
11538
11568
|
this.componentScopeName = 'zudf_' + this.data.Name;
|
|
11539
11569
|
this.componentPrefix = 'zudf_' + this.data.Name;
|
|
@@ -11706,6 +11736,26 @@ class ZudfComponent extends ContainerFieldBase {
|
|
|
11706
11736
|
this.data.Value = fieldElements;
|
|
11707
11737
|
this.group[this.componentScopeName].form = this.form;
|
|
11708
11738
|
this.group[this.componentScopeName]['loadedFieldsSequence'] = this.loadedFieldsSequence;
|
|
11739
|
+
this.componentService.componentLoaded$.subscribe(() => {
|
|
11740
|
+
// All components have finished loading
|
|
11741
|
+
const zudfGroup = this.group[this.componentScopeName];
|
|
11742
|
+
zudfGroup['linkedComponent'].forEach(item => {
|
|
11743
|
+
const linkedComponentSegments = item.value.split('_');
|
|
11744
|
+
const parentComponentName = linkedComponentSegments.slice(0, -1).join('_') + '_' + item.linkedComponent;
|
|
11745
|
+
const parentComponent = ZComponentHelper.getComponentByValue(this.group, parentComponentName);
|
|
11746
|
+
const childComponent = ZComponentHelper.getComponentByValue(this.group, item.value);
|
|
11747
|
+
if (parentComponent && childComponent) {
|
|
11748
|
+
const originalSelectOptions = childComponent.data['originalSelectOptions'] ?? Object.assign([], childComponent.data.SelectOptions);
|
|
11749
|
+
const filteredSelectionOptions = originalSelectOptions.filter(option => option.parentExpression == zudfGroup.zModel[parentComponentName]);
|
|
11750
|
+
// manually patch the component formcontrol value
|
|
11751
|
+
const zudfForm = zudfGroup.form;
|
|
11752
|
+
const componentFormControl = zudfForm.controls[item.value];
|
|
11753
|
+
childComponent.setSelectOption(filteredSelectionOptions);
|
|
11754
|
+
componentFormControl.patchValue(zudfGroup.zModel[item.value]);
|
|
11755
|
+
}
|
|
11756
|
+
});
|
|
11757
|
+
// To consider: Trigger the "onchange" event or perform any other necessary actions here
|
|
11758
|
+
});
|
|
11709
11759
|
}
|
|
11710
11760
|
}
|
|
11711
11761
|
generateFormControls(fieldArray, formControls, containerName, isMultiValueGroup = false, fieldValueGrouped = false, index = '') {
|
|
@@ -11742,7 +11792,6 @@ class ZudfComponent extends ContainerFieldBase {
|
|
|
11742
11792
|
// this for later on, we can easily know this field belong to which zudf and under which container.
|
|
11743
11793
|
if (containerName) {
|
|
11744
11794
|
field['containerName'] = containerName;
|
|
11745
|
-
;
|
|
11746
11795
|
if (!zudfGroup[containerName]) {
|
|
11747
11796
|
zudfGroup[containerName] = [];
|
|
11748
11797
|
}
|
|
@@ -11754,6 +11803,9 @@ class ZudfComponent extends ContainerFieldBase {
|
|
|
11754
11803
|
if (!this.loadedFieldsSequence) {
|
|
11755
11804
|
this.loadedFieldsSequence = {};
|
|
11756
11805
|
}
|
|
11806
|
+
if (field.Type === 'zuiselectmultiple') {
|
|
11807
|
+
this.componentService.incrementComponentCounter();
|
|
11808
|
+
}
|
|
11757
11809
|
field.Name = this.generateFormControlName(field.Name, containerName);
|
|
11758
11810
|
field.Value = this.generateFormControlName(field.Value, containerName);
|
|
11759
11811
|
this.loadedFieldsSequence[fieldIndex] = {
|
|
@@ -12338,12 +12390,12 @@ class ZudfComponent extends ContainerFieldBase {
|
|
|
12338
12390
|
}
|
|
12339
12391
|
}
|
|
12340
12392
|
}
|
|
12341
|
-
ZudfComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: ZudfComponent, deps: [{ token:
|
|
12393
|
+
ZudfComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: ZudfComponent, deps: [{ token: i2.AlertService }, { token: i2.AuthService }, { token: i2.FieldService }, { token: i2.ToastService }, { token: ComponentErrorHandlerService }, { token: ZComponentService }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
12342
12394
|
ZudfComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.12", type: ZudfComponent, selector: "app-zudf", usesInheritance: true, ngImport: i0, template: "<div style=\"padding: 15px\" *ngIf=\"data.Title && (!!componentProperties.isVisibleField ? group[componentProperties.isVisibleField] : componentProperties.isVisible)\" class=\"zudf-container\">\r\n <kendo-card *ngIf=\"data.Title\">\r\n <kendo-card-header>\r\n <div>\r\n <ion-label class=\"card-header-title\">{{data.Title}}</ion-label>\r\n </div>\r\n </kendo-card-header>\r\n <kendo-card-body>\r\n <!-- <app-zformcontrol [ngClass]=\"group[field.isVisibleField] ? field.DivClass : ((field.Visible === true) ? field.DivClass : 'flex-hide')\"\r\n *ngFor=\"let field of formFields | divzlayout: data.zlayout\"\r\n [field]=\"field\"\r\n [group]=\"group\"\r\n [form]=\"form\"\r\n id=\"{{field.Name}}\">\r\n </app-zformcontrol> -->\r\n <app-zdiv [data]=\"data\" [form]=\"form\" [group]=\"group\" [containerField]=\"containerField\"></app-zdiv>\r\n </kendo-card-body>\r\n </kendo-card>\r\n</div>\r\n\r\n<div *ngIf=\"!data.Title && (!!componentProperties.isVisibleField ? group[componentProperties.isVisibleField] : componentProperties.isVisible)\" [style]=\"data.Style\" class=\"zudf-container\">\r\n <form [formGroup]=\"form\" autocomplete=\"off\" *ngIf=\"!isLoading\">\r\n <!-- <app-zformcontrol [ngClass]=\"group[field.isVisibleField] ? field.DivClass : ((field.Visible === true) ? field.DivClass : 'flex-hide')\"\r\n *ngFor=\"let field of formFields | divzlayout: data.zlayout\"\r\n [field]=\"field\"\r\n [group]=\"group\"\r\n [form]=\"form\"\r\n id=\"{{field.Name}}\">\r\n </app-zformcontrol> -->\r\n <app-zdiv [data]=\"data\" [form]=\"form\" [group]=\"group\" [containerField]=\"containerField\"></app-zdiv>\r\n </form>\r\n</div>\r\n", styles: [".card-header-title{color:#fff!important;font-weight:500;font-size:11pt}.zudf-container{width:100%}\n"], components: [{ type: i3$3.CardComponent, selector: "kendo-card", inputs: ["orientation", "width"] }, { type: i3$3.CardHeaderComponent, selector: "kendo-card-header" }, { type: i2$1.IonLabel, selector: "ion-label", inputs: ["color", "mode", "position"] }, { type: i3$3.CardBodyComponent, selector: "kendo-card-body" }, { type: ZdivComponent, selector: "app-zdiv" }], directives: [{ type: i5$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i4$1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { 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"] }] });
|
|
12343
12395
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: ZudfComponent, decorators: [{
|
|
12344
12396
|
type: Component,
|
|
12345
12397
|
args: [{ selector: 'app-zudf', template: "<div style=\"padding: 15px\" *ngIf=\"data.Title && (!!componentProperties.isVisibleField ? group[componentProperties.isVisibleField] : componentProperties.isVisible)\" class=\"zudf-container\">\r\n <kendo-card *ngIf=\"data.Title\">\r\n <kendo-card-header>\r\n <div>\r\n <ion-label class=\"card-header-title\">{{data.Title}}</ion-label>\r\n </div>\r\n </kendo-card-header>\r\n <kendo-card-body>\r\n <!-- <app-zformcontrol [ngClass]=\"group[field.isVisibleField] ? field.DivClass : ((field.Visible === true) ? field.DivClass : 'flex-hide')\"\r\n *ngFor=\"let field of formFields | divzlayout: data.zlayout\"\r\n [field]=\"field\"\r\n [group]=\"group\"\r\n [form]=\"form\"\r\n id=\"{{field.Name}}\">\r\n </app-zformcontrol> -->\r\n <app-zdiv [data]=\"data\" [form]=\"form\" [group]=\"group\" [containerField]=\"containerField\"></app-zdiv>\r\n </kendo-card-body>\r\n </kendo-card>\r\n</div>\r\n\r\n<div *ngIf=\"!data.Title && (!!componentProperties.isVisibleField ? group[componentProperties.isVisibleField] : componentProperties.isVisible)\" [style]=\"data.Style\" class=\"zudf-container\">\r\n <form [formGroup]=\"form\" autocomplete=\"off\" *ngIf=\"!isLoading\">\r\n <!-- <app-zformcontrol [ngClass]=\"group[field.isVisibleField] ? field.DivClass : ((field.Visible === true) ? field.DivClass : 'flex-hide')\"\r\n *ngFor=\"let field of formFields | divzlayout: data.zlayout\"\r\n [field]=\"field\"\r\n [group]=\"group\"\r\n [form]=\"form\"\r\n id=\"{{field.Name}}\">\r\n </app-zformcontrol> -->\r\n <app-zdiv [data]=\"data\" [form]=\"form\" [group]=\"group\" [containerField]=\"containerField\"></app-zdiv>\r\n </form>\r\n</div>\r\n", styles: [".card-header-title{color:#fff!important;font-weight:500;font-size:11pt}.zudf-container{width:100%}\n"] }]
|
|
12346
|
-
}], ctorParameters: function () { return [{ type:
|
|
12398
|
+
}], ctorParameters: function () { return [{ type: i2.AlertService }, { type: i2.AuthService }, { type: i2.FieldService }, { type: i2.ToastService }, { type: ComponentErrorHandlerService }, { type: ZComponentService }, { type: i0.ChangeDetectorRef }]; } });
|
|
12347
12399
|
var ComponentType;
|
|
12348
12400
|
(function (ComponentType) {
|
|
12349
12401
|
ComponentType["text"] = "text";
|