@pega/angular-sdk-overrides 0.23.14 → 0.23.16

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.
@@ -170,15 +170,25 @@ export class CurrencyComponent implements OnInit, OnDestroy {
170
170
  }
171
171
 
172
172
  fieldOnChange(event: any) {
173
- this.angularPConnectData.actions?.onChange(this, event);
173
+ const oldVal = this.value$ ?? '';
174
+ const isValueChanged = Number(event.target.value).toString() !== oldVal.toString();
175
+
176
+ if (isValueChanged) {
177
+ this.angularPConnectData.actions?.onChange(this, event);
178
+ }
174
179
  }
175
180
 
176
181
  fieldOnBlur(event: any) {
177
182
  // PConnect wants to use eventHandler for onBlur
178
183
 
179
- const actionsApi = this.pConn$?.getActionsApi();
180
- const propName = (this.pConn$?.getStateProps() as any).value;
181
- handleEvent(actionsApi, 'changeNblur', propName, event?.target?.value);
184
+ const oldVal = this.value$ ?? '';
185
+ const isValueChanged = Number(event.target.value).toString() !== oldVal.toString();
186
+
187
+ if (isValueChanged) {
188
+ const actionsApi = this.pConn$?.getActionsApi();
189
+ const propName = (this.pConn$?.getStateProps() as any).value;
190
+ handleEvent(actionsApi, 'changeNblur', propName, event?.target?.value);
191
+ }
182
192
  }
183
193
 
