Skip to content

Commit

Permalink
fix: refresh call not happening for calculated fields
Browse files Browse the repository at this point in the history
  • Loading branch information
tumms2021389 committed May 23, 2024
1 parent 9776770 commit ac4f192
Showing 1 changed file with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -127,6 +135,8 @@ export class AssignmentComponent implements OnInit, OnDestroy, OnChanges {
}

updateChanges() {
this.registerForRefresh();

this.bIsRefComponent = this.checkIfRefComponent(this.pConn$);

this.ngZone.run(() => {
Expand Down Expand Up @@ -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
);
});
}
}
}

0 comments on commit ac4f192

Please sign in to comment.