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.
@@ -3,7 +3,7 @@ import * as i0 from '@angular/core';
3
3
  import { Injectable, Component, Input, Directive, ViewChild, Inject, HostListener, Pipe, ViewContainerRef, TemplateRef, EventEmitter, Output, NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
4
4
  import * as i1$1 from '@angular/router';
5
5
  import { NavigationStart, NavigationEnd, NavigationError, RouterModule } from '@angular/router';
6
- import { of, switchMap, forkJoin, tap, BehaviorSubject, Subject, map as map$1, isObservable, interval, takeWhile, from, delay as delay$1, filter as filter$1, first } from 'rxjs';
6
+ 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';
7
7
  import { map, tap as tap$1, switchMap as switchMap$1, delay, take, filter, concatMap } from 'rxjs/operators';
8
8
  import * as i2 from 'mmhglobal-zcore';
9
9
  import { ZComponentHelper, ZComponentProperties, ZGroup, MESSAGETYPE, ZSelectPostApiParams, UploadMetaData, DefaultPageSettingParams, ZCoreModule } from 'mmhglobal-zcore';
@@ -205,6 +205,8 @@ class ZComponentService {
205
205
  this.componentObjectService = componentObjectService;
206
206
  this.translateService = translateService;
207
207
  this.zcoreService = zcoreService;
208
+ this.componentCounter = 0;
209
+ this.componentLoadSubject = new Subject();
208
210
  this.DEFAULT_ISEDIT = true;
209
211
  //#region DateTime Conversion
210
212
  this.timePickerDateType = ['zuidatetime', 'ztime', 'zuitime'];
@@ -441,6 +443,21 @@ class ZComponentService {
441
443
  const result = `${(Math.abs(num) / 60).toString().padStart(2, '0')}:00`;
442
444
  return `${prefix}${result}`;
443
445
  }
446
+ //#endregion
447
+ //#region track component loaded
448
+ get componentLoaded$() {
449
+ return this.componentLoadSubject.asObservable();
450
+ }
451
+ incrementComponentCounter() {
452
+ this.componentCounter++;
453
+ }
454
+ decrementComponentCounter() {
455
+ this.componentCounter--;
456
+ if (this.componentCounter === 0) {
457
+ this.componentLoadSubject.next();
458
+ this.componentLoadSubject.complete();
459
+ }
460
+ }
444
461
  }
445
462
  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 });
446
463
  ZComponentService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: ZComponentService, providedIn: 'root' });
@@ -6559,11 +6576,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
6559
6576
 
6560
6577
  /********** Angular **********/
