mmhglobal-dynamicform 2.12.3 → 2.12.4

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.
@@ -1923,7 +1923,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImpor
1923
1923
  // import { ZComponentHelper, ZComponentOutputEvent, ModalPageParams, ZGrid } from '../dynamicform/zcomponent.model';
1924
1924
  // import { ZGroup, ZField } from '../model/zgroup.model';
1925
1925
  class MainService {
1926
- constructor(router, activatedRoute, modalCtrl, navController, alertService, cacheService, fieldService, resourceApiService, componentErrorHandlerService, webApiService, zcoreService, modalService, storageService, debugService, translationService, signalrService, dialogService, oauth2Service, sharepointService, toastService) {
1926
+ constructor(router, activatedRoute, modalCtrl, navController, alertService, cacheService, fieldService, resourceApiService, componentErrorHandlerService, webApiService, zcoreService, modalService, storageService, debugService, translationService, signalrService, dialogService, oauth2Service, toastService, authService) {
1927
1927
  this.router = router;
1928
1928
  this.activatedRoute = activatedRoute;
1929
1929
  this.modalCtrl = modalCtrl;
@@ -1942,8 +1942,8 @@ class MainService {
1942
1942
  this.signalrService = signalrService;
1943
1943
  this.dialogService = dialogService;
1944
1944
  this.oauth2Service = oauth2Service;
1945
- this.sharepointService = sharepointService;
1946
1945
  this.toastService = toastService;
1946
+ this.authService = authService;
1947
1947
  this.backNavigationPath = [];
1948
1948
  this.routeParam = [];
1949
1949
  this.currentUrl = '';
@@ -2994,63 +2994,69 @@ class MainService {
2994
2994
  }
2995
2995
  }
2996
2996
  alertFormModified(formId, group, resp, eventName) {
2997
- // TODO: 20230830: need to further enhance handling data refresh if there linked child/Id at same page. currently unsure how to pull the linked child record.
2998
2997
  if (!resp) {
2999
2998
  return false;
3000
2999
  }
3001
3000
  const respResult = JSON.parse(resp);
3001
+ if (!respResult.UserName) {
3002
+ return false;
3003
+ }
3002
3004
  if (formId === respResult.Id?.toString() && eventName === window.location.href) {
3003
- if (respResult.Action === ActionType.Delete) {
3004
- this.alertService.show("Record Deleted by Another User", "The current record has been deleted by another user.", [
3005
- { text: "OK", cssClass: "primary" }
3006
- ], ["col-6"], undefined, true).pipe(switchMap((reply) => {
3007
- if (reply === "OK") {
3008
- this.navigateBackToPreviousPage(group);
3009
- return of(true);
3010
- }
3011
- })).subscribe();
3012
- }
3013
- else if (respResult.Action === ActionType.Update) {
3014
- this.webApiService.httpGet$(`${this.group.resourceURL}/${formId}`, null).subscribe(resp => {
3015
- if (resp && resp.RowVersion) {
3016
- // Find properties starting with 'zworkflowbuttons_'
3017
- const workflowButtons = [];
3018
- for (const key in this.group.zComponents) {
3019
- if (key.startsWith("zworkflowbuttons_")) {
3020
- workflowButtons.push(this.group.zComponents[key]);
3021
- }
3022
- }
3023
- if (resp.RowVersion !== this.group.zModel?.RowVersion) {
3024
- this.alertService.show("The current page has been modified by other users.", "Would you like to refresh the page data?", [
3025
- { text: "No", cssClass: "secondary" },
3026
- { text: "Yes", cssClass: "primary" }
3027
- ], ["col-6"], undefined, true).pipe(switchMap((reply) => {
3028
- if (reply === "Yes") {
3029
- this.group.zModel = resp;
3030
- const fg = this.group.form;
3031
- fg.patchValue(this.group.zModel);
3032
- fg.markAsPristine();
3033
- //reload workflow buttons
3034
- workflowButtons.forEach(buttons => {
3035
- buttons.loadButton();
3036
- });
3037
- return of(true);
3038
- }
3039
- workflowButtons.forEach(buttons => {
3040
- buttons.removeGotoButton();
3041
- });
3042
- this.toastService.showPermanently('The data on the current page is not up to date, as it has been saved and overwritten by another user. Please refresh the page.', 'top', 'warning');
3043
- return of(false);
3044
- })).subscribe();
3005
+ if (respResult.UserName === this.authService.e1Token.myProfile.UserName) {
3006
+ if (respResult.Action === ActionType.Update) {
3007
+ this.reloadDataAndWorkflowButton(resp);
3008
+ }
3009
+ }
3010
+ else {
3011
+ if (respResult.Action === ActionType.Delete) {
3012
+ this.alertService.show("Record Deleted by Another User", "The current record has been deleted by another user.", [
3013
+ { text: "OK", cssClass: "primary" }
3014
+ ], ["col-6"], undefined, true).pipe(switchMap((reply) => {
3015
+ if (reply === "OK") {
3016
+ this.navigateBackToPreviousPage(group);
3017
+ return of(true);
3045
3018
  }
3046
- else {
3047
- console.log(`Alert received regarding form modification, RowVersion remains unaltered. No further action has been taken.`);
3019
+ })).subscribe();
3020
+ }
3021
+ else if (respResult.Action === ActionType.Update) {
3022
+ this.webApiService.httpGet$(`${this.group.resourceURL}/${formId}`, null).subscribe(resp => {
3023
+ if (resp && resp.RowVersion) {
3024
+ if (resp.RowVersion !== this.group.zModel?.RowVersion) {
3025
+ this.alertService.show("The current page has been modified by other users.", "Would you like to refresh the page data?", [
3026
+ { text: "No", cssClass: "secondary" },
3027
+ { text: "Yes", cssClass: "primary" }
3028
+ ], ["col-6"], undefined, true).pipe(switchMap((reply) => {
3029
+ if (reply === "Yes") {
3030
+ this.reloadDataAndWorkflowButton(resp);
3031
+ return of(true);
3032
+ }
3033
+ this.toastService.showPermanently('The data on the current page is not up to date, as it has been saved and overwritten by another user. Please refresh the page.', 'top', 'warning');
3034
+ return of(false);
3035
+ })).subscribe();
3036
+ }
3037
+ else {
3038
+ console.log(`Alert received regarding form modification, RowVersion remains unaltered. No further action has been taken.`);
3039
+ }
3048
3040
  }
3049
- }
3050
- });
3041
+ });
3042
+ }
3051
3043
  }
3052
3044
  }
3053
3045
  }
3046
+ reloadDataAndWorkflowButton(zModel) {
3047
+ this.group.zModel = zModel;
3048
+ const fg = this.group.form;
3049
+ fg.patchValue(this.group.zModel);
3050
+ fg.markAsPristine();
3051
+ // Capture all workflow buttons
3052
+ const workflowButtons = Object.keys(this.group.zComponents)
3053
+ .filter(key => key.startsWith("zworkflowbuttons_"))
3054
+ .map(key => this.group.zComponents[key]);
3055
+ // Reload workflow buttons
3056
+ workflowButtons.forEach(button => {
3057
+ button.loadButton();
3058
+ });
3059
+ }
3054
3060
  //#endregion
3055
3061
  // #region DEC
3056
3062
  async loadContainerView(elementContainer, containerPage, data, group) {
@@ -3100,14 +3106,14 @@ class MainService {
3100
3106
  }
3101
3107
  }
3102
3108
  }
3103
- MainService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: MainService, deps: [{ token: i1$1.Router }, { token: i1$1.ActivatedRoute }, { token: i2$1.ModalController }, { token: i2$1.NavController }, { token: i2.AlertService }, { token: i2.CacheService }, { token: i2.FieldService }, { token: i2.ResourceApiService }, { token: i2.ComponentErrorHandlerService }, { token: i2.WebApiService }, { token: i2.ZCoreService }, { token: i3.ModalService }, { token: i2.StorageSessionService }, { token: ZComponentDebugService }, { token: i2.TranslationService }, { token: i2.SignalrService }, { token: i1$2.DialogService }, { token: i2.OAuth2Service }, { token: i2.SharePointService }, { token: i2.ToastService }], target: i0.ɵɵFactoryTarget.Injectable });
3109
+ MainService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: MainService, deps: [{ token: i1$1.Router }, { token: i1$1.ActivatedRoute }, { token: i2$1.ModalController }, { token: i2$1.NavController }, { token: i2.AlertService }, { token: i2.CacheService }, { token: i2.FieldService }, { token: i2.ResourceApiService }, { token: i2.ComponentErrorHandlerService }, { token: i2.WebApiService }, { token: i2.ZCoreService }, { token: i3.ModalService }, { token: i2.StorageSessionService }, { token: ZComponentDebugService }, { token: i2.TranslationService }, { token: i2.SignalrService }, { token: i1$2.DialogService }, { token: i2.OAuth2Service }, { token: i2.ToastService }, { token: i2.AuthService }], target: i0.ɵɵFactoryTarget.Injectable });
3104
3110
  MainService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: MainService, providedIn: 'root' });
