diff --git a/packages/angular-sdk-components/src/lib/_components/infra/assignment/assignment.component.ts b/packages/angular-sdk-components/src/lib/_components/infra/assignment/assignment.component.ts index d9da6926..b28362f6 100644 --- a/packages/angular-sdk-components/src/lib/_components/infra/assignment/assignment.component.ts +++ b/packages/angular-sdk-components/src/lib/_components/infra/assignment/assignment.component.ts @@ -9,6 +9,14 @@ import { ProgressSpinnerService } from '../../../_messages/progress-spinner.serv import { ReferenceComponent } from '../../infra/reference/reference.component'; import { ComponentMapperComponent } from '../../../_bridge/component-mapper/component-mapper.component'; +function getRefreshProps(refreshConditions) { + // refreshConditions cuurently supports only "Changes" event + if (!refreshConditions) { + return []; + } + return refreshConditions.filter(item => item.event && item.event === 'Changes').map(item => [item.field, item.field?.substring(1)]) || []; +} + interface AssignmentProps { // If any, enter additional props that only exist on this component template: string; @@ -127,6 +135,8 @@ export class AssignmentComponent implements OnInit, OnDestroy, OnChanges { } updateChanges() { + this.registerForRefresh(); + this.bIsRefComponent = this.checkIfRefComponent(this.pConn$); this.ngZone.run(() => { @@ -460,4 +470,36 @@ export class AssignmentComponent implements OnInit, OnDestroy, OnChanges { control.markAsTouched(); }); } + + registerForRefresh() { + // @ts-ignore - Property 'getActionRefreshConditions' is private and only accessible within class 'CaseInfo' + const refreshConditions = this.pConn$.getCaseInfo()?.getActionRefreshConditions(); + const pageReference = this.pConn$.getPageReference(); + const context = this.pConn$.getContextName(); + + // refresh api de-registration + PCore.getRefreshManager().deRegisterForRefresh(context); + + // refresh api registration + const refreshProps = getRefreshProps(refreshConditions); + const caseKey = this.pConn$.getCaseInfo().getKey(); + const refreshOptions = { + autoDetectRefresh: true, + preserveClientChanges: false + }; + if (refreshProps.length > 0) { + refreshProps.forEach(prop => { + PCore.getRefreshManager().registerForRefresh( + 'PROP_CHANGE', + this.pConn$.getActionsApi().refreshCaseView.bind(this.pConn$.getActionsApi(), caseKey, null, pageReference, { + ...refreshOptions, + refreshFor: prop[0] + }), + `${pageReference}.${prop[1]}`, + `${context}/${pageReference}`, + context + ); + }); + } + } }