Untitled
unknown
plain_text
3 years ago
2.7 kB
10
Indexable
private getRequestObservables(caseIds, prefillInfo, componentHistory) {
const observables = {};
if (!caseIds.aggregateIdentifier && prefillInfo) {
this.toastNotif.showNotification(ToastSeverityList.Warn, `WRONG CONFIGURATION!! You want prefill with a data which is unavailable`)
return of({});
}
Object.keys(prefillInfo).forEach((key) => {
let oldFormKeyHolder = key;
if(key==='GeneralInformation' || key === 'GENERAL_INFORMATION'){
observables[key] = this.formService
.getCaseGeneralInformation(this.aggregateIdentifier).pipe(
map(caseGeneralInfo=>caseGeneralInfo.Payload)
)
} else {
const workflowComponent = componentHistory.find(
(history) => history.WorkflowComponentCode === key || history.WorkflowComponentCode === key.replace('FC ', '').replace('.', '_'),
);
if (!workflowComponent) {
this.toastNotif.showNotification(
ToastSeverityList.Warn,
'You want to prefill from a component which is not found in the workflow history. I still try to prefill it from the subprocess.',
);
} else if (!workflowComponent.WorkflowComponentCode.includes('FC')) {
oldFormKeyHolder = oldFormKeyHolder.replace('FC ', '').replace('.', '_');
}
observables[key] = this.getCaseInformation(
workflowComponent?.AggregateIdentifier || caseIds.aggregateIdentifier,
workflowComponent?.SubProcessIdentifier || caseIds.subProcessId,
oldFormKeyHolder,
).pipe(
map((command) => {
if(!command?.Payload?.Data?.length){
return this.formService.tryToLoadOldTableDate(
caseIds.aggregateIdentifier,
workflowComponent?.SubProcessIdentifier || caseIds.subProcessId,
key,
this.formId,
);
}else{
return command.Payload.Data;
}
}),
catchError((error) => {
return this.formService.tryToLoadOldTableDate(
caseIds.aggregateIdentifier,
workflowComponent?.SubProcessIdentifier || caseIds.subProcessId,
key,
this.formId,
);
}),
catchError((err) => {
this.toastNotif.showNotification(
ToastSeverityList.Warn,
`The prefill from the form ${key} is not possible, because the endpoint is not reachable`,
);
return of({});
}),
);
}
});
return Object.keys(observables).length ? forkJoin(observables).pipe(catchError((error) => of({}))) : of({});
}
Editor is loading...