3105
3111
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: MainService, decorators: [{
3106
3112
  type: Injectable,
3107
3113
  args: [{
3108
3114
  providedIn: 'root',
3109
3115
  }]
3110
- }], ctorParameters: function () { return [{ type: i1$1.Router }, { type: i1$1.ActivatedRoute }, { type: i2$1.ModalController }, { type: i2$1.NavController }, { type: i2.AlertService }, { type: i2.CacheService }, { type: i2.FieldService }, { type: i2.ResourceApiService }, { type: i2.ComponentErrorHandlerService }, { type: i2.WebApiService }, { type: i2.ZCoreService }, { type: i3.ModalService }, { type: i2.StorageSessionService }, { type: ZComponentDebugService }, { type: i2.TranslationService }, { type: i2.SignalrService }, { type: i1$2.DialogService }, { type: i2.OAuth2Service }, { type: i2.SharePointService }, { type: i2.ToastService }]; } });
3116
+ }], ctorParameters: function () { return [{ type: i1$1.Router }, { type: i1$1.ActivatedRoute }, { type: i2$1.ModalController }, { type: i2$1.NavController }, { type: i2.AlertService }, { type: i2.CacheService }, { type: i2.FieldService }, { type: i2.ResourceApiService }, { type: i2.ComponentErrorHandlerService }, { type: i2.WebApiService }, { type: i2.ZCoreService }, { type: i3.ModalService }, { type: i2.StorageSessionService }, { type: ZComponentDebugService }, { type: i2.TranslationService }, { type: i2.SignalrService }, { type: i1$2.DialogService }, { type: i2.OAuth2Service }, { type: i2.ToastService }, { type: i2.AuthService }]; } });
3111
3117
  function refreshGrid(group) {
3112
3118
  const zgridControl = group["gridOptions"];
3113
3119
  if (zgridControl) {
@@ -3168,16 +3174,7 @@ class ZGridBindingDirective extends DataBindingDirective {
3168
3174
  }
3169
3175
  return;
3170
3176
  }
3171
- const array = this.resourceURL.split("/api/");
3172
- if (!!array[1]) {
3173
- array[1] = "Page" + array[1];
3174
- this.paginationApiPostUrl = array.join("/api/");
3175
- }
3176
- else {
3177
- const arr = this.resourceURL.split("/");
3178
- arr[arr.length - 2] = "Page" + arr[arr.length - 2];
3179
- this.paginationApiPostUrl = arr.join("/");
3180
- }
3177
+ this.setResourceUrl(this.resourceURL);
3181
3178
  this.setFilterParamsByParentRefId();
3182
3179
  }
