mmhglobal-dynamicform 2.6.5 → 2.7.1
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 +8 -0
- package/esm2020/lib/services/main.service.mjs +60 -25
- package/esm2020/lib/zform/zform.component.mjs +8 -4
- package/esm2020/lib/zudf/zudf.component.mjs +6 -1
- package/fesm2015/mmhglobal-dynamicform.mjs +71 -28
- package/fesm2015/mmhglobal-dynamicform.mjs.map +1 -1
- package/fesm2020/mmhglobal-dynamicform.mjs +71 -28
- package/fesm2020/mmhglobal-dynamicform.mjs.map +1 -1
- package/lib/services/main.service.d.ts +14 -4
- package/lib/zudf/zudf.component.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
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
|
+
import { HttpParams, HttpEventType } from '@angular/common/http';
|
|
3
4
|
import * as i2$2 from '@angular/router';
|
|
4
5
|
import { NavigationStart, NavigationEnd, NavigationError, RouterModule } from '@angular/router';
|
|
5
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
7
|
import { map, tap as tap$1, switchMap as switchMap$1, delay, take, filter, concatMap, ignoreElements } from 'rxjs/operators';
|
|
7
|
-
import * as i2 from 'mmhglobal-zcore';
|
|
8
|
-
import { ZComponentHelper, ZComponentProperties, FieldType, ComponentType as ComponentType$1, ZGroup, MESSAGETYPE, DefaultMessage, DefaultDialogTitle, ZSelectPostApiParams, UploadMetaData, DefaultPageSettingParams, ZCoreModule } from 'mmhglobal-zcore';
|
|
9
8
|
import * as i1$1 from '@progress/kendo-angular-dialog';
|
|
10
9
|
import { DialogContentBase } from '@progress/kendo-angular-dialog';
|
|
10
|
+
import * as i2 from 'mmhglobal-zcore';
|
|
11
|
+
import { ZComponentHelper, ZComponentProperties, FieldType, ComponentType as ComponentType$1, ZGroup, MESSAGETYPE, DefaultMessage, DefaultDialogTitle, ZSelectPostApiParams, UploadMetaData, DefaultPageSettingParams, ZCoreModule } from 'mmhglobal-zcore';
|
|
11
12
|
import * as i4 from 'mmhglobal-zmodal';
|
|
12
13
|
import { ZmodalHelper, MmhglobalZmodalModule, ModalService } from 'mmhglobal-zmodal';
|
|
13
14
|
import * as i2$1 from '@ionic/angular';
|
|
@@ -19,7 +20,6 @@ import { Validators, FormGroup, FormControl, FormsModule, ReactiveFormsModule }
|
|
|
19
20
|
import * as i1 from 'mmhglobal-middleware';
|
|
20
21
|
import * as i5$1 from '@angular/common';
|
|
21
22
|
import { formatDate, CommonModule } from '@angular/common';
|
|
22
|
-
import { HttpParams, HttpEventType } from '@angular/common/http';
|
|
23
23
|
import * as i7 from '@angular/flex-layout/extended';
|
|
24
24
|
import * as i7$1 from '@progress/kendo-angular-grid';
|
|
25
25
|
import { DataBindingDirective, GridComponent, BaseFilterCellComponent, ExcelModule, GridModule } from '@progress/kendo-angular-grid';
|
|
@@ -1611,7 +1611,7 @@ class ZformComponent {
|
|
|
1611
1611
|
console.error('Field Name Duplication: ' + field.Name + '; ', field);
|
|
1612
1612
|
}
|
|
1613
1613
|
}
|
|
1614
|
-
getFormControls(fieldArray, formControls) {
|
|
1614
|
+
getFormControls(fieldArray, formControls, containerIsVisible = true) {
|
|
1615
1615
|
fieldArray.forEach(field => {
|
|
1616
1616
|
if (!field.SubType) {
|
|
1617
1617
|
this.addToFieldIndex(field);
|
|
@@ -1623,13 +1623,17 @@ class ZformComponent {
|
|
|
1623
1623
|
}
|
|
1624
1624
|
else {
|
|
1625
1625
|
if (Array.isArray(field.Value)) {
|
|
1626
|
-
|
|
1626
|
+
const containerIsVisible = ZComponentHelper.isVisibleFormControl(this, field);
|
|
1627
|
+
this.getFormControls(field.Value, formControls, containerIsVisible);
|
|
1627
1628
|
}
|
|
1628
1629
|
else {
|
|
1629
|
-
this.fieldService.incrementComponentCounter(field.FieldElementName);
|
|
1630
1630
|
const isFormControl = ZComponentHelper.isFormControl(field);
|
|
1631
1631
|
const isVisible = ZComponentHelper.isVisibleFormControl(this, field);
|
|
1632
1632
|
const isRequired = ZComponentHelper.isRequiredFormControl(this, field);
|
|
1633
|
+
// if container || control visible == false, dont increase the counter.
|
|
1634
|
+
if (isVisible && containerIsVisible) {
|
|
1635
|
+
this.fieldService.incrementComponentCounter(field.FieldElementName);
|
|
1636
|
+
}
|
|
1633
1637
|
if (isFormControl === true) {
|
|
1634
1638
|
const validators = ZComponentHelper.getValidators(field, isVisible, isRequired);
|
|
1635
1639
|
formControls[field.Value] = new FormControl(this.group.zModel[field.Value], validators);
|
|
@@ -1931,11 +1935,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImpor
|
|
|
1931
1935
|
}] } });
|
|
1932
1936
|
|
|
1933
1937
|
/********** Angular **********/
|
|
1938
|
+
// import { ModalService } from '../zmodal/modal.service';
|
|
1934
1939
|
// import { ZmodalPage } from '../zmodal/zmodal.page';
|
|
1935
1940
|
// import { ZComponentHelper, ZComponentOutputEvent, ModalPageParams, ZGrid } from '../dynamicform/zcomponent.model';
|
|
1936
1941
|
// import { ZGroup, ZField } from '../model/zgroup.model';
|
|
1937
1942
|
class MainService {
|
|
1938
|
-
constructor(router, activatedRoute, modalCtrl, navController, alertService, cacheService, fieldService, resourceApiService, componentErrorHandler, webApiService, zcoreService, modalService, storageService, debugService, translationService) {
|
|
1943
|
+
constructor(router, activatedRoute, modalCtrl, navController, alertService, cacheService, fieldService, resourceApiService, componentErrorHandler, webApiService, zcoreService, modalService, storageService, debugService, translationService, signalr, dialogService, oauth2Service) {
|
|
1939
1944
|
this.router = router;
|
|
1940
1945
|
this.activatedRoute = activatedRoute;
|
|
1941
1946
|
this.modalCtrl = modalCtrl;
|
|
@@ -1951,6 +1956,9 @@ class MainService {
|
|
|
1951
1956
|
this.storageService = storageService;
|
|
1952
1957
|
this.debugService = debugService;
|
|
1953
1958
|
this.translationService = translationService;
|
|
1959
|
+
this.signalr = signalr;
|
|
1960
|
+
this.dialogService = dialogService;
|
|
1961
|
+
this.oauth2Service = oauth2Service;
|
|
1954
1962
|
this.backNavigationPath = [];
|
|
1955
1963
|
this.routeParam = [];
|
|
1956
1964
|
this.NAVIGATION_PARAMS_STORAGE_KEY = 'routeParam';
|
|
@@ -1959,6 +1967,16 @@ class MainService {
|
|
|
1959
1967
|
this.NAVIGATED_RELOAD_GRID_STORAGE_KEY = 'navigatedReloadGrid';
|
|
1960
1968
|
this.CLONE_NEW_MODEL_CACHE_KEY = 'cloneNewModel';
|
|
1961
1969
|
this.secretKey = 'my-secret-key';
|
|
1970
|
+
//#region for signalR alert
|
|
1971
|
+
this.getListFieldName = (fieldName) => {
|
|
1972
|
+
const params = new HttpParams().set("name", fieldName);
|
|
1973
|
+
return this.oauth2Service.httpGet$(this.fieldService.downloadListFieldUrl, params).pipe(map(res => res.FieldElementMasterId), switchMap$1(id => this.oauth2Service.httpGet$(this.fieldService.downloadFormFieldUrl, { id })), map(res => res.Name));
|
|
1974
|
+
};
|
|
1975
|
+
this.clearFormListFields = () => {
|
|
1976
|
+
this.fieldService.dataFormFields = {};
|
|
1977
|
+
this.fieldService.dataListFields = {};
|
|
1978
|
+
this.fieldService.dataListFieldItems = {};
|
|
1979
|
+
};
|
|
1962
1980
|
console.log('MainService constructor');
|
|
1963
1981
|
this.environment = this.zcoreService.getEnvironment();
|
|
1964
1982
|
this.oauthEnvironmentUrl = this.environment.e1OauthUrl + '/';
|
|
@@ -1968,10 +1986,7 @@ class MainService {
|
|
|
1968
1986
|
console.log(event);
|
|
1969
1987
|
// Reset the routeParam,backNavigationPath and related sessionStorage current page is startup page
|
|
1970
1988
|
if (this.getStartupPage() === event.url) {
|
|
1971
|
-
this.
|
|
1972
|
-
this.backNavigationPath = [];
|
|
1973
|
-
this.storageService.set(this.NAVIGATION_PARAMS_STORAGE_KEY, JSON.stringify(this.routeParam));
|
|
1974
|
-
this.storageService.set(this.BACK_NAVIGATION_PATH_STORAGE_KEY, JSON.stringify(this.backNavigationPath));
|
|
1989
|
+
this.resetRouteParam();
|
|
1975
1990
|
}
|
|
1976
1991
|
}
|
|
1977
1992
|
if (event instanceof NavigationEnd) {
|
|
@@ -1986,6 +2001,13 @@ class MainService {
|
|
|
1986
2001
|
}
|
|
1987
2002
|
});
|
|
1988
2003
|
}
|
|
2004
|
+
signalrGetEvent() {
|
|
2005
|
+
return this.signalr.getEvent();
|
|
2006
|
+
}
|
|
2007
|
+
dialogOpen(options) {
|
|
2008
|
+
return this.dialogService.open(options);
|
|
2009
|
+
}
|
|
2010
|
+
//#endregion
|
|
1989
2011
|
startUp() {
|
|
1990
2012
|
console.log('At main.service (StartUp) ...');
|
|
1991
2013
|
}
|
|
@@ -2287,6 +2309,19 @@ class MainService {
|
|
|
2287
2309
|
}
|
|
2288
2310
|
return false;
|
|
2289
2311
|
}
|
|
2312
|
+
navigateFromMenu(pageName) {
|
|
2313
|
+
const { startUpPage } = this.environment;
|
|
2314
|
+
this.setRouteParam([`${startUpPage}`]);
|
|
2315
|
+
this.backNavigationPath.push(this.getStartupPage());
|
|
2316
|
+
this.storageService.set(this.BACK_NAVIGATION_PATH_STORAGE_KEY, JSON.stringify([this.getStartupPage()]));
|
|
2317
|
+
this.router.navigate([pageName], { replaceUrl: true });
|
|
2318
|
+
}
|
|
2319
|
+
resetRouteParam() {
|
|
2320
|
+
this.routeParam = [];
|
|
2321
|
+
this.backNavigationPath = [];
|
|
2322
|
+
this.storageService.set(this.NAVIGATION_PARAMS_STORAGE_KEY, JSON.stringify(this.routeParam));
|
|
2323
|
+
this.storageService.set(this.BACK_NAVIGATION_PATH_STORAGE_KEY, JSON.stringify(this.backNavigationPath));
|
|
2324
|
+
}
|
|
2290
2325
|
getNavigationParams() {
|
|
2291
2326
|
this.routeParam = this.routeParam || [];
|
|
2292
2327
|
if (this.routeParam.length === 0) {
|
|
@@ -2388,6 +2423,16 @@ class MainService {
|
|
|
2388
2423
|
this.tryUpdateGroupTrigger(false);
|
|
2389
2424
|
const backNavigationPath = JSON.parse(sessionStorage.getItem(this.BACK_NAVIGATION_PATH_STORAGE_KEY));
|
|
2390
2425
|
const backNavigationURL = group.backNavigationPage || backNavigationPath[backNavigationPath.length - 1];
|
|
2426
|
+
//const backNavigationPathLastValue = backNavigationPath && backNavigationPath.length > 0 ? backNavigationPath[backNavigationPath.length - 1] : null;
|
|
2427
|
+
// if navated by external(prefixed url) when close, direct go to menu/startu page
|
|
2428
|
+
//const invalidSubstrings = ['?l=', '?f=', '?r=', '#'];
|
|
2429
|
+
//const containsAny = (str, substrings) => {
|
|
2430
|
+
// return substrings.some(substring => str.includes(substring));
|
|
2431
|
+
//};
|
|
2432
|
+
//if (containsAny(backNavigationPathLastValue, invalidSubstrings)) {
|
|
2433
|
+
// await this.router.navigateByUrl(this.getStartupPage(), { replaceUrl: true });
|
|
2434
|
+
//}
|
|
2435
|
+
//else {
|
|
2391
2436
|
if (!backNavigationURL) {
|
|
2392
2437
|
console.error("Error navigating back to previous page: backNavigationURL is not set.");
|
|
2393
2438
|
//throw new Error("BackNavigationPath not set.");
|
|
@@ -2413,6 +2458,7 @@ class MainService {
|
|
|
2413
2458
|
console.error(`Error navigating back to previous page: ${error.message}`);
|
|
2414
2459
|
//throw error;
|
|
2415
2460
|
}
|
|
2461
|
+
//}
|
|
2416
2462
|
}
|
|
2417
2463
|
getStartupPage() {
|
|
2418
2464
|
const { startUpPage } = this.environment;
|
|
@@ -2469,8 +2515,7 @@ class MainService {
|
|
|
2469
2515
|
group.isTriggered = false;
|
|
2470
2516
|
}
|
|
2471
2517
|
newModel(event, group) {
|
|
2472
|
-
of([])
|
|
2473
|
-
.pipe(switchMap$1((zmodel) => {
|
|
2518
|
+
of([]).pipe(switchMap$1((zmodel) => {
|
|
2474
2519
|
console.log("Before new, zModel:", zmodel);
|
|
2475
2520
|
return this.beforeNewModel(group);
|
|
2476
2521
|
}), tap$1(() => {
|
|
@@ -2535,8 +2580,7 @@ class MainService {
|
|
|
2535
2580
|
this.afterNewModel(group);
|
|
2536
2581
|
}
|
|
2537
2582
|
}
|
|
2538
|
-
}))
|
|
2539
|
-
.subscribe();
|
|
2583
|
+
})).subscribe();
|
|
2540
2584
|
}
|
|
2541
2585
|
createModel(event, group) {
|
|
2542
2586
|
const fg = group.form;
|
|
@@ -2550,8 +2594,7 @@ class MainService {
|
|
|
2550
2594
|
this.componentErrorHandler.showFormGroupErrorMessage(group, fg);
|
|
2551
2595
|
return;
|
|
2552
2596
|
}
|
|
2553
|
-
of(group.zModel)
|
|
2554
|
-
.pipe(switchMap$1((zmodel) => {
|
|
2597
|
+
of(group.zModel).pipe(switchMap$1((zmodel) => {
|
|
2555
2598
|
console.log("Before create, zModel:", zmodel);
|
|
2556
2599
|
return this.beforeCreateModel(group);
|
|
2557
2600
|
}), tap$1(() => {
|
|
@@ -2561,9 +2604,7 @@ class MainService {
|
|
|
2561
2604
|
}), switchMap$1(() => {
|
|
2562
2605
|
const newModel = Object.assign({}, group.zModel);
|
|
2563
2606
|
ZComponentHelper.removeNullFields(newModel);
|
|
2564
|
-
return this.webApiService
|
|
2565
|
-
.httpPost$(group.resourceURL, newModel)
|
|
2566
|
-
.pipe(tap$1((resp) => {
|
|
2607
|
+
return this.webApiService.httpPost$(group.resourceURL, newModel).pipe(tap$1((resp) => {
|
|
2567
2608
|
createModelres = resp;
|
|
2568
2609
|
return resp;
|
|
2569
2610
|
}), tap$1((res) => {
|
|
@@ -2594,8 +2635,7 @@ class MainService {
|
|
|
2594
2635
|
}
|
|
2595
2636
|
// console.log("Done updateModel updated zModel:", fg.value);
|
|
2596
2637
|
// this.toastService.show("Record is created successfully.");
|
|
2597
|
-
}))
|
|
2598
|
-
.subscribe();
|
|
2638
|
+
})).subscribe();
|
|
2599
2639
|
}
|
|
2600
2640
|
updateModel(event, group) {
|
|
2601
2641
|
this.updateModelObservable(event, group).subscribe();
|
|
@@ -2610,14 +2650,12 @@ class MainService {
|
|
|
2610
2650
|
}
|
|
2611
2651
|
return of(false);
|
|
2612
2652
|
}
|
|
2613
|
-
updateAPIObservable = updateAPIObservable || this.webApiService.httpPut$(group.resourceURL + "/" + group.zModel.Id, group.zModel)
|
|
2614
|
-
.pipe(tap$1((res) => {
|
|
2653
|
+
updateAPIObservable = updateAPIObservable || this.webApiService.httpPut$(group.resourceURL + "/" + group.zModel.Id, group.zModel, false).pipe(tap$1((res) => {
|
|
2615
2654
|
this.handleSuccess(res, resMessage);
|
|
2616
2655
|
}
|
|
2617
2656
|
//this.handleSuccess(res, "Record is updated successfully.")
|
|
2618
2657
|
));
|
|
2619
|
-
return of(group.zModel)
|
|
2620
|
-
.pipe(switchMap$1((zmodel) => {
|
|
2658
|
+
return of(group.zModel).pipe(switchMap$1((zmodel) => {
|
|
2621
2659
|
console.log("Before update, zModel:", zmodel);
|
|
2622
2660
|
return this.beforeUpdateModel(group);
|
|
2623
2661
|
}), tap$1(() => {
|
|
@@ -3002,14 +3040,14 @@ class MainService {
|
|
|
3002
3040
|
}
|
|
3003
3041
|
}
|
|
3004
3042
|
}
|
|
3005
|
-
MainService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: MainService, deps: [{ token: i2$2.Router }, { token: i2$2.ActivatedRoute }, { token: i2$1.ModalController }, { token: i2$1.NavController }, { token: i2.AlertService }, { token: i2.CacheService }, { token: i2.FieldService }, { token: i2.ResourceApiService }, { token: ComponentErrorHandlerService }, { token: i2.WebApiService }, { token: i2.ZCoreService }, { token: i4.ModalService }, { token: i2.StorageSessionService }, { token: ZComponentDebugService }, { token: i2.TranslationService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
3043
|
+
MainService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: MainService, deps: [{ token: i2$2.Router }, { token: i2$2.ActivatedRoute }, { token: i2$1.ModalController }, { token: i2$1.NavController }, { token: i2.AlertService }, { token: i2.CacheService }, { token: i2.FieldService }, { token: i2.ResourceApiService }, { token: ComponentErrorHandlerService }, { token: i2.WebApiService }, { token: i2.ZCoreService }, { token: i4.ModalService }, { token: i2.StorageSessionService }, { token: ZComponentDebugService }, { token: i2.TranslationService }, { token: i2.SignalrService }, { token: i1$1.DialogService }, { token: i2.OAuth2Service }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
3006
3044
|
MainService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: MainService, providedIn: 'root' });
|
|
3007
3045
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: MainService, decorators: [{
|
|
3008
3046
|
type: Injectable,
|
|
3009
3047
|
args: [{
|
|
3010
3048
|
providedIn: 'root',
|
|
3011
3049
|
}]
|
|
3012
|
-
}], ctorParameters: function () { return [{ type: i2$2.Router }, { type: i2$2.ActivatedRoute }, { type: i2$1.ModalController }, { type: i2$1.NavController }, { type: i2.AlertService }, { type: i2.CacheService }, { type: i2.FieldService }, { type: i2.ResourceApiService }, { type: ComponentErrorHandlerService }, { type: i2.WebApiService }, { type: i2.ZCoreService }, { type: i4.ModalService }, { type: i2.StorageSessionService }, { type: ZComponentDebugService }, { type: i2.TranslationService }]; } });
|
|
3050
|
+
}], ctorParameters: function () { return [{ type: i2$2.Router }, { type: i2$2.ActivatedRoute }, { type: i2$1.ModalController }, { type: i2$1.NavController }, { type: i2.AlertService }, { type: i2.CacheService }, { type: i2.FieldService }, { type: i2.ResourceApiService }, { type: ComponentErrorHandlerService }, { type: i2.WebApiService }, { type: i2.ZCoreService }, { type: i4.ModalService }, { type: i2.StorageSessionService }, { type: ZComponentDebugService }, { type: i2.TranslationService }, { type: i2.SignalrService }, { type: i1$1.DialogService }, { type: i2.OAuth2Service }]; } });
|
|
3013
3051
|
function refreshGrid(group) {
|
|
3014
3052
|
const zgridControl = group["gridOptions"];
|
|
3015
3053
|
if (zgridControl) {
|
|
@@ -11713,6 +11751,11 @@ class ZudfComponent extends ContainerFieldBase {
|
|
|
11713
11751
|
this.isLoading = false;
|
|
11714
11752
|
})).subscribe();
|
|
11715
11753
|
}
|
|
11754
|
+
ngOnDestroy() {
|
|
11755
|
+
if (this.subscription) {
|
|
11756
|
+
this.subscription.unsubscribe();
|
|
11757
|
+
}
|
|
11758
|
+
}
|
|
11716
11759
|
/**
|
|
11717
11760
|
* Renders the field element and sets up the form.
|
|
11718
11761
|
*/
|