Skip to content

Commit

Permalink
story/add-documentId-to-start-form add documentId to fvm start view m…
Browse files Browse the repository at this point in the history
…odel
  • Loading branch information
floris-thijssen-ritense committed Jan 16, 2025
1 parent 02f12f7 commit dd27b1a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,15 +176,17 @@ export class DossierSupportingProcessStartModalComponent {
this.processDefinitionKey$,
this.documentDefinitionName$,
this.options$,
this.documentId$,
])
.pipe(take(1))
.subscribe(([form, processDefinitionKey, documentDefinitionName, options]) => {
.subscribe(([form, processDefinitionKey, documentDefinitionName, options, documentId]) => {
formViewModelComponent.instance.formName = formName;
formViewModelComponent.instance.form = form;
formViewModelComponent.instance.processDefinitionKey = processDefinitionKey;
formViewModelComponent.instance.documentDefinitionName = documentDefinitionName;
formViewModelComponent.instance.options = options;
formViewModelComponent.instance.isStartForm = true;
formViewModelComponent.instance.documentId = documentId;
});

formViewModelComponent.instance.formSubmit.pipe(take(1)).subscribe(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ export class FormViewModelComponent implements OnInit, OnDestroy {
this.isStartForm$.next(isStartFormValue);
}

@Input() set documentId(documentId: string) {
this.documentId$.next(documentId);
}

@Input() set processDefinitionKey(processDefinitionKeyValue: string) {
this.processDefinitionKey$.next(processDefinitionKeyValue);
}
Expand Down Expand Up @@ -113,6 +117,7 @@ export class FormViewModelComponent implements OnInit, OnDestroy {
public readonly focus$ = new BehaviorSubject<FocusEvent>(null);
public readonly loading$ = new BehaviorSubject<boolean>(true);
public readonly isStartForm$ = new BehaviorSubject<boolean>(false);
public readonly documentId$ = new BehaviorSubject<string>(null);
public readonly processDefinitionKey$ = new BehaviorSubject<string>(undefined);
public readonly documentDefinitionName$ = new BehaviorSubject<string>(undefined);
public readonly updateForm = new Subject<boolean>();
Expand Down Expand Up @@ -385,11 +390,11 @@ export class FormViewModelComponent implements OnInit, OnDestroy {
}

public loadInitialViewModelForStartForm(): void {
combineLatest([this.formName$, this.processDefinitionKey$])
combineLatest([this.formName$, this.processDefinitionKey$, this.documentId$])
.pipe(
take(1),
switchMap(([formName, processDefinitionKey]) =>
this.viewModelService.getViewModelForStartForm(formName, processDefinitionKey).pipe(
switchMap(([formName, processDefinitionKey, documentId]) =>
this.viewModelService.getViewModelForStartForm(formName, processDefinitionKey, documentId).pipe(
tap(viewModel => {
this.submission$.next({data: viewModel});
this.change$.pipe(take(1)).subscribe(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,14 @@ export class ViewModelService extends BaseApiService {

public getViewModelForStartForm(
formName: string,
processDefinitionKey: string
processDefinitionKey: string,
documentId: string = null,
): Observable<object> {
return this.httpClient.get<any>(this.getApiUrl('/v1/form/view-model/start-form'), {
params: {
formName,
processDefinitionKey,
documentId,
},
headers: new HttpHeaders().set(InterceptorSkip, '400'),
});
Expand Down

0 comments on commit dd27b1a

Please sign in to comment.