Skip to content

Commit 96d9193

Browse files
committed
fix: Prevents the finish assignment screen from appearing when opening an assignment assigned to a different operator
1 parent cb1ed12 commit 96d9193

File tree

7 files changed

+25
-53
lines changed

7 files changed

+25
-53
lines changed

packages/angular-sdk-components/src/lib/_components/infra/Containers/flow-container/flow-container.component.ts

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { publicConstants } from '@pega/pcore-pconnect-typedefs/constants';
66
import { ProgressSpinnerService } from '../../../../_messages/progress-spinner.service';
77
import { ReferenceComponent } from '../../reference/reference.component';
88
import { Utils } from '../../../../_helpers/utils';
9-
import { getToDoAssignments, showBanner } from './helpers';
9+
import { getToDoAssignments, hasAssignments, showBanner } from './helpers';
1010
import { ComponentMapperComponent } from '../../../../_bridge/component-mapper/component-mapper.component';
1111
import { FlowContainerBaseComponent } from '../base-components/flow-container-base.component';
1212

@@ -277,41 +277,6 @@ export class FlowContainerComponent extends FlowContainerBaseComponent implement
277277
this.psService.sendMessage(false);
278278
}
279279

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-
315280
isCaseWideLocalAction() {
316281
const actionID = this.pConn$.getValue(this.pCoreConstants.CASE_INFO.ACTIVE_ACTION_ID);
317282
const caseActions = this.pConn$.getValue(this.pCoreConstants.CASE_INFO.AVAILABLEACTIONS);
@@ -461,7 +426,7 @@ export class FlowContainerComponent extends FlowContainerBaseComponent implement
461426
this.caseMessages$ = this.localizedVal(this.pConn$.getValue('caseMessages'), this.localeCategory);
462427
// caseMessages's behavior has changed in 24.2, and hence it doesn't let Optional Action work.
463428
// Changing the below condition for now. Was: (theCaseMessages || !hasAssignments())
464-
if (!this.hasAssignments()) {
429+
if (!hasAssignments(this.pConn$)) {
465430
this.bHasCaseMessages$ = true;
466431
this.bShowConfirm = true;
467432
this.checkSvg$ = this.utils.getImageSrc('check', this.utils.getSDKStaticContentUrl());
@@ -471,9 +436,6 @@ export class FlowContainerComponent extends FlowContainerBaseComponent implement
471436
this.caseMessages$ = this.localizedVal('Thank you! The next step in this case has been routed appropriately.', this.localeCategory);
472437
}
473438

474-
// publish this "assignmentFinished" for mashup, need to get approved as a standard
475-
PCore.getPubSubUtils().publish('assignmentFinished');
476-
477439
this.psService.sendMessage(false);
478440
} else {
479441
this.bHasCaseMessages$ = false;

packages/angular-sdk-components/src/lib/_components/infra/Containers/flow-container/helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function getChildCaseAssignments(pConnect) {
2828
return allAssignments;
2929
}
3030

31-
function hasAssignments(pConnect) {
31+
export function hasAssignments(pConnect) {
3232
const { CASE_INFO } = PCore.getConstants();
3333
const assignments = pConnect.getValue(CASE_INFO.D_CASE_ASSIGNMENTS_RESULTS);
3434
const childCasesAssignments = getChildCaseAssignments(pConnect);

packages/angular-sdk-components/src/lib/_components/widget/todo/todo.component.html

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
<div class="psdk-todo">
2-
<div class="psdk-todo-header">
3-
<div *ngIf="showTodoList$" class="psdk-avatar">{{ this.currentUserInitials$ }}</div>
2+
<div *ngIf="showTodoList$" class="psdk-todo-header">
3+
<div class="psdk-avatar">{{ this.currentUserInitials$ }}</div>
44
<div id="worklist" class="psdk-todo-text">{{ headerText$ }}</div>
5-
<div *ngIf="showTodoList$" class="psdk-assignment-count">{{ count }}</div>
5+
<div class="psdk-assignment-count">{{ count }}</div>
66
</div>
7-
<br /><br />
87
<div *ngIf="showTodoList$" class="psdk-display-divider"></div>
98

109
<div class="psdk-todo-assignments">
@@ -27,7 +26,7 @@
2726
</div>
2827
</div>
2928
</div>
30-
<div class="psdk-todo-assignment-action" *ngIf="!isConfirm || canPerform">
29+
<div *ngIf="!isConfirm || canPerform" class="psdk-todo-assignment-action">
3130
<button mat-flat-button color="primary" (click)="clickGo(assignment)">{{ localizedVal('Go', localeCategory) }}</button>
3231
</div>
3332
</div>

packages/angular-sdk-components/src/lib/_components/widget/todo/todo.component.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1+
.psdk-todo-assignments > *:last-child {
2+
.psdk-display-divider {
3+
display: none;
4+
}
5+
}
6+
17
.psdk-display-divider {
28
border-bottom: 0.0625rem solid var(--app-neutral-light-color);
9+
margin-block: 0.5rem;
310
}
411

512
.psdk-todo {
@@ -12,6 +19,7 @@
1219

1320
.psdk-todo-header {
1421
display: inline-flex;
22+
margin-bottom: 1rem;
1523
}
1624

1725
.psdk-todo-text {

packages/angular-sdk-components/src/lib/_components/widget/todo/todo.component.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ export class TodoComponent implements OnInit, OnDestroy {
9191
localeCategory = 'Todo';
9292
showlessLocalizedValue = this.localizedVal('show_less', 'CosmosFields');
9393
showMoreLocalizedValue = this.localizedVal('show_more', 'CosmosFields');
94-
canPerform: boolean;
9594
count: number;
9695

9796
constructor(
@@ -119,6 +118,10 @@ export class TodoComponent implements OnInit, OnDestroy {
119118
PCore.getPubSubUtils().unsubscribe(CREATE_STAGE_DELETED, CREATE_STAGE_DELETED);
120119
}
121120

121+
get canPerform() {
122+
return this.assignmentsSource$?.[0]?.canPerform === 'true' || this.assignmentsSource$?.[0]?.canPerform === true;
123+
}
124+
122125
updateList() {
123126
const {
124127
WORK_BASKET: {
@@ -156,8 +159,6 @@ export class TodoComponent implements OnInit, OnDestroy {
156159
}
157160
}
158161

159-
this.canPerform = this.arAssignments$?.[0]?.canPerform === 'true' || this.arAssignments$?.[0]?.canPerform === true;
160-
161162
this.currentUser$ = PCore.getEnvironmentInfo().getOperatorName();
162163
this.currentUserInitials$ = this.utils.getInitials(this.currentUser$ ?? '');
163164
}

projects/angular-test-app/src/app/_samples/embedded/main-screen/main-screen.component.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export class MainScreenComponent implements OnInit, OnDestroy {
2929
) {}
3030

3131
ngOnInit(): void {
32+
// Subscribe to the EVENT_CANCEL event to handle the assignment cancellation
3233
PCore.getPubSubUtils().subscribe(
3334
PCore.getConstants().PUB_SUB_EVENTS.EVENT_CANCEL,
3435
() => {
@@ -37,19 +38,20 @@ export class MainScreenComponent implements OnInit, OnDestroy {
3738
'cancelAssignment'
3839
);
3940

41+
// Subscribe to the END_OF_ASSIGNMENT_PROCESSING event to handle assignment completion
4042
PCore.getPubSubUtils().subscribe(
41-
'assignmentFinished',
43+
PCore.getConstants().PUB_SUB_EVENTS.CASE_EVENTS.END_OF_ASSIGNMENT_PROCESSING,
4244
() => {
4345
this.assignmentFinished();
4446
},
45-
'assignmentFinished'
47+
'endOfAssignmentProcessing'
4648
);
4749
}
4850

4951
ngOnDestroy() {
5052
PCore.getPubSubUtils().unsubscribe(PCore.getConstants().PUB_SUB_EVENTS.EVENT_CANCEL, 'cancelAssignment');
5153

52-
PCore.getPubSubUtils().unsubscribe('assignmentFinished', 'assignmentFinished');
54+
PCore.getPubSubUtils().unsubscribe(PCore.getConstants().PUB_SUB_EVENTS.CASE_EVENTS.END_OF_ASSIGNMENT_PROCESSING, 'endOfAssignmentProcessing');
5355
}
5456

5557
cancelAssignment() {

projects/angular-test-app/src/containerStyles.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ app-flow-container {
1414

1515
.psdk-flow-container-top {
1616
background-color: var(--app-form-color);
17-
padding: 0rem 0.625rem;
17+
padding: 0.5rem 0.625rem;
1818
border-radius: 0.3125rem;
1919
}
2020
.psdk-flow-container {

0 commit comments

Comments
 (0)