184
194
  getErrorMessage() {
@@ -160,12 +160,18 @@ export class DecimalComponent implements OnInit, OnDestroy {
160
160
  }
161
161
 
162
162
  fieldOnBlur(event: any) {
163
- const actionsApi = this.pConn$?.getActionsApi();
164
- const propName = (this.pConn$?.getStateProps() as any).value;
165
163
  let value = event?.target?.value;
166
164
  value = value.replace(/,/g, '');
167
165
  value = value !== '' ? Number(value) : value;
168
- handleEvent(actionsApi, 'changeNblur', propName, value);
166
+
167
+ const oldVal = this.value$ ?? '';
168
+ const isValueChanged = value.toString() !== oldVal.toString();
169
+
170
+ if (isValueChanged) {
171
+ const actionsApi = this.pConn$?.getActionsApi();
172
+ const propName = (this.pConn$?.getStateProps() as any).value;
173
+ handleEvent(actionsApi, 'changeNblur', propName, value);
174
+ }
169
175
  }
170
176
 
171
177
  getErrorMessage() {
@@ -154,13 +154,23 @@ export class EmailComponent implements OnInit, OnDestroy {
154
154
  }
155
155
 
156
156
  fieldOnChange(event: any) {
157
- this.angularPConnectData.actions?.onChange(this, event);
157
+ const oldVal = this.value$ ?? '';
158
+ const isValueChanged = event.target.value.toString() !== oldVal.toString();
159
+
160
+ if (isValueChanged) {
161
+ this.angularPConnectData.actions?.onChange(this, event);
162
+ }
158
163
  }
159
164
 
160
165
  fieldOnBlur(event: any) {
161
- const actionsApi = this.pConn$?.getActionsApi();
162
- const propName = (this.pConn$?.getStateProps() as any).value;
163
- handleEvent(actionsApi, 'changeNblur', propName, event?.target?.value);
166
+ const oldVal = this.value$ ?? '';
167
+ const isValueChanged = event.target.value.toString() !== oldVal.toString();
168
+
169
+ if (isValueChanged) {
170
+ const actionsApi = this.pConn$?.getActionsApi();
171
+ const propName = (this.pConn$?.getStateProps() as any).value;
172
+ handleEvent(actionsApi, 'changeNblur', propName, event?.target?.value);
173
+ }
164
174
  }
165
175
 
166
176
  getErrorMessage() {
@@ -157,13 +157,23 @@ export class IntegerComponent implements OnInit, OnDestroy {
157
157
  }
158
158
 
159
159
  fieldOnChange(event: any) {
160
- this.angularPConnectData.actions?.onChange(this, event);
160
+ const oldVal = this.value$ ?? '';
161
+ const isValueChanged = event.target.value.toString() !== oldVal.toString();
162
+
163
+ if (isValueChanged) {
164
+ this.angularPConnectData.actions?.onChange(this, event);
165
+ }
161
166
  }
162
167
 
163
168
  fieldOnBlur(event: any) {
164
- const actionsApi = this.pConn$?.getActionsApi();
165
- const propName = (this.pConn$?.getStateProps() as any).value;
166
- handleEvent(actionsApi, 'changeNblur', propName, event?.target?.value);
169
+ const oldVal = this.value$ ?? '';
170
+ const isValueChanged = event.target.value.toString() !== oldVal.toString();
171
+
172
+ if (isValueChanged) {
173
+ const actionsApi = this.pConn$?.getActionsApi();
174
+ const propName = (this.pConn$?.getStateProps() as any).value;
175
+ handleEvent(actionsApi, 'changeNblur', propName, event?.target?.value);
176
+ }
167
177
  }
168
178
 
169
179
  getErrorMessage() {
@@ -155,13 +155,23 @@ export class PercentageComponent implements OnInit, OnDestroy {
155
155
  }
156
156
 
157
157
  fieldOnChange(event: any) {
158
- this.angularPConnectData.actions?.onChange(this, event);
158
+ const oldVal = this.value$ ?? '';
159
+ const isValueChanged = event.target.value.toString() !== oldVal.toString();
160
+
161
+ if (isValueChanged) {
162
+ this.angularPConnectData.actions?.onChange(this, event);
163
+ }
159
164
  }
160
165
 
161
166
  fieldOnBlur(event: any) {
162
- const actionsApi = this.pConn$?.getActionsApi();
163
- const propName = (this.pConn$?.getStateProps() as any).value;
164
- handleEvent(actionsApi, 'changeNblur', propName, event?.target?.value);
167
+ const oldVal = this.value$ ?? '';
168
+ const isValueChanged = event.target.value.toString() !== oldVal.toString();
169
+
170
+ if (isValueChanged) {
171
+ const actionsApi = this.pConn$?.getActionsApi();
172
+ const propName = (this.pConn$?.getStateProps() as any).value;
173
+ handleEvent(actionsApi, 'changeNblur', propName, event?.target?.value);
174
+ }
165
175
  }
166
176
 
167
177
  getErrorMessage() {
@@ -159,26 +159,18 @@ export class PhoneComponent implements OnInit, OnDestroy {
159
159
  }
160
160
  }
161
161
 
162
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
163
+ fieldOnBlur(event: Event) {}
164
+
162
165
  fieldOnChange() {
163
166
  if (this.formGroup$.controls[this.controlName$].value) {
164
- const actionsApi = this.pConn$?.getActionsApi();
165
- const propName = (this.pConn$?.getStateProps() as any).value;
166
167
  const value = this.formGroup$.controls[this.controlName$].value;
167
- const eventObj = {
168
- target: {
169
- value
170
- }
171
- };
172
168
  this.afterBlur = true;
173
- this.angularPConnectData.actions?.onChange(this, eventObj);
174
- handleEvent(actionsApi, 'blur', propName, value);
175
- }
176
- }
177
169
 
178
- fieldOnBlur(event: any) {
179
- const actionsApi = this.pConn$?.getActionsApi();
180
- const propName = (this.pConn$?.getStateProps() as any).value;
181
- handleEvent(actionsApi, 'changeNblur', propName, event?.target?.value);
170
+ const actionsApi = this.pConn$.getActionsApi();
171
+ const propName = (this.pConn$.getStateProps() as any).value;
172
+ handleEvent(actionsApi, 'changeNblur', propName, value);
173
+ }
182
174
  }
183
175
 
184
176
  getErrorMessage() {
@@ -157,9 +157,14 @@ export class TextAreaComponent implements OnInit, OnDestroy {
157
157
  }
158
158
 
159
159
  fieldOnChange(event: any) {
160
- const actionsApi = this.pConn$?.getActionsApi();
161
- const propName = (this.pConn$?.getStateProps() as any).value;
162
- handleEvent(actionsApi, 'changeNblur', propName, event?.target?.value);
160
+ const oldVal = this.value$ ?? '';
161
+ const isValueChanged = event.target.value.toString() !== oldVal.toString();
162
+
163
+ if (isValueChanged) {
164
+ const actionsApi = this.pConn$?.getActionsApi();
165
+ const propName = (this.pConn$?.getStateProps() as any).value;
166
+ handleEvent(actionsApi, 'changeNblur', propName, event?.target?.value);
167
+ }
163
168
  }
164
169
 
165
170
  getErrorMessage() {
@@ -157,13 +157,23 @@ export class TextInputComponent implements OnInit, OnDestroy {
157
157
  }
158
158
 
159
159
  fieldOnChange(event: any) {
160
- this.angularPConnectData.actions?.onChange(this, event);
160
+ const oldVal = this.value$ ?? '';
161
+ const isValueChanged = event.target.value.toString() !== oldVal.toString();
162
+
163
+ if (isValueChanged) {
164
+ this.angularPConnectData.actions?.onChange(this, event);
165
+ }
161
166
  }
162
167
 
163
168
  fieldOnBlur(event: any) {
164
- const actionsApi = this.pConn$?.getActionsApi();
165
- const propName = (this.pConn$?.getStateProps() as any).value;
166
- handleEvent(actionsApi, 'changeNblur', propName, event?.target?.value);
169
+ const oldVal = this.value$ ?? '';
170
+ const isValueChanged = event.target.value.toString() !== oldVal.toString();
171
+
172
+ if (isValueChanged) {
173
+ const actionsApi = this.pConn$?.getActionsApi();
174
+ const propName = (this.pConn$?.getStateProps() as any).value;
175
+ handleEvent(actionsApi, 'changeNblur', propName, event?.target?.value);
176
+ }
167
177
  }
168
178
 
169
179
  getErrorMessage() {
@@ -155,13 +155,23 @@ export class UrlComponent implements OnInit, OnDestroy {
155
155
  }
156
156
 
157
157
  fieldOnChange(event: any) {
158
- this.angularPConnectData.actions?.onChange(this, event);
158
+ const oldVal = this.value$ ?? '';
159
+ const isValueChanged = event.target.value.toString() !== oldVal.toString();
160
+
161
+ if (isValueChanged) {
162
+ this.angularPConnectData.actions?.onChange(this, event);
163
+ }
159
164
  }
160
165
 
161
166
  fieldOnBlur(event: any) {
162
- const actionsApi = this.pConn$?.getActionsApi();
163
- const propName = (this.pConn$?.getStateProps() as any).value;
164
- handleEvent(actionsApi, 'changeNblur', propName, event?.target?.value);
167
+ const oldVal = this.value$ ?? '';
168
+ const isValueChanged = event.target.value.toString() !== oldVal.toString();
169
+
170
+ if (isValueChanged) {
171
+ const actionsApi = this.pConn$?.getActionsApi();
172
+ const propName = (this.pConn$?.getStateProps() as any).value;
173
+ handleEvent(actionsApi, 'changeNblur', propName, event?.target?.value);
174
+ }
165
175
  }
166
176
 
167
177
  getErrorMessage() {
@@ -119,6 +119,14 @@ export class FlowContainerComponent extends FlowContainerBaseComponent implement
119
119
  },
120
120
  'cancelPressed'
121
121
  );
122
+
123
+ PCore.getPubSubUtils().subscribe(
124
+ 'clearBannerMessages',
125
+ () => {
126
+ this.banners = [];
127
+ },
128
+ 'CLEAR_BANNER_MESSAGES'
129
+ );
122
130
  }
123
131
 
124
132
  ngOnDestroy() {
@@ -129,6 +137,7 @@ export class FlowContainerComponent extends FlowContainerBaseComponent implement
129
137
  PCore.getPubSubUtils().unsubscribe(PCore.getConstants().PUB_SUB_EVENTS.EVENT_CANCEL, 'cancelAssignment');
130
138
 
131
139
  PCore.getPubSubUtils().unsubscribe('cancelPressed', 'cancelPressed');
140
+ PCore.getPubSubUtils().unsubscribe('clearBannerMessages', 'CLEAR_BANNER_MESSAGES');
132
141
  }
133
142
 
134
143
  handleCancel() {
@@ -152,14 +161,15 @@ export class FlowContainerComponent extends FlowContainerBaseComponent implement
152
161
  const pConn = this.pConnectOfActiveContainerItem || this.pConn$;
153
162
  const caseViewModeFromProps = this.angularPConnect.getComponentProp(this, 'caseViewMode');
154
163
  const caseViewModeFromRedux = pConn.getValue('context_data.caseViewMode', '');
164
+ const completeProps = this.angularPConnect.getCurrentCompleteProps(this) as FlowContainerProps;
155
165
 
156
166
  // ONLY call updateSelf when the component should update
157
167
  // AND removing the "gate" that was put there since shouldComponentUpdate
158
168
  // should be the real "gate"
169
+ // eslint-disable-next-line sonarjs/no-collapsible-if
159
170
  if (bUpdateSelf || caseViewModeFromProps !== caseViewModeFromRedux) {
160
171
  // don't want to redraw the flow container when there are page messages, because
161
172
  // the redraw causes us to loose the errors on the elements
162
- const completeProps = this.angularPConnect.getCurrentCompleteProps(this) as FlowContainerProps;
163
173
  if (!completeProps.pageMessages || completeProps.pageMessages.length == 0) {
164
174
  // with a cancel, need to timeout so todo will update correctly
165
175
  if (this.bHasCancel) {
@@ -170,10 +180,10 @@ export class FlowContainerComponent extends FlowContainerBaseComponent implement
170
180
  } else {
171
181
  this.updateSelf();
172
182
  }
173
- } else {
174
- this.showPageMessages(completeProps);
175
183
  }
176
184
  }
185
+
186
+ this.showPageMessages(completeProps);
177
187
  }
178
188
 
179
189
  showPageMessages(completeProps: FlowContainerProps) {
@@ -1,5 +1,5 @@
1
1
  <div>
2
- <div><component-mapper name="AlertBanner" [props]="{ banners }" [parent]="this"></component-mapper></div>
2
+ <div><component-mapper name="AlertBanner" [props]="{ banners: bannerService.banners }" [parent]="this"></component-mapper></div>
3
3
  <div *ngIf="bHasNavigation$" class="psdk-stepper">
4
4
  <component-mapper
5
5
  name="MultiStep"
@@ -8,6 +8,7 @@ import { ErrorMessagesService } from '@pega/angular-sdk-components';
8
8
  import { ProgressSpinnerService } from '@pega/angular-sdk-components';
9
9
  import { ReferenceComponent } from '@pega/angular-sdk-components';
10
10
  import { ComponentMapperComponent } from '@pega/angular-sdk-components';
11
+ import { BannerService } from '@pega/angular-sdk-components';
11
12
 
12
13
  function getRefreshProps(refreshConditions) {
13
14
  // refreshConditions cuurently supports only "Changes" event
@@ -37,7 +38,6 @@ export class AssignmentComponent implements OnInit, OnDestroy, OnChanges {
37
38
  @Input() isCreateStage$: boolean;
38
39
  @Input() updateToken$: number;
39
40
  @Input() isInModal$ = false;
40
- @Input() banners;
41
41
 
42
42
  // For interaction with AngularPConnect
43
43
  angularPConnectData: AngularPConnectData = {};
@@ -75,12 +75,15 @@ export class AssignmentComponent implements OnInit, OnDestroy, OnChanges {
75
75
  localeCategory = 'Assignment';
76
76
  localeReference;
77
77
 
78
+ snackBarRef;
79
+
78
80
  constructor(
79
81
  private angularPConnect: AngularPConnectService,
80
82
  private psService: ProgressSpinnerService,
81
83
  private erService: ErrorMessagesService,
82
84
  private ngZone: NgZone,
83
- private snackBar: MatSnackBar
85
+ private snackBar: MatSnackBar,
86
+ public bannerService: BannerService
84
87
  ) {}
85
88
 
86
89
  ngOnInit(): void {
@@ -111,6 +114,8 @@ export class AssignmentComponent implements OnInit, OnDestroy, OnChanges {
111
114
  // Should always check the bridge to see if the component should update itself (re-render)
112
115
  const bUpdateSelf = this.angularPConnect.shouldComponentUpdate(this);
113
116
 
117
+ this.bannerService.updateBanners(this.itemKey$);
118
+
114
119
  // ONLY call updateSelf when the component should update
115
120
  // AND removing the "gate" that was put there since shouldComponentUpdate
116
121
  // should be the real "gate"
@@ -300,6 +305,10 @@ export class AssignmentComponent implements OnInit, OnDestroy, OnChanges {
300
305
  }
301
306
 
302
307
  buttonClick(sAction, sButtonType) {
308
+ this.snackBarRef?.dismiss();
309
+ this.bannerService.clearBanners();
310
+ // @ts-ignore
311
+ PCore.getPubSubUtils().publish('clearBannerMessages');
303
312
  // right now, done on an individual basis, setting bReInit to true
304
313
  // upon the next flow container state change, will cause the flow container
305
314
  // to re-initialize
@@ -335,7 +344,7 @@ export class AssignmentComponent implements OnInit, OnDestroy, OnChanges {
335
344
  })
336
345
  .catch(() => {
337
346
  this.psService.sendMessage(false);
338
- this.snackBar.open(`${this.localizedVal('Navigation failed!', this.localeCategory)}`, 'Ok');
347
+ this.snackBarRef = this.snackBar.open(`${this.localizedVal('Navigation failed!', this.localeCategory)}`, 'Ok');
339
348
  });
340
349
  }
341
350
  break;
@@ -354,7 +363,7 @@ export class AssignmentComponent implements OnInit, OnDestroy, OnChanges {
354
363
  })
355
364
  .catch(() => {
356
365
  this.psService.sendMessage(false);
357
- this.snackBar.open(`${this.localizedVal('Save failed', this.localeCategory)}`, 'Ok');
366
+ this.snackBarRef = this.snackBar.open(`${this.localizedVal('Save failed', this.localeCategory)}`, 'Ok');
358
367
  });
359
368
 
360
369
  break;
@@ -381,7 +390,7 @@ export class AssignmentComponent implements OnInit, OnDestroy, OnChanges {
381
390
  })
382
391
  .catch(() => {
383
392
  this.psService.sendMessage(false);
384
- this.snackBar.open(`${this.localizedVal('Cancel failed!', this.localeCategory)}`, 'Ok');
393
+ this.snackBarRef = this.snackBar.open(`${this.localizedVal('Cancel failed!', this.localeCategory)}`, 'Ok');
385
394
  });
386
395
  } else {
387
396
  this.psService.sendMessage(true);
@@ -400,7 +409,7 @@ export class AssignmentComponent implements OnInit, OnDestroy, OnChanges {
400
409
  })
401
410
  .catch(() => {
402
411
  this.psService.sendMessage(false);
403
- this.snackBar.open(`${this.localizedVal('Cancel failed!', this.localeCategory)}`, 'Ok');
412
+ this.snackBarRef = this.snackBar.open(`${this.localizedVal('Cancel failed!', this.localeCategory)}`, 'Ok');
404
413
  });
405
414
  }
406
415
  break;
@@ -413,23 +422,18 @@ export class AssignmentComponent implements OnInit, OnDestroy, OnChanges {
413
422
  switch (sAction) {
414
423
  case 'finishAssignment':
415
424
  this.erService.sendMessage('publish', '');
416
- if (this.formValid()) {
417
- this.bReInit = true;
418
- this.psService.sendMessage(true);
419
- const finishPromise = this.finishAssignment(this.itemKey$); // JA - was itemID but Nebula/Constellation uses itemKey
420
- finishPromise
421
- .then(() => {
422
- this.psService.sendMessage(false);
423
- this.updateChanges();
424
- })
425
- .catch(() => {
426
- this.psService.sendMessage(false);
427
- this.snackBar.open(`${this.localizedVal('Submit failed!', this.localeCategory)}`, 'Ok');
428
- });
429
- } else {
430
- // let snackBarRef = this.snackBar.open("Please fix errors on form.", "Ok");
431
- this.erService.sendMessage('show', this.localizedVal('Please fix errors on form.', this.localeCategory));
432
- }
425
+ this.bReInit = true;
426
+ this.psService.sendMessage(true);
427
+ const finishPromise = this.finishAssignment(this.itemKey$); // JA - was itemID but Nebula/Constellation uses itemKey
428
+ finishPromise
429
+ .then(() => {
430
+ this.psService.sendMessage(false);
431
+ this.updateChanges();
432
+ })
433
+ .catch(() => {
434
+ this.psService.sendMessage(false);
435
+ this.snackBarRef = this.snackBar.open(`${this.localizedVal('Submit failed!', this.localeCategory)}`, 'Ok');
436
+ });
433
437
  break;
434
438
  default:
435
439
  break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pega/angular-sdk-overrides",
3
- "version": "0.23.14",
3
+ "version": "0.23.16",
4
4
  "description": "Angular SDK - Code for overriding components",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"