mmhglobal-dynamicform 2.6.4 → 2.7.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.
@@ -1,14 +1,15 @@
1
1
  import { __awaiter } from 'tslib';
2
2
  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
+ import { HttpParams, HttpEventType } from '@angular/common/http';
4
5
  import * as i2$2 from '@angular/router';
5
6
  import { NavigationStart, NavigationEnd, NavigationError, RouterModule } from '@angular/router';
6
7
  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';
7
8
  import { map, tap as tap$1, switchMap as switchMap$1, delay, take, filter, concatMap, ignoreElements } from 'rxjs/operators';
8
- import * as i2 from 'mmhglobal-zcore';
9
- import { ZComponentHelper, ZComponentProperties, FieldType, ComponentType as ComponentType$1, ZGroup, MESSAGETYPE, DefaultMessage, DefaultDialogTitle, ZSelectPostApiParams, UploadMetaData, DefaultPageSettingParams, ZCoreModule } from 'mmhglobal-zcore';
10
9
  import * as i1$1 from '@progress/kendo-angular-dialog';
11
10
  import { DialogContentBase } from '@progress/kendo-angular-dialog';
11
+ import * as i2 from 'mmhglobal-zcore';
12
+ import { ZComponentHelper, ZComponentProperties, FieldType, ComponentType as ComponentType$1, ZGroup, MESSAGETYPE, DefaultMessage, DefaultDialogTitle, ZSelectPostApiParams, UploadMetaData, DefaultPageSettingParams, ZCoreModule } from 'mmhglobal-zcore';
12
13
  import * as i4 from 'mmhglobal-zmodal';
13
14
  import { ZmodalHelper, MmhglobalZmodalModule, ModalService } from 'mmhglobal-zmodal';
14
15
  import * as i2$1 from '@ionic/angular';
@@ -20,7 +21,6 @@ import { Validators, FormGroup, FormControl, FormsModule, ReactiveFormsModule }
20
21
  import * as i1 from 'mmhglobal-middleware';
21
22
  import * as i5$1 from '@angular/common';
22
23
  import { formatDate, CommonModule } from '@angular/common';
23
- import { HttpParams, HttpEventType } from '@angular/common/http';
24
24
  import * as i7 from '@angular/flex-layout/extended';
25
25
  import * as i7$1 from '@progress/kendo-angular-grid';
26
26
  import { DataBindingDirective, GridComponent, BaseFilterCellComponent, ExcelModule, GridModule } from '@progress/kendo-angular-grid';
@@ -1936,11 +1936,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImpor
1936
1936
  type: Input
1937
1937
  }] } });
1938
1938
 
1939
+ // import { ModalService } from '../zmodal/modal.service';
1939
1940
  // import { ZmodalPage } from '../zmodal/zmodal.page';
1940
1941
  // import { ZComponentHelper, ZComponentOutputEvent, ModalPageParams, ZGrid } from '../dynamicform/zcomponent.model';
1941
1942
  // import { ZGroup, ZField } from '../model/zgroup.model';