6561
6578
  class ZselectmultipleComponent extends InputFieldBase {
6562
- constructor(resourceApiService, webApiService, cacheService, compService) {
6563
- super(compService);
6579
+ constructor(resourceApiService, webApiService, cacheService, componentService) {
6580
+ super(componentService);
6564
6581
  this.resourceApiService = resourceApiService;
6565
6582
  this.webApiService = webApiService;
6566
6583
  this.cacheService = cacheService;
6584
+ this.componentService = componentService;
6567
6585
  this.items = [];
6568
6586
  this.infinitezData = [];
6569
6587
  this.infiniteSearchText = null;
@@ -6704,6 +6722,11 @@ class ZselectmultipleComponent extends InputFieldBase {
6704
6722
  }
6705
6723
  super.focusOnDefault(this.focus.bind(this));
6706
6724
  }
6725
+ ngAfterViewInit() {
6726
+ if (this.data.SubType === 'zudf') {
6727
+ this.componentService.decrementComponentCounter();
6728
+ }
6729
+ }
6707
6730
  // Auto select first option (if required & only 1 option)
6708
6731
  autoSelectFirstOption(required, data, zModelPropertyName, id) {
6709
6732
  if (ZComponentHelper.isNullUndefinedEmpty(id) && required) {
@@ -11510,13 +11533,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
11510
11533
 
11511
11534
  /********** Angular **********/
11512
11535
  class ZudfComponent extends ContainerFieldBase {
11513
- constructor(compService, alertService, authService, fieldService, toastService, componentErrorHandlerService, cdr) {
11514
- super(compService);
11536
+ constructor(alertService, authService, fieldService, toastService, componentErrorHandlerService, componentService, cdr) {
11537
+ super(componentService);
11515
11538
  this.alertService = alertService;
11516
11539
  this.authService = authService;
11517
11540
  this.fieldService = fieldService;
11518
11541
  this.toastService = toastService;
11519
11542
  this.componentErrorHandlerService = componentErrorHandlerService;
11543
+ this.componentService = componentService;
11520
11544
  this.cdr = cdr;
11521
11545
  // formFields: any[]; // populate using field element.
11522
11546
  this.componentProperties = new ZComponentProperties();
@@ -11551,8 +11575,14 @@ class ZudfComponent extends ContainerFieldBase {
11551
11575
  obs = this.fieldService.getFormFieldCode(fieldName, 'FormField', this, 'fields');
11552
11576
  }
11553
11577
  super.initComponent().pipe(switchMap$1(() => obs), switchMap$1((field) => {
11578
+ if (this.data.FieldElementCode) {
11579
+ // use obs value only if FieldElementCode is set. if nto default as null.
11580
+ this.data.Value = field;
11581
+ }
11582
+ else {
11583
+ this.data.Value = null;
11584
+ }
11554
11585
  // Store initial data value and set component scope and prefix
11555
- this.data.Value = field;
11556
11586
  this.initialDataValue = this.data.Value;
11557
11587
  this.componentScopeName = 'zudf_' + this.data.Name;
11558
11588
  this.componentPrefix = 'zudf_' + this.data.Name;
@@ -11726,6 +11756,27 @@ class ZudfComponent extends ContainerFieldBase {
11726
11756
  this.data.Value = fieldElements;
11727
11757
  this.group[this.componentScopeName].form = this.form;
11728
11758
  this.group[this.componentScopeName]['loadedFieldsSequence'] = this.loadedFieldsSequence;
11759
+ this.componentService.componentLoaded$.subscribe(() => {
11760
+ // All components have finished loading
11761
+ const zudfGroup = this.group[this.componentScopeName];
11762
+ zudfGroup['linkedComponent'].forEach(item => {
11763
+ var _a;
11764
+ const linkedComponentSegments = item.value.split('_');
11765
+ const parentComponentName = linkedComponentSegments.slice(0, -1).join('_') + '_' + item.linkedComponent;
11766
+ const parentComponent = ZComponentHelper.getComponentByValue(this.group, parentComponentName);
11767
+ const childComponent = ZComponentHelper.getComponentByValue(this.group, item.value);
11768
+ if (parentComponent && childComponent) {
11769
+ const originalSelectOptions = (_a = childComponent.data['originalSelectOptions']) !== null && _a !== void 0 ? _a : Object.assign([], childComponent.data.SelectOptions);
11770
+ const filteredSelectionOptions = originalSelectOptions.filter(option => option.parentExpression == zudfGroup.zModel[parentComponentName]);
11771
+ // manually patch the component formcontrol value
11772
+ const zudfForm = zudfGroup.form;
11773
+ const componentFormControl = zudfForm.controls[item.value];
11774
+ childComponent.setSelectOption(filteredSelectionOptions);
11775
+ componentFormControl.patchValue(zudfGroup.zModel[item.value]);
11776
+ }
11777
+ });
11778
+ // To consider: Trigger the "onchange" event or perform any other necessary actions here
11779
+ });
11729
11780
  }
11730
11781
  }
11731
11782
  generateFormControls(fieldArray, formControls, containerName, isMultiValueGroup = false, fieldValueGrouped = false, index = '') {
@@ -11763,7 +11814,6 @@ class ZudfComponent extends ContainerFieldBase {
11763
11814
  // this for later on, we can easily know this field belong to which zudf and under which container.
11764
11815
  if (containerName) {
11765
11816
  field['containerName'] = containerName;
11766
- ;
11767
11817
  if (!zudfGroup[containerName]) {
11768
11818
  zudfGroup[containerName] = [];
11769
11819
  }
@@ -11775,6 +11825,9 @@ class ZudfComponent extends ContainerFieldBase {
11775
11825
  if (!this.loadedFieldsSequence) {
11776
11826
  this.loadedFieldsSequence = {};
11777
11827
  }
11828
+ if (field.Type === 'zuiselectmultiple') {
11829
+ this.componentService.incrementComponentCounter();
11830
+ }
11778
11831
  field.Name = this.generateFormControlName(field.Name, containerName);
11779
11832
  field.Value = this.generateFormControlName(field.Value, containerName);
11780
11833
  this.loadedFieldsSequence[fieldIndex] = {
@@ -12360,12 +12413,12 @@ class ZudfComponent extends ContainerFieldBase {
12360
12413
  }
12361
12414
  }
12362
12415
  }
12363
- ZudfComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: ZudfComponent, deps: [{ token: ZComponentService }, { token: i2.AlertService }, { token: i2.AuthService }, { token: i2.FieldService }, { token: i2.ToastService }, { token: ComponentErrorHandlerService }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
12416
+ 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 });
12364
12417
  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"] }] });
12365
12418
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: ZudfComponent, decorators: [{
12366
12419
  type: Component,
12367
12420
  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"] }]
12368
- }], ctorParameters: function () { return [{ type: ZComponentService }, { type: i2.AlertService }, { type: i2.AuthService }, { type: i2.FieldService }, { type: i2.ToastService }, { type: ComponentErrorHandlerService }, { type: i0.ChangeDetectorRef }]; } });
12421
+ }], ctorParameters: function () { return [{ type: i2.AlertService }, { type: i2.AuthService }, { type: i2.FieldService }, { type: i2.ToastService }, { type: ComponentErrorHandlerService }, { type: ZComponentService }, { type: i0.ChangeDetectorRef }]; } });
12369
12422
  var ComponentType;
12370
12423
  (function (ComponentType) {
12371
12424
  ComponentType["text"] = "text";