Skip to content

Commit 51b0236

Browse files
committed
$'syncing commit from monoropo. PR: 248, Title: FIO-6122: Fixes an issue where angular renderer will not use the original form revision to view a submission'
1 parent d8bb4c6 commit 51b0236

File tree

1 file changed

+27
-21
lines changed

1 file changed

+27
-21
lines changed

projects/angular-formio/src/FormioBaseComponent.ts

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@ import {Form, Utils, Webform} from '@formio/js';
99
import { AlertsPosition } from './types/alerts-position';
1010
const { Evaluator, fastCloneDeep } = Utils;
1111

12-
@Component({
13-
template: '',
14-
standalone: false
15-
})
12+
@Component({ template: '' })
1613
export class FormioBaseComponent implements OnInit, OnChanges, OnDestroy {
1714
@Input() form?: FormioForm;
1815
@Input() submission?: any = {};
@@ -288,30 +285,39 @@ export class FormioBaseComponent implements OnInit, OnChanges, OnDestroy {
288285
}
289286
}
290287

291-
setFormFromSrc() {
288+
setFormFromSrc() {
289+
// if a submission is provided, load it first to set required form revision.
290+
if (
291+
isEmpty(this.submission) &&
292+
this.service &&
293+
this.service.formio.submissionId
294+
) {
295+
this.service.loadSubmission().subscribe(
296+
(submission: any) => {
297+
this.loadForm(() => {
298+
if (this.readOnly) {
299+
this.formio.options.readOnly = true;
300+
}
301+
this.submission = this.formio.submission = submission;
302+
});
303+
},
304+
err => this.onError(err)
305+
);
306+
} else {
307+
this.loadForm();
308+
}
309+
}
310+
311+
loadForm(done?: () => void) {
292312
this.service.loadForm({ params: { live: 1 } }).subscribe(
293313
(form: FormioForm) => {
294314
if (form && form.components) {
295315
this.ngZone.runOutsideAngular(() => {
296316
this.setForm(form);
297317
});
298318
}
299-
300-
// if a submission is also provided.
301-
if (
302-
isEmpty(this.submission) &&
303-
this.service &&
304-
this.service.formio.submissionId
305-
) {
306-
this.service.loadSubmission().subscribe(
307-
(submission: any) => {
308-
if (this.readOnly) {
309-
this.formio.options.readOnly = true;
310-
}
311-
this.submission = this.formio.submission = submission;
312-
},
313-
err => this.onError(err)
314-
);
319+
if (done) {
320+
done();
315321
}
316322
},
317323
err => this.onError(err)

0 commit comments

Comments
 (0)