1942
1943
  class MainService {
1943
- constructor(router, activatedRoute, modalCtrl, navController, alertService, cacheService, fieldService, resourceApiService, componentErrorHandler, webApiService, zcoreService, modalService, storageService, debugService, translationService) {
1944
+ constructor(router, activatedRoute, modalCtrl, navController, alertService, cacheService, fieldService, resourceApiService, componentErrorHandler, webApiService, zcoreService, modalService, storageService, debugService, translationService, signalr, dialogService, oauth2Service) {
1944
1945
  this.router = router;
1945
1946
  this.activatedRoute = activatedRoute;
1946
1947
  this.modalCtrl = modalCtrl;
@@ -1956,6 +1957,9 @@ class MainService {
1956
1957
  this.storageService = storageService;
1957
1958
  this.debugService = debugService;
1958
1959
  this.translationService = translationService;
1960
+ this.signalr = signalr;
1961
+ this.dialogService = dialogService;
1962
+ this.oauth2Service = oauth2Service;
1959
1963
  this.backNavigationPath = [];
1960
1964
  this.routeParam = [];
1961
1965
  this.NAVIGATION_PARAMS_STORAGE_KEY = 'routeParam';
@@ -1964,6 +1968,16 @@ class MainService {
1964
1968
  this.NAVIGATED_RELOAD_GRID_STORAGE_KEY = 'navigatedReloadGrid';
1965
1969
  this.CLONE_NEW_MODEL_CACHE_KEY = 'cloneNewModel';
1966
1970
  this.secretKey = 'my-secret-key';
1971
+ //#region for signalR alert
1972
+ this.getListFieldName = (fieldName) => {
1973
+ const params = new HttpParams().set("name", fieldName);
1974
+ 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));
1975
+ };
1976
+ this.clearFormListFields = () => {
1977
+ this.fieldService.dataFormFields = {};
1978
+ this.fieldService.dataListFields = {};
1979
+ this.fieldService.dataListFieldItems = {};
1980
+ };
1967
1981
  console.log('MainService constructor');
1968
1982
  this.environment = this.zcoreService.getEnvironment();
1969
1983
  this.oauthEnvironmentUrl = this.environment.e1OauthUrl + '/';
@@ -1973,10 +1987,7 @@ class MainService {
1973
1987
  console.log(event);
1974
1988
  // Reset the routeParam,backNavigationPath and related sessionStorage current page is startup page
1975
1989
  if (this.getStartupPage() === event.url) {
1976
- this.routeParam = [];
1977
- this.backNavigationPath = [];
1978
- this.storageService.set(this.NAVIGATION_PARAMS_STORAGE_KEY, JSON.stringify(this.routeParam));
1979
- this.storageService.set(this.BACK_NAVIGATION_PATH_STORAGE_KEY, JSON.stringify(this.backNavigationPath));
1990
+ this.resetRouteParam();
1980
1991
  }
1981
1992
  }
1982
1993
  if (event instanceof NavigationEnd) {
@@ -1991,6 +2002,13 @@ class MainService {
1991
2002
  }
1992
2003
  });
1993
2004
  }
2005
+ signalrGetEvent() {
2006
+ return this.signalr.getEvent();
2007
+ }
2008
+ dialogOpen(options) {
2009
+ return this.dialogService.open(options);
2010
+ }
2011
+ //#endregion
1994
2012
  startUp() {
1995
2013
  console.log('At main.service (StartUp) ...');
1996
2014
  }
@@ -2293,6 +2311,19 @@ class MainService {
2293
2311
  }
2294
2312
  return false;
2295
2313
  }