3183
3180
  // this.gridSubject.next(this);
@@ -3198,6 +3195,18 @@ class ZGridBindingDirective extends DataBindingDirective {
3198
3195
  this.generateGridColumns();
3199
3196
  }
3200
3197
  }
3198
+ setResourceUrl(resourceUrl) {
3199
+ const array = resourceUrl.split("/api/");
3200
+ if (!!array[1]) {
3201
+ array[1] = "Page" + array[1];
3202
+ this.paginationApiPostUrl = array.join("/api/");
3203
+ }
3204
+ else {
3205
+ const arr = this.resourceURL.split("/");
3206
+ arr[arr.length - 2] = "Page" + arr[arr.length - 2];
3207
+ this.paginationApiPostUrl = arr.join("/");
3208
+ }
3209
+ }
3201
3210
  setFilterParamsByParentRefId() {
3202
3211
  // Use field own referenceId if available
3203
3212
  const refId = this.getFieldReferenceId() || this.grp.referenceId;
@@ -4438,7 +4447,7 @@ class UipageComponent {
4438
4447
  this.setupRouteParams(routeParam);
4439
4448
  }
4440
4449
  else {
4441
- console.warn("Error in uipage init.");
4450
+ console.warn("routeParam is undefined.");
4442
4451
  }
4443
4452
  }), switchMap(() => {
4444
4453
  const formType = isListForm ? FieldType.listField : FieldType.formField;