@formio/js 5.1.0-dev.6019.b7cdf53 → 5.1.0-dev.6021.879d00c
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/formio.form.js +1 -1
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.full.js +1 -1
- package/dist/formio.full.min.js +1 -1
- package/lib/cjs/components/form/Form.d.ts +4 -2
- package/lib/cjs/components/form/Form.js +12 -7
- package/lib/mjs/components/form/Form.d.ts +4 -2
- package/lib/mjs/components/form/Form.js +12 -7
- package/package.json +1 -1
@@ -45,16 +45,18 @@ export default class FormComponent extends Component {
|
|
45
45
|
/**
|
46
46
|
* Create a subform instance.
|
47
47
|
* @param {boolean} [fromAttach] - This function is being called from an `attach` method.
|
48
|
+
* @param {boolean} [beforeSubmit] - This function is being called from a `beforeSubmit` method.
|
48
49
|
* @returns {*} - The subform instance.
|
49
50
|
*/
|
50
|
-
createSubForm(fromAttach?: boolean | undefined): any;
|
51
|
+
createSubForm(fromAttach?: boolean | undefined, beforeSubmit?: boolean | undefined): any;
|
51
52
|
hideSubmitButton(component: any): void;
|
52
53
|
/**
|
53
54
|
* Load the subform.
|
54
55
|
* @param {boolean} fromAttach - This function is being called from an `attach` method.
|
56
|
+
* @param {boolean} beforeSubmit - This function is being called from a `beforeSubmit` method.
|
55
57
|
* @returns {Promise} - The promise that resolves when the subform is loaded.
|
56
58
|
*/
|
57
|
-
loadSubForm(fromAttach: boolean): Promise<any>;
|
59
|
+
loadSubForm(fromAttach: boolean, beforeSubmit: boolean): Promise<any>;
|
58
60
|
subFormLoading: boolean | undefined;
|
59
61
|
checkComponentConditions(data: any, flags: any, row: any): any;
|
60
62
|
calculateValue(data: any, flags: any, row: any): any;
|
@@ -380,10 +380,11 @@ class FormComponent extends Component_1.default {
|
|
380
380
|
/**
|
381
381
|
* Create a subform instance.
|
382
382
|
* @param {boolean} [fromAttach] - This function is being called from an `attach` method.
|
383
|
+
* @param {boolean} [beforeSubmit] - This function is being called from a `beforeSubmit` method.
|
383
384
|
* @returns {*} - The subform instance.
|
384
385
|
*/
|
385
|
-
createSubForm(fromAttach) {
|
386
|
-
this.subFormReady = this.loadSubForm(fromAttach).then((form) => {
|
386
|
+
createSubForm(fromAttach, beforeSubmit) {
|
387
|
+
this.subFormReady = this.loadSubForm(fromAttach, beforeSubmit).then((form) => {
|
387
388
|
if (!form) {
|
388
389
|
return;
|
389
390
|
}
|
@@ -440,11 +441,13 @@ class FormComponent extends Component_1.default {
|
|
440
441
|
/**
|
441
442
|
* Load the subform.
|
442
443
|
* @param {boolean} fromAttach - This function is being called from an `attach` method.
|
444
|
+
* @param {boolean} beforeSubmit - This function is being called from a `beforeSubmit` method.
|
443
445
|
* @returns {Promise} - The promise that resolves when the subform is loaded.
|
444
446
|
*/
|
445
|
-
loadSubForm(fromAttach) {
|
447
|
+
loadSubForm(fromAttach, beforeSubmit) {
|
446
448
|
var _a, _b, _c, _d, _e;
|
447
|
-
|
449
|
+
const loadHiddenForm = beforeSubmit && !this.component.clearOnHide;
|
450
|
+
if (this.builderMode || (this.conditionallyHidden && !loadHiddenForm) || (this.isSubFormLazyLoad() && !fromAttach)) {
|
448
451
|
return Promise.resolve();
|
449
452
|
}
|
450
453
|
if (this.hasLoadedForm && !this.isRevisionChanged &&
|
@@ -516,7 +519,7 @@ class FormComponent extends Component_1.default {
|
|
516
519
|
* @returns {*|boolean} - TRUE if the subform should be submitted, FALSE if it should not.
|
517
520
|
*/
|
518
521
|
get shouldSubmit() {
|
519
|
-
return this.subFormReady && (!this.component.hasOwnProperty('reference') || this.component.reference) && !this.conditionallyHidden;
|
522
|
+
return this.subFormReady && (!this.component.hasOwnProperty('reference') || this.component.reference) && (!this.conditionallyHidden || !this.component.clearOnHide);
|
520
523
|
}
|
521
524
|
/**
|
522
525
|
* Returns the data for the subform.
|
@@ -587,8 +590,10 @@ class FormComponent extends Component_1.default {
|
|
587
590
|
this.dataValue = submission;
|
588
591
|
return Promise.resolve(this.dataValue);
|
589
592
|
}
|
590
|
-
|
591
|
-
|
593
|
+
// we need to load a hidden form (when clearOnHide is disabled) in order to get and submit (if needed) its data
|
594
|
+
const loadHiddenForm = !this.subForm && !this.component.clearOnHide;
|
595
|
+
if ((this.isSubFormLazyLoad() || loadHiddenForm) && !this.subFormLoading) {
|
596
|
+
return this.createSubForm(true, true)
|
592
597
|
.then(this.submitSubForm(false))
|
593
598
|
.then(() => {
|
594
599
|
return this.dataValue;
|
@@ -45,16 +45,18 @@ export default class FormComponent extends Component {
|
|
45
45
|
/**
|
46
46
|
* Create a subform instance.
|
47
47
|
* @param {boolean} [fromAttach] - This function is being called from an `attach` method.
|
48
|
+
* @param {boolean} [beforeSubmit] - This function is being called from a `beforeSubmit` method.
|
48
49
|
* @returns {*} - The subform instance.
|
49
50
|
*/
|
50
|
-
createSubForm(fromAttach?: boolean | undefined): any;
|
51
|
+
createSubForm(fromAttach?: boolean | undefined, beforeSubmit?: boolean | undefined): any;
|
51
52
|
hideSubmitButton(component: any): void;
|
52
53
|
/**
|
53
54
|
* Load the subform.
|
54
55
|
* @param {boolean} fromAttach - This function is being called from an `attach` method.
|
56
|
+
* @param {boolean} beforeSubmit - This function is being called from a `beforeSubmit` method.
|
55
57
|
* @returns {Promise} - The promise that resolves when the subform is loaded.
|
56
58
|
*/
|
57
|
-
loadSubForm(fromAttach: boolean): Promise<any>;
|
59
|
+
loadSubForm(fromAttach: boolean, beforeSubmit: boolean): Promise<any>;
|
58
60
|
subFormLoading: boolean | undefined;
|
59
61
|
checkComponentConditions(data: any, flags: any, row: any): any;
|
60
62
|
calculateValue(data: any, flags: any, row: any): any;
|
@@ -375,10 +375,11 @@ export default class FormComponent extends Component {
|
|
375
375
|
/**
|
376
376
|
* Create a subform instance.
|
377
377
|
* @param {boolean} [fromAttach] - This function is being called from an `attach` method.
|
378
|
+
* @param {boolean} [beforeSubmit] - This function is being called from a `beforeSubmit` method.
|
378
379
|
* @returns {*} - The subform instance.
|
379
380
|
*/
|
380
|
-
createSubForm(fromAttach) {
|
381
|
-
this.subFormReady = this.loadSubForm(fromAttach).then((form) => {
|
381
|
+
createSubForm(fromAttach, beforeSubmit) {
|
382
|
+
this.subFormReady = this.loadSubForm(fromAttach, beforeSubmit).then((form) => {
|
382
383
|
if (!form) {
|
383
384
|
return;
|
384
385
|
}
|
@@ -435,10 +436,12 @@ export default class FormComponent extends Component {
|
|
435
436
|
/**
|
436
437
|
* Load the subform.
|
437
438
|
* @param {boolean} fromAttach - This function is being called from an `attach` method.
|
439
|
+
* @param {boolean} beforeSubmit - This function is being called from a `beforeSubmit` method.
|
438
440
|
* @returns {Promise} - The promise that resolves when the subform is loaded.
|
439
441
|
*/
|
440
|
-
loadSubForm(fromAttach) {
|
441
|
-
|
442
|
+
loadSubForm(fromAttach, beforeSubmit) {
|
443
|
+
const loadHiddenForm = beforeSubmit && !this.component.clearOnHide;
|
444
|
+
if (this.builderMode || (this.conditionallyHidden && !loadHiddenForm) || (this.isSubFormLazyLoad() && !fromAttach)) {
|
442
445
|
return Promise.resolve();
|
443
446
|
}
|
444
447
|
if (this.hasLoadedForm && !this.isRevisionChanged &&
|
@@ -510,7 +513,7 @@ export default class FormComponent extends Component {
|
|
510
513
|
* @returns {*|boolean} - TRUE if the subform should be submitted, FALSE if it should not.
|
511
514
|
*/
|
512
515
|
get shouldSubmit() {
|
513
|
-
return this.subFormReady && (!this.component.hasOwnProperty('reference') || this.component.reference) && !this.conditionallyHidden;
|
516
|
+
return this.subFormReady && (!this.component.hasOwnProperty('reference') || this.component.reference) && (!this.conditionallyHidden || !this.component.clearOnHide);
|
514
517
|
}
|
515
518
|
/**
|
516
519
|
* Returns the data for the subform.
|
@@ -580,8 +583,10 @@ export default class FormComponent extends Component {
|
|
580
583
|
this.dataValue = submission;
|
581
584
|
return Promise.resolve(this.dataValue);
|
582
585
|
}
|
583
|
-
|
584
|
-
|
586
|
+
// we need to load a hidden form (when clearOnHide is disabled) in order to get and submit (if needed) its data
|
587
|
+
const loadHiddenForm = !this.subForm && !this.component.clearOnHide;
|
588
|
+
if ((this.isSubFormLazyLoad() || loadHiddenForm) && !this.subFormLoading) {
|
589
|
+
return this.createSubForm(true, true)
|
585
590
|
.then(this.submitSubForm(false))
|
586
591
|
.then(() => {
|
587
592
|
return this.dataValue;
|