2314
+ navigateFromMenu(pageName) {
2315
+ const { startUpPage } = this.environment;
2316
+ this.setRouteParam([`${startUpPage}`]);
2317
+ this.backNavigationPath.push(this.getStartupPage());
2318
+ this.storageService.set(this.BACK_NAVIGATION_PATH_STORAGE_KEY, JSON.stringify([this.getStartupPage()]));
2319
+ this.router.navigate([pageName], { replaceUrl: true });
2320
+ }
2321
+ resetRouteParam() {
2322
+ this.routeParam = [];
2323
+ this.backNavigationPath = [];
2324
+ this.storageService.set(this.NAVIGATION_PARAMS_STORAGE_KEY, JSON.stringify(this.routeParam));
2325
+ this.storageService.set(this.BACK_NAVIGATION_PATH_STORAGE_KEY, JSON.stringify(this.backNavigationPath));
2326
+ }
2296
2327
  getNavigationParams() {
2297
2328
  this.routeParam = this.routeParam || [];
2298
2329
  if (this.routeParam.length === 0) {
@@ -2395,6 +2426,16 @@ class MainService {
2395
2426
  this.tryUpdateGroupTrigger(false);
2396
2427
  const backNavigationPath = JSON.parse(sessionStorage.getItem(this.BACK_NAVIGATION_PATH_STORAGE_KEY));
2397
2428
  const backNavigationURL = group.backNavigationPage || backNavigationPath[backNavigationPath.length - 1];
2429
+ //const backNavigationPathLastValue = backNavigationPath && backNavigationPath.length > 0 ? backNavigationPath[backNavigationPath.length - 1] : null;
2430
+ // if navated by external(prefixed url) when close, direct go to menu/startu page
2431
+ //const invalidSubstrings = ['?l=', '?f=', '?r=', '#'];
2432
+ //const containsAny = (str, substrings) => {
2433
+ // return substrings.some(substring => str.includes(substring));
2434
+ //};
2435
+ //if (containsAny(backNavigationPathLastValue, invalidSubstrings)) {
2436
+ // await this.router.navigateByUrl(this.getStartupPage(), { replaceUrl: true });
2437
+ //}
2438
+ //else {
2398
2439
  if (!backNavigationURL) {
2399
2440
  console.error("Error navigating back to previous page: backNavigationURL is not set.");
2400
2441
  //throw new Error("BackNavigationPath not set.");
@@ -2420,6 +2461,7 @@ class MainService {
2420
2461
  console.error(`Error navigating back to previous page: ${error.message}`);
2421
2462
  //throw error;
2422
2463
  }
2464
+ //}
2423
2465
  });
2424
2466
  }
2425
2467
  getStartupPage() {
@@ -2477,8 +2519,7 @@ class MainService {
2477
2519
  group.isTriggered = false;
2478
2520
  }
2479
2521
  newModel(event, group) {
2480
- of([])
2481
- .pipe(switchMap$1((zmodel) => {
2522
+ of([]).pipe(switchMap$1((zmodel) => {
2482
2523
  console.log("Before new, zModel:", zmodel);
2483
2524
  return this.beforeNewModel(group);
2484
2525
  }), tap$1(() => {
@@ -2543,8 +2584,7 @@ class MainService {
2543
2584
  this.afterNewModel(group);
2544
2585
  }
2545
2586
  }
2546
- }))
2547
- .subscribe();
2587
+ })).subscribe();
2548
2588
  }
2549
2589
  createModel(event, group) {
2550
2590
  const fg = group.form;
@@ -2558,8 +2598,7 @@ class MainService {
2558
2598
  this.componentErrorHandler.showFormGroupErrorMessage(group, fg);
2559
2599
  return;
2560
2600
  }
2561
- of(group.zModel)
2562
- .pipe(switchMap$1((zmodel) => {
2601
+ of(group.zModel).pipe(switchMap$1((zmodel) => {
2563
2602
  console.log("Before create, zModel:", zmodel);
2564
2603
  return this.beforeCreateModel(group);
2565
2604
  }), tap$1(() => {
@@ -2569,9 +2608,7 @@ class MainService {
2569
2608
  }), switchMap$1(() => {
2570
2609
  const newModel = Object.assign({}, group.zModel);
2571
2610
  ZComponentHelper.removeNullFields(newModel);
2572
- return this.webApiService
2573
- .httpPost$(group.resourceURL, newModel)
2574
- .pipe(tap$1((resp) => {
2611
+ return this.webApiService.httpPost$(group.resourceURL, newModel).pipe(tap$1((resp) => {
2575
2612
  createModelres = resp;
2576
2613
  return resp;
2577
2614
  }), tap$1((res) => {
@@ -2602,8 +2639,7 @@ class MainService {
2602
2639
  }
2603
2640
  // console.log("Done updateModel updated zModel:", fg.value);
2604
2641
  // this.toastService.show("Record is created successfully.");
2605
- }))
2606
- .subscribe();
2642
+ })).subscribe();
2607
2643
  }
2608
2644
  updateModel(event, group) {
2609
2645
  this.updateModelObservable(event, group).subscribe();
@@ -2618,14 +2654,12 @@ class MainService {
2618
2654
  }
2619
2655
  return of(false);
2620
2656
  }
2621
- updateAPIObservable = updateAPIObservable || this.webApiService.httpPut$(group.resourceURL + "/" + group.zModel.Id, group.zModel)
2622
- .pipe(tap$1((res) => {
2657
+ updateAPIObservable = updateAPIObservable || this.webApiService.httpPut$(group.resourceURL + "/" + group.zModel.Id, group.zModel, false, event).pipe(tap$1((res) => {
2623
2658
  this.handleSuccess(res, resMessage);
2624
2659
  }
2625
2660
  //this.handleSuccess(res, "Record is updated successfully.")
2626
2661
  ));
2627
- return of(group.zModel)
2628
- .pipe(switchMap$1((zmodel) => {
2662
+ return of(group.zModel).pipe(switchMap$1((zmodel) => {
2629
2663
  console.log("Before update, zModel:", zmodel);
2630
2664
  return this.beforeUpdateModel(group);
2631
2665
  }), tap$1(() => {
@@ -3019,14 +3053,14 @@ class MainService {
3019
3053
  }
3020
3054
  }
3021
3055
  }
3022
- 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 });
3056
+ 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 });
3023
3057
  MainService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: MainService, providedIn: 'root' });
3024
3058
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: MainService, decorators: [{
3025
3059
  type: Injectable,
3026
3060
  args: [{
3027
3061
  providedIn: 'root',
3028
3062
  }]
3029
- }], 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 }]; } });
3063
+ }], 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 }]; } });
3030
3064
  function refreshGrid(group) {
3031
3065
  const zgridControl = group["gridOptions"];
3032
3066
  if (zgridControl) {
@@ -12459,13 +12493,13 @@ class ZudfComponent extends ContainerFieldBase {
12459
12493
  }
12460
12494
  /**
12461
12495
  * Validates a form and returns its ZModel if it is valid.
12462
- *
12496
+ * @param skipRemoveMvgFieldValue Whether to skip removing the values of mvg fields from the zModel object.
12463
12497
  * @returns The form's ZModel if it is valid, or undefined otherwise.
12464
12498
  */
12465
- getValidatedFormZModel() {
12499
+ getValidatedFormZModel(skipRemovePrefix, skipRemoveMvgFieldValue) {
12466
12500
  const isValidForm = this.validateAndShowErrorMessage();
12467
12501
  if (isValidForm) {
12468
- return this.getZModel();
12502
+ return this.getZModel(skipRemovePrefix, skipRemoveMvgFieldValue);
12469
12503
  }
12470
12504
  return undefined;
12471
12505
  }