@@ -9,6 +9,14 @@ import { ProgressSpinnerService } from '../../../_messages/progress-spinner.serv
99import { ReferenceComponent } from '../../infra/reference/reference.component' ;
1010import { ComponentMapperComponent } from '../../../_bridge/component-mapper/component-mapper.component' ;
1111
12+ function getRefreshProps ( refreshConditions ) {
13+ // refreshConditions cuurently supports only "Changes" event
14+ if ( ! refreshConditions ) {
15+ return [ ] ;
16+ }
17+ return refreshConditions . filter ( item => item . event && item . event === 'Changes' ) . map ( item => [ item . field , item . field ?. substring ( 1 ) ] ) || [ ] ;
18+ }
19+
1220interface AssignmentProps {
1321 // If any, enter additional props that only exist on this component
1422 template : string ;
@@ -128,6 +136,8 @@ export class AssignmentComponent implements OnInit, OnDestroy, OnChanges {
128136 }
129137
130138 updateChanges ( ) {
139+ this . registerForRefresh ( ) ;
140+
131141 // pConn$ may be a 'reference' component, so normalize it
132142 this . newPConn$ = ReferenceComponent . normalizePConn ( this . pConn$ ) ;
133143
@@ -452,10 +462,41 @@ export class AssignmentComponent implements OnInit, OnDestroy, OnChanges {
452462 } ) ;
453463 }
454464
455- // eslint-disable-next-line sonarjs/no-identical-functions
456465 topViewRefresh ( ) : void {
457466 Object . values ( this . formGroup$ . controls ) . forEach ( ( control : any ) => {
458467 control . markAsTouched ( ) ;
459468 } ) ;
460469 }
470+
471+ registerForRefresh ( ) {
472+ // @ts -ignore - Property 'getActionRefreshConditions' is private and only accessible within class 'CaseInfo'
473+ const refreshConditions = this . pConn$ . getCaseInfo ( ) ?. getActionRefreshConditions ( ) ;
474+ const pageReference = this . pConn$ . getPageReference ( ) ;
475+ const context = this . pConn$ . getContextName ( ) ;
476+
477+ // refresh api de-registration
478+ PCore . getRefreshManager ( ) . deRegisterForRefresh ( context ) ;
479+
480+ // refresh api registration
481+ const refreshProps = getRefreshProps ( refreshConditions ) ;
482+ const caseKey = this . pConn$ . getCaseInfo ( ) . getKey ( ) ;
483+ const refreshOptions = {
484+ autoDetectRefresh : true ,
485+ preserveClientChanges : false
486+ } ;
487+ if ( refreshProps . length > 0 ) {
488+ refreshProps . forEach ( prop => {
489+ PCore . getRefreshManager ( ) . registerForRefresh (
490+ 'PROP_CHANGE' ,
491+ this . pConn$ . getActionsApi ( ) . refreshCaseView . bind ( this . pConn$ . getActionsApi ( ) , caseKey , '' , pageReference , {
492+ ...refreshOptions ,
493+ refreshFor : prop [ 0 ]
494+ } ) ,
495+ `${ pageReference } .${ prop [ 1 ] } ` ,
496+ `${ context } /${ pageReference } ` ,
497+ context
498+ ) ;
499+ } ) ;
500+ }
501+ }
461502}
0 commit comments