@pega/angular-sdk-overrides 0.242.4 → 0.242.6

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.
Files changed (35) hide show
  1. package/lib/field/dropdown/dropdown.component.ts +29 -15
  2. package/lib/field/user-reference/user-reference.component.html +2 -10
  3. package/lib/field/user-reference/user-reference.component.ts +34 -12
  4. package/lib/infra/Containers/flow-container/flow-container.component.ts +17 -40
  5. package/lib/infra/Containers/flow-container/helpers.ts +1 -1
  6. package/lib/infra/Containers/modal-view-container/modal-view-container.component.ts +0 -6
  7. package/lib/infra/assignment/assignment.component.html +1 -1
  8. package/lib/infra/assignment/assignment.component.ts +84 -39
  9. package/lib/infra/assignment-card/assignment-card.component.html +1 -0
  10. package/lib/infra/assignment-card/assignment-card.component.ts +32 -4
  11. package/lib/infra/root-container/root-container.component.html +2 -15
  12. package/lib/infra/root-container/root-container.component.ts +0 -10
  13. package/lib/infra/view/view.component.ts +15 -1
  14. package/lib/template/base/details-template-base.ts +67 -0
  15. package/lib/template/base/form-template-base.ts +16 -0
  16. package/lib/template/case-view/case-view.component.html +4 -4
  17. package/lib/template/case-view/case-view.component.ts +7 -12
  18. package/lib/template/default-form/default-form.component.ts +40 -5
  19. package/lib/template/details/details.component.ts +5 -39
  20. package/lib/template/details-narrow-wide/details-narrow-wide.component.ts +5 -38
  21. package/lib/template/details-one-column/details-one-column.component.ts +5 -40
  22. package/lib/template/details-sub-tabs/details-sub-tabs.component.html +1 -2
  23. package/lib/template/details-sub-tabs/details-sub-tabs.component.ts +5 -37
  24. package/lib/template/details-three-column/details-three-column.component.ts +5 -41
  25. package/lib/template/details-two-column/details-two-column.component.ts +5 -41
  26. package/lib/template/details-wide-narrow/details-wide-narrow.component.ts +5 -40
  27. package/lib/template/one-column/one-column.component.ts +2 -2
  28. package/lib/template/simple-table-manual/helpers.ts +7 -5
  29. package/lib/template/three-column/three-column.component.ts +2 -2
  30. package/lib/template/two-column/two-column.component.ts +2 -2
  31. package/lib/template/wide-narrow-form/wide-narrow-form.component.ts +2 -2
  32. package/lib/widget/todo/todo.component.html +3 -3
  33. package/lib/widget/todo/todo.component.scss +7 -0
  34. package/package.json +1 -1
  35. package/lib/template/form-template-base/form-template-base.component.ts +0 -10
@@ -279,25 +279,39 @@ export class DropdownComponent implements OnInit, OnDestroy {
279
279
 
280
280
  columns = preProcessColumns(columns) || [];
281
281
  if (!this.displayMode$ && listType !== 'associated' && typeof datasource === 'string') {
282
- this.getData(datasource, parameters, columns, context);
282
+ this.getData(datasource, parameters, columns, context, listType);
283
283
  }
284
284
  }
285
285
 
286
- getData(datasource, parameters, columns, context) {
287
- this.dataPageService.getDataPageData(datasource, parameters, context).then((results: any) => {
288
- const optionsData: any[] = [];
289
- const displayColumn = getDisplayFieldsMetaData(columns);
290
- results?.forEach(element => {
291
- const val = element[displayColumn.primary]?.toString();
292
- const obj = {
293
- key: element[displayColumn.key] || element.pyGUID,
294
- value: val
295
- };
296
- optionsData.push(obj);
286
+ getData(dataSource, parameters, columns, context, listType) {
287
+ const dataConfig: any = {
288
+ columns,
289
+ dataSource,
290
+ deferDatasource: true,
291
+ listType,
292
+ parameters,
293
+ matchPosition: 'contains',
294
+ maxResultsDisplay: '5000',
295
+ cacheLifeSpan: 'form'
296
+ };
297
+ PCore.getDataApi()
298
+ .init(dataConfig, context)
299
+ .then((dataApiObj: any) => {
300
+ const optionsData: any[] = [];
301
+ const displayColumn = getDisplayFieldsMetaData(columns);
302
+ dataApiObj?.fetchData('').then(response => {
303
+ response.data?.forEach(element => {
304
+ const val = element[displayColumn.primary]?.toString();
305
+ const obj = {
306
+ key: element[displayColumn.key] || element.pyGUID,
307
+ value: val
308
+ };
309
+ optionsData.push(obj);
310
+ });
311
+ optionsData?.unshift({ key: 'Select', value: this.pConn$.getLocalizedValue('Select...', '', '') });
312
+ this.options$ = optionsData;
313
+ });
297
314
  });
298
- optionsData?.unshift({ key: 'Select', value: this.pConn$.getLocalizedValue('Select...', '', '') });
299
- this.options$ = optionsData;
300
- });
301
315
  }
302
316
 
303
317
  isSelected(buttonValue: string): boolean {
@@ -8,13 +8,7 @@
8
8
  </div>
9
9
  <div [formGroup]="formGroup$" *ngIf="type === 'dropdown'">
10
10
  <mat-form-field class="psdk-full-width" subscriptSizing="dynamic" [hintLabel]="helperText">
11
- <mat-select
12
- [value]="value$"
13
- [required]="bRequired$"
14
- [formControl]="fieldControl"
15
- [attr.data-test-id]="testId"
16
- (selectionChange)="fieldOnChange($event)"
17
- >
11
+ <mat-select [required]="bRequired$" [formControl]="fieldControl" [attr.data-test-id]="testId" (selectionChange)="fieldOnChange($event)">
18
12
  <mat-option *ngFor="let opt of options$" [value]="opt.key">
19
13
  {{ opt.value }}
20
14
  </mat-option>
@@ -32,14 +26,12 @@
32
26
  matInput
33
27
  [placeholder]="placeholder"
34
28
  [formControl]="fieldControl"
35
- [value]="value$"
36
29
  [required]="bRequired$"
37
30
  [matAutocomplete]="auto"
38
31
  [attr.data-test-id]="testId"
39
- (change)="fieldOnChange($event)"
40
32
  (blur)="fieldOnBlur($event)"
41
33
  />
42
- <mat-autocomplete #auto="matAutocomplete">
34
+ <mat-autocomplete #auto="matAutocomplete" autoActiveFirstOption (optionSelected)="optionChanged($event)">
43
35
  <mat-option *ngFor="let opt of filteredOptions | async" [value]="opt.value">
44
36
  <span>{{ opt.value }}</span>
45
37
  </mat-option>
@@ -23,6 +23,7 @@ interface UserReferenceProps extends Omit<PConnFieldProps, 'value'> {
23
23
  value?: any;
24
24
  showAsFormattedText?: boolean;
25
25
  additionalProps?: object;
26
+ onRecordChange?: any;
26
27
  }
27
28
 
28
29
  @Component({
@@ -66,6 +67,7 @@ export class UserReferenceComponent implements OnInit, OnDestroy {
66
67
  fieldControl = new FormControl('', null);
67
68
  actionsApi: Object;
68
69
  propName: string;
70
+ onRecordChange: any;
69
71
 
70
72
  constructor(
71
73
  private angularPConnect: AngularPConnectService,
@@ -83,11 +85,11 @@ export class UserReferenceComponent implements OnInit, OnDestroy {
83
85
  if (this.formGroup$) {
84
86
  // add control to formGroup
85
87
  this.formGroup$.addControl(this.controlName$, this.fieldControl);
86
- this.fieldControl.setValue(this.value$);
88
+ this.fieldControl.setValue(this.getValue(this.value$));
87
89
  }
88
90
 
89
91
  this.filteredOptions = this.fieldControl.valueChanges.pipe(
90
- startWith(''),
92
+ startWith(this.getValue(this.value$) || ''),
91
93
  map(value => this._filter(value || ''))
92
94
  );
93
95
  }
@@ -126,6 +128,21 @@ export class UserReferenceComponent implements OnInit, OnDestroy {
126
128
  return this.options$?.filter(option => option.value?.toLowerCase().includes(filterVal));
127
129
  }
128
130
 
131
+ isUserNameAvailable = user => {
132
+ return typeof user === 'object' && user !== null && user.userName;
133
+ };
134
+
135
+ getUserName = user => {
136
+ return user.userName;
137
+ };
138
+
139
+ getValue = user => {
140
+ if (this.displayAs$ === DROPDOWN_LIST) {
141
+ return this.utils.getUserId(user) || this.getUserName(user);
142
+ }
143
+ return this.isUserNameAvailable(user) ? this.getUserName(user) : this.utils.getUserId(user);
144
+ };
145
+
129
146
  async checkAndUpdate() {
130
147
  // Should always check the bridge to see if the component should
131
148
  // update itself (re-render)
@@ -140,6 +157,7 @@ export class UserReferenceComponent implements OnInit, OnDestroy {
140
157
  async updateSelf() {
141
158
  const props = this.pConn$.getConfigProps() as UserReferenceProps;
142
159
  this.testId = props.testId;
160
+ this.onRecordChange = props?.onRecordChange;
143
161
 
144
162
  const { label, displayAs, value, showAsFormattedText, helperText, placeholder, displayMode } = props;
145
163
 
@@ -150,20 +168,18 @@ export class UserReferenceComponent implements OnInit, OnDestroy {
150
168
  this.placeholder = placeholder || '';
151
169
  this.displayMode$ = displayMode;
152
170
 
171
+ this.value$ = this.pConn$.getConfigProps()?.value;
172
+
153
173
  const { readOnly, required } = props;
154
174
  [this.bReadonly$, this.bRequired$] = [readOnly, required].map(prop => prop === true || (typeof prop === 'string' && prop === 'true'));
155
175
 
156
176
  this.actionsApi = this.pConn$.getActionsApi();
157
177
  this.propName = this.pConn$.getStateProps().value;
158
178
 
159
- const isUserNameAvailable = user => {
160
- return typeof user === 'object' && user !== null && user.userName;
161
- };
162
-
163
179
  this.userID$ = this.utils.getUserId(value);
164
180
 
165
181
  if (this.userID$ && this.bReadonly$ && this.showAsFormattedText$) {
166
- if (isUserNameAvailable(value)) {
182
+ if (this.isUserNameAvailable(value)) {
167
183
  this.userName$ = value.userName;
168
184
  } else {
169
185
  // if same user ref field is referred in view as editable & readonly formatted text
@@ -201,7 +217,12 @@ export class UserReferenceComponent implements OnInit, OnDestroy {
201
217
  if (event?.target) {
202
218
  this.filterValue = (event.target as HTMLInputElement).value;
203
219
  }
204
- const value = event?.target?.value;
220
+ const value = event?.value;
221
+ handleEvent(this.actionsApi, 'change', this.propName, value);
222
+ }
223
+
224
+ optionChanged(event: any) {
225
+ const value = event?.option?.value;
205
226
  handleEvent(this.actionsApi, 'change', this.propName, value);
206
227
  }
207
228
 
@@ -211,11 +232,12 @@ export class UserReferenceComponent implements OnInit, OnDestroy {
211
232
  const index = this.options$?.findIndex(element => element.value === event.target.value);
212
233
  key = index > -1 ? (key = this.options$[index].key) : event.target.value;
213
234
  }
214
-
215
- const value = {
216
- value: key
217
- };
235
+ const value = key;
218
236
  handleEvent(this.actionsApi, 'changeNblur', this.propName, value);
237
+ if (this.onRecordChange) {
238
+ event.target.value = value;
239
+ this.onRecordChange(event);
240
+ }
219
241
  }
220
242
 
221
243
  getErrorMessage() {
@@ -6,7 +6,7 @@ import { publicConstants } from '@pega/pcore-pconnect-typedefs/constants';
6
6
  import { ProgressSpinnerService } from '@pega/angular-sdk-components';
7
7
  import { ReferenceComponent } from '@pega/angular-sdk-components';
8
8
  import { Utils } from '@pega/angular-sdk-components';
9
- import { getToDoAssignments, showBanner } from './helpers';
9
+ import { getToDoAssignments, hasAssignments, showBanner } from './helpers';
10
10
  import { ComponentMapperComponent } from '@pega/angular-sdk-components';
11
11
  import { FlowContainerBaseComponent } from '@pega/angular-sdk-components';
12
12
 
@@ -121,6 +121,14 @@ export class FlowContainerComponent extends FlowContainerBaseComponent implement
121
121
  },
122
122
  'cancelPressed'
123
123
  );
124
+
125
+ PCore.getPubSubUtils().subscribe(
126
+ 'clearBannerMessages',
127
+ () => {
128
+ this.banners = [];
129
+ },
130
+ 'CLEAR_BANNER_MESSAGES'
131
+ );
124
132
  }
125
133
 
126
134
  ngOnDestroy() {
@@ -131,6 +139,8 @@ export class FlowContainerComponent extends FlowContainerBaseComponent implement
131
139
  PCore.getPubSubUtils().unsubscribe(PCore.getConstants().PUB_SUB_EVENTS.EVENT_CANCEL, 'cancelAssignment');
132
140
 
133
141
  PCore.getPubSubUtils().unsubscribe('cancelPressed', 'cancelPressed');
142
+
143
+ PCore.getPubSubUtils().unsubscribe('clearBannerMessages', 'CLEAR_BANNER_MESSAGES');
134
144
  }
135
145
 
136
146
  handleCancel() {
@@ -155,13 +165,15 @@ export class FlowContainerComponent extends FlowContainerBaseComponent implement
155
165
  const caseViewModeFromProps = this.angularPConnect.getComponentProp(this, 'caseViewMode');
156
166
  const caseViewModeFromRedux = pConn.getValue('context_data.caseViewMode', '');
157
167
 
168
+ const completeProps = this.angularPConnect.getCurrentCompleteProps(this) as FlowContainerProps;
169
+
158
170
  // ONLY call updateSelf when the component should update
159
171
  // AND removing the "gate" that was put there since shouldComponentUpdate
160
172
  // should be the real "gate"
173
+ // eslint-disable-next-line sonarjs/no-collapsible-if
161
174
  if (bUpdateSelf || caseViewModeFromProps !== caseViewModeFromRedux) {
162
175
  // don't want to redraw the flow container when there are page messages, because
163
176
  // the redraw causes us to loose the errors on the elements
164
- const completeProps = this.angularPConnect.getCurrentCompleteProps(this) as FlowContainerProps;
165
177
  if (!completeProps.pageMessages || completeProps.pageMessages.length == 0) {
166
178
  // with a cancel, need to timeout so todo will update correctly
167
179
  if (this.bHasCancel) {
@@ -172,10 +184,10 @@ export class FlowContainerComponent extends FlowContainerBaseComponent implement
172
184
  } else {
173
185
  this.updateSelf();
174
186
  }
175
- } else {
176
- this.showPageMessages(completeProps);
177
187
  }
178
188
  }
189
+
190
+ this.showPageMessages(completeProps);
179
191
  }
180
192
 
181
193
  showPageMessages(completeProps: FlowContainerProps) {
@@ -277,41 +289,6 @@ export class FlowContainerComponent extends FlowContainerBaseComponent implement
277
289
  this.psService.sendMessage(false);
278
290
  }
279
291
 
280
- hasAssignments() {
281
- let hasAssignments = false;
282
- const assignmentsList = this.pConn$.getValue(this.pCoreConstants.CASE_INFO.D_CASE_ASSIGNMENTS_RESULTS);
283
- // const thisOperator = PCore.getEnvironmentInfo().getOperatorIdentifier();
284
- // 8.7 includes assignments in Assignments List that may be assigned to
285
- // a different operator. So, see if there are any assignments for
286
- // the current operator
287
- const isEmbedded = window.location.href.includes('embedded');
288
- let bAssignmentsForThisOperator = false;
289
-
290
- if (isEmbedded) {
291
- const thisOperator = PCore.getEnvironmentInfo().getOperatorIdentifier();
292
- for (const assignment of assignmentsList) {
293
- if (assignment.assigneeInfo.ID === thisOperator) {
294
- bAssignmentsForThisOperator = true;
295
- }
296
- }
297
- } else {
298
- bAssignmentsForThisOperator = true;
299
- }
300
-
301
- // Bail if there is no assignmentsList
302
- if (!assignmentsList) {
303
- return hasAssignments;
304
- }
305
-
306
- const hasChildCaseAssignments = this.hasChildCaseAssignments();
307
-
308
- if (bAssignmentsForThisOperator || hasChildCaseAssignments || this.isCaseWideLocalAction()) {
309
- hasAssignments = true;
310
- }
311
-
312
- return hasAssignments;
313
- }
314
-
315
292
  isCaseWideLocalAction() {
316
293
  const actionID = this.pConn$.getValue(this.pCoreConstants.CASE_INFO.ACTIVE_ACTION_ID);
317
294
  const caseActions = this.pConn$.getValue(this.pCoreConstants.CASE_INFO.AVAILABLEACTIONS);
@@ -461,7 +438,7 @@ export class FlowContainerComponent extends FlowContainerBaseComponent implement
461
438
  this.caseMessages$ = this.localizedVal(this.pConn$.getValue('caseMessages'), this.localeCategory);
462
439
  // caseMessages's behavior has changed in 24.2, and hence it doesn't let Optional Action work.
463
440
  // Changing the below condition for now. Was: (theCaseMessages || !hasAssignments())
464
- if (!this.hasAssignments()) {
441
+ if (!hasAssignments(this.pConn$)) {
465
442
  this.bHasCaseMessages$ = true;
466
443
  this.bShowConfirm = true;
467
444
  this.checkSvg$ = this.utils.getImageSrc('check', this.utils.getSDKStaticContentUrl());
@@ -28,7 +28,7 @@ function getChildCaseAssignments(pConnect) {
28
28
  return allAssignments;
29
29
  }
30
30
 
31
- function hasAssignments(pConnect) {
31
+ export function hasAssignments(pConnect) {
32
32
  const { CASE_INFO } = PCore.getConstants();
33
33
  const assignments = pConnect.getValue(CASE_INFO.D_CASE_ASSIGNMENTS_RESULTS);
34
34
  const childCasesAssignments = getChildCaseAssignments(pConnect);
@@ -23,7 +23,6 @@ import { ReferenceComponent } from '@pega/angular-sdk-components';
23
23
  })
24
24
  export class ModalViewContainerComponent implements OnInit, OnDestroy {
25
25
  @Input() pConn$: typeof PConnect;
26
- @Input() displayOnlyFA$: boolean;
27
26
 
28
27
  // for when non modal
29
28
  @Output() modalVisibleChange = new EventEmitter<boolean>();
@@ -73,11 +72,6 @@ export class ModalViewContainerComponent implements OnInit, OnDestroy {
73
72
  }
74
73
 
75
74
  ngOnInit(): void {
76
- if (this.displayOnlyFA$) {
77
- // for when non modal
78
- this.bShowAsModal$ = false;
79
- }
80
-
81
75
  // First thing in initialization is registering and subscribing to the AngularPConnect service
82
76
  this.angularPConnectData = this.angularPConnect.registerAndSubscribeComponent(this, this.onStateChange);
83
77
 
@@ -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,15 @@ 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 'packages/angular-sdk-components/src/public-api';
12
+
13
+ function getRefreshProps(refreshConditions) {
14
+ // refreshConditions cuurently supports only "Changes" event
15
+ if (!refreshConditions) {
16
+ return [];
17
+ }
18
+ return refreshConditions.filter(item => item.event && item.event === 'Changes').map(item => [item.field, item.field?.substring(1)]) || [];
19
+ }
11
20
 
12
21
  interface AssignmentProps {
13
22
  // If any, enter additional props that only exist on this component
@@ -29,7 +38,6 @@ export class AssignmentComponent implements OnInit, OnDestroy, OnChanges {
29
38
  @Input() isCreateStage$: boolean;
30
39
  @Input() updateToken$: number;
31
40
  @Input() isInModal$ = false;
32
- @Input() banners;
33
41
 
34
42
  // For interaction with AngularPConnect
35
43
  angularPConnectData: AngularPConnectData = {};
@@ -69,12 +77,15 @@ export class AssignmentComponent implements OnInit, OnDestroy, OnChanges {
69
77
  localeCategory = 'Assignment';
70
78
  localeReference;
71
79
 
80
+ snackBarRef;
81
+
72
82
  constructor(
73
83
  private angularPConnect: AngularPConnectService,
74
84
  private psService: ProgressSpinnerService,
75
85
  private erService: ErrorMessagesService,
76
86
  private ngZone: NgZone,
77
- private snackBar: MatSnackBar
87
+ private snackBar: MatSnackBar,
88
+ public bannerService: BannerService
78
89
  ) {}
79
90
 
80
91
  ngOnInit(): void {
@@ -105,6 +116,8 @@ export class AssignmentComponent implements OnInit, OnDestroy, OnChanges {
105
116
  // Should always check the bridge to see if the component should update itself (re-render)
106
117
  const bUpdateSelf = this.angularPConnect.shouldComponentUpdate(this);
107
118
 
119
+ this.bannerService.updateBanners(this.itemKey$);
120
+
108
121
  // ONLY call updateSelf when the component should update
109
122
  // AND removing the "gate" that was put there since shouldComponentUpdate
110
123
  // should be the real "gate"
@@ -128,6 +141,8 @@ export class AssignmentComponent implements OnInit, OnDestroy, OnChanges {
128
141
  }
129
142
 
130
143
  updateChanges() {
144
+ this.registerForRefresh();
145
+
131
146
  // pConn$ may be a 'reference' component, so normalize it
132
147
  this.newPConn$ = ReferenceComponent.normalizePConn(this.pConn$);
133
148
 
@@ -285,6 +300,9 @@ export class AssignmentComponent implements OnInit, OnDestroy, OnChanges {
285
300
  }
286
301
 
287
302
  buttonClick(sAction, sButtonType) {
303
+ this.snackBarRef?.dismiss();
304
+ this.bannerService.clearBanners();
305
+ PCore.getPubSubUtils().publish('clearBannerMessages');
288
306
  // right now, done on an individual basis, setting bReInit to true
289
307
  // upon the next flow container state change, will cause the flow container
290
308
  // to re-initialize
@@ -308,21 +326,21 @@ export class AssignmentComponent implements OnInit, OnDestroy, OnChanges {
308
326
  switch (sAction) {
309
327
  case 'navigateToStep':
310
328
  this.erService.sendMessage('publish', '');
311
- if (this.formValid()) {
312
- this.bReInit = true;
313
- this.psService.sendMessage(true);
329
+ // if (this.formValid()) {
330
+ this.bReInit = true;
331
+ this.psService.sendMessage(true);
314
332
 
315
- const navigatePromise = this.navigateToStep('previous', this.itemKey$);
316
- navigatePromise
317
- .then(() => {
318
- this.updateChanges();
319
- this.psService.sendMessage(false);
320
- })
321
- .catch(() => {
322
- this.psService.sendMessage(false);
323
- this.snackBar.open(`${this.localizedVal('Navigation failed!', this.localeCategory)}`, 'Ok');
324
- });
325
- }
333
+ const navigatePromise = this.navigateToStep('previous', this.itemKey$);
334
+ navigatePromise
335
+ .then(() => {
336
+ this.updateChanges();
337
+ this.psService.sendMessage(false);
338
+ })
339
+ .catch(() => {
340
+ this.psService.sendMessage(false);
341
+ this.snackBarRef = this.snackBar.open(`${this.localizedVal('Navigation failed!', this.localeCategory)}`, 'Ok');
342
+ });
343
+ // }
326
344
  break;
327
345
 
328
346
  case 'saveAssignment': {
@@ -338,7 +356,7 @@ export class AssignmentComponent implements OnInit, OnDestroy, OnChanges {
338
356
  })
339
357
  .catch(() => {
340
358
  this.psService.sendMessage(false);
341
- this.snackBar.open(`${this.localizedVal('Save failed', this.localeCategory)}`, 'Ok');
359
+ this.snackBarRef = this.snackBar.open(`${this.localizedVal('Save failed', this.localeCategory)}`, 'Ok');
342
360
  });
343
361
 
344
362
  break;
@@ -362,7 +380,7 @@ export class AssignmentComponent implements OnInit, OnDestroy, OnChanges {
362
380
  })
363
381
  .catch(() => {
364
382
  this.psService.sendMessage(false);
365
- this.snackBar.open(`${this.localizedVal('Cancel failed!', this.localeCategory)}`, 'Ok');
383
+ this.snackBarRef = this.snackBar.open(`${this.localizedVal('Cancel failed!', this.localeCategory)}`, 'Ok');
366
384
  });
367
385
  } else {
368
386
  this.psService.sendMessage(true);
@@ -379,7 +397,7 @@ export class AssignmentComponent implements OnInit, OnDestroy, OnChanges {
379
397
  })
380
398
  .catch(() => {
381
399
  this.psService.sendMessage(false);
382
- this.snackBar.open(`${this.localizedVal('Cancel failed!', this.localeCategory)}`, 'Ok');
400
+ this.snackBarRef = this.snackBar.open(`${this.localizedVal('Cancel failed!', this.localeCategory)}`, 'Ok');
383
401
  });
384
402
  }
385
403
  break;
@@ -391,7 +409,7 @@ export class AssignmentComponent implements OnInit, OnDestroy, OnChanges {
391
409
  .then(() => {})
392
410
  .catch(() => {
393
411
  this.psService.sendMessage(false);
394
- this.snackBar.open(`${this.localizedVal('Rejection failed!', this.localeCategory)}`, 'Ok');
412
+ this.snackBarRef = this.snackBar.open(`${this.localizedVal('Rejection failed!', this.localeCategory)}`, 'Ok');
395
413
  });
396
414
 
397
415
  break;
@@ -404,23 +422,19 @@ export class AssignmentComponent implements OnInit, OnDestroy, OnChanges {
404
422
  switch (sAction) {
405
423
  case 'finishAssignment':
406
424
  this.erService.sendMessage('publish', '');
407
- if (this.formValid()) {
408
- this.bReInit = true;
409
- this.psService.sendMessage(true);
410
- const finishPromise = this.finishAssignment(this.itemKey$); // JA - was itemID but Nebula/Constellation uses itemKey
411
- finishPromise
412
- .then(() => {
413
- this.psService.sendMessage(false);
414
- this.updateChanges();
415
- })
416
- .catch(() => {
417
- this.psService.sendMessage(false);
418
- this.snackBar.open(`${this.localizedVal('Submit failed!', this.localeCategory)}`, 'Ok');
419
- });
420
- } else {
421
- // let snackBarRef = this.snackBar.open("Please fix errors on form.", "Ok");
422
- this.erService.sendMessage('show', this.localizedVal('Please fix errors on form.', this.localeCategory));
423
- }
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
+ });
437
+
424
438
  break;
425
439
 
426
440
  case 'approveCase': {
@@ -430,7 +444,7 @@ export class AssignmentComponent implements OnInit, OnDestroy, OnChanges {
430
444
  .then(() => {})
431
445
  .catch(() => {
432
446
  this.psService.sendMessage(false);
433
- this.snackBar.open(`${this.localizedVal('Approve failed!', this.localeCategory)}`, 'Ok');
447
+ this.snackBarRef = this.snackBar.open(`${this.localizedVal('Approve failed!', this.localeCategory)}`, 'Ok');
434
448
  });
435
449
 
436
450
  break;
@@ -452,10 +466,41 @@ export class AssignmentComponent implements OnInit, OnDestroy, OnChanges {
452
466
  });
453
467
  }
454
468
 
455
- // eslint-disable-next-line sonarjs/no-identical-functions
456
469
  topViewRefresh(): void {
457
470
  Object.values(this.formGroup$.controls).forEach((control: any) => {
458
471
  control.markAsTouched();
459
472
  });
460
473
  }
474
+
475
+ registerForRefresh() {
476
+ // @ts-ignore - Property 'getActionRefreshConditions' is private and only accessible within class 'CaseInfo'
477
+ const refreshConditions = this.pConn$.getCaseInfo()?.getActionRefreshConditions();
478
+ const pageReference = this.pConn$.getPageReference();
479
+ const context = this.pConn$.getContextName();
480
+
481
+ // refresh api de-registration
482
+ PCore.getRefreshManager().deRegisterForRefresh(context);
483
+
484
+ // refresh api registration
485
+ const refreshProps = getRefreshProps(refreshConditions);
486
+ const caseKey = this.pConn$.getCaseInfo().getKey();
487
+ const refreshOptions = {
488
+ autoDetectRefresh: true,
489
+ preserveClientChanges: false
490
+ };
491
+ if (refreshProps.length > 0) {
492
+ refreshProps.forEach(prop => {
493
+ PCore.getRefreshManager().registerForRefresh(
494
+ 'PROP_CHANGE',
495
+ this.pConn$.getActionsApi().refreshCaseView.bind(this.pConn$.getActionsApi(), caseKey, '', pageReference, {
496
+ ...refreshOptions,
497
+ refreshFor: prop[0]
498
+ }),
499
+ `${pageReference}.${prop[1]}`,
500
+ `${context}/${pageReference}`,
501
+ context
502
+ );
503
+ });
504
+ }
505
+ }
461
506
  }
@@ -18,6 +18,7 @@
18
18
  <div class="psdk-case-view-divider"></div>
19
19
 
20
20
  <component-mapper
21
+ *ngIf="arMainButtons$ && arSecondaryButtons$"
21
22
  name="ActionButtons"
22
23
  [props]="{ arMainButtons$, arSecondaryButtons$ }"
23
24
  [parent]="this"
@@ -1,8 +1,10 @@
1
- import { Component, OnInit, Input, Output, EventEmitter, forwardRef, OnChanges } from '@angular/core';
1
+ import { Component, OnInit, Input, Output, EventEmitter, forwardRef, OnChanges, OnDestroy } from '@angular/core';
2
2
  import { CommonModule } from '@angular/common';
3
3
  import { FormGroup, ReactiveFormsModule } from '@angular/forms';
4
4
  import { ReferenceComponent } from '@pega/angular-sdk-components';
5
5
  import { ComponentMapperComponent } from '@pega/angular-sdk-components';
6
+ import { IdleDetectionService } from '@pega/angular-sdk-components';
7
+ import { ServerConfigService } from '@pega/angular-sdk-components';
6
8
 
7
9
  @Component({
8
10
  selector: 'app-assignment-card',
@@ -11,7 +13,7 @@ import { ComponentMapperComponent } from '@pega/angular-sdk-components';
11
13
  standalone: true,
12
14
  imports: [CommonModule, ReactiveFormsModule, forwardRef(() => ComponentMapperComponent)]
13
15
  })
14
- export class AssignmentCardComponent implements OnInit, OnChanges {
16
+ export class AssignmentCardComponent implements OnInit, OnChanges, OnDestroy {
15
17
  @Input() pConn$: typeof PConnect;
16
18
  @Input() formGroup$: FormGroup;
17
19
  @Input() arMainButtons$: any[];
@@ -21,10 +23,16 @@ export class AssignmentCardComponent implements OnInit, OnChanges {
21
23
 
22
24
  @Output() actionButtonClick: EventEmitter<any> = new EventEmitter();
23
25
 
26
+ constructor(
27
+ private idleService: IdleDetectionService,
28
+ private scservice: ServerConfigService
29
+ ) {}
30
+
24
31
  ngOnInit(): void {
25
- // Children may contain 'reference' component, so we need to
26
- // normalize them
32
+ // Children may contain 'reference' component, so we need to normalize them
27
33
  this.arChildren$ = ReferenceComponent.normalizePConnArray(this.arChildren$);
34
+
35
+ this.checkAndEnableAutoSave();
28
36
  }
29
37
 
30
38
  ngOnChanges() {
@@ -33,7 +41,27 @@ export class AssignmentCardComponent implements OnInit, OnChanges {
33
41
  this.arChildren$ = ReferenceComponent.normalizePConnArray(this.arChildren$);
34
42
  }
35
43
 
44
+ ngOnDestroy() {
45
+ this.idleService.stopWatching();
46
+ }
47
+
48
+ async checkAndEnableAutoSave() {
49
+ const sdkConfig = await this.scservice.getSdkConfig();
50
+ const autoSave = sdkConfig.serverConfig.autoSave;
51
+
52
+ if (autoSave) {
53
+ this.idleService.startWatching(() => this.autoSave(), autoSave);
54
+ }
55
+ }
56
+
36
57
  onActionButtonClick(oData: any) {
37
58
  this.actionButtonClick.emit(oData);
38
59
  }
60
+
61
+ autoSave() {
62
+ const context = this.pConn$.getContextName();
63
+ if (PCore.getFormUtils().isStateModified(context)) {
64
+ this.pConn$.getActionsApi().saveAssignment(context);
65
+ }
66
+ }
39
67
  }