@formio/js 5.1.0-dev.6024.3b197fc → 5.1.0-dev.6026.7f60c92
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 +2 -2
- package/dist/formio.full.min.js +1 -1
- package/lib/cjs/WizardBuilder.d.ts +1 -0
- package/lib/cjs/WizardBuilder.js +21 -2
- package/lib/cjs/components/form/Form.d.ts +4 -2
- package/lib/cjs/components/form/Form.js +12 -7
- package/lib/mjs/WizardBuilder.d.ts +1 -0
- package/lib/mjs/WizardBuilder.js +21 -2
- package/lib/mjs/components/form/Form.d.ts +4 -2
- package/lib/mjs/components/form/Form.js +12 -7
- package/package.json +1 -1
package/lib/cjs/WizardBuilder.js
CHANGED
@@ -261,12 +261,31 @@ class WizardBuilder extends WebformBuilder_1.default {
|
|
261
261
|
if (component instanceof WizardBuilder) {
|
262
262
|
return;
|
263
263
|
}
|
264
|
-
if (
|
265
|
-
this.
|
264
|
+
if (!window.sessionStorage) {
|
265
|
+
return console.warn(this.t('sessionStorageSupportError'));
|
266
|
+
}
|
267
|
+
const isWizardPageCopied = window.sessionStorage.getItem('formio.isWizardPageCopied') === 'true' ? true : false;
|
268
|
+
if (isWizardPageCopied) {
|
269
|
+
const data = window.sessionStorage.getItem('formio.clipboard');
|
270
|
+
if (data) {
|
271
|
+
const schema = JSON.parse(data);
|
272
|
+
if (schema.type !== 'panel') {
|
273
|
+
window.sessionStorage.setItem('formio.isWizardPageCopied', 'false');
|
274
|
+
return super.pasteComponent(component);
|
275
|
+
}
|
276
|
+
this.addPage(schema);
|
277
|
+
}
|
266
278
|
}
|
267
279
|
else {
|
268
280
|
return super.pasteComponent(component);
|
269
281
|
}
|
270
282
|
}
|
283
|
+
copyComponent(component) {
|
284
|
+
super.copyComponent(component);
|
285
|
+
if (window.sessionStorage) {
|
286
|
+
const isWizardPageCopied = this._form.components.indexOf(comp => lodash_1.default.isEqual(component.component, comp)) !== -1;
|
287
|
+
window.sessionStorage.setItem('formio.isWizardPageCopied', isWizardPageCopied.toString());
|
288
|
+
}
|
289
|
+
}
|
271
290
|
}
|
272
291
|
exports.default = WizardBuilder;
|
@@ -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;
|
package/lib/mjs/WizardBuilder.js
CHANGED
@@ -255,11 +255,30 @@ export default class WizardBuilder extends WebformBuilder {
|
|
255
255
|
if (component instanceof WizardBuilder) {
|
256
256
|
return;
|
257
257
|
}
|
258
|
-
if (
|
259
|
-
this.
|
258
|
+
if (!window.sessionStorage) {
|
259
|
+
return console.warn(this.t('sessionStorageSupportError'));
|
260
|
+
}
|
261
|
+
const isWizardPageCopied = window.sessionStorage.getItem('formio.isWizardPageCopied') === 'true' ? true : false;
|
262
|
+
if (isWizardPageCopied) {
|
263
|
+
const data = window.sessionStorage.getItem('formio.clipboard');
|
264
|
+
if (data) {
|
265
|
+
const schema = JSON.parse(data);
|
266
|
+
if (schema.type !== 'panel') {
|
267
|
+
window.sessionStorage.setItem('formio.isWizardPageCopied', 'false');
|
268
|
+
return super.pasteComponent(component);
|
269
|
+
}
|
270
|
+
this.addPage(schema);
|
271
|
+
}
|
260
272
|
}
|
261
273
|
else {
|
262
274
|
return super.pasteComponent(component);
|
263
275
|
}
|
264
276
|
}
|
277
|
+
copyComponent(component) {
|
278
|
+
super.copyComponent(component);
|
279
|
+
if (window.sessionStorage) {
|
280
|
+
const isWizardPageCopied = this._form.components.indexOf(comp => _.isEqual(component.component, comp)) !== -1;
|
281
|
+
window.sessionStorage.setItem('formio.isWizardPageCopied', isWizardPageCopied.toString());
|
282
|
+
}
|
283
|
+
}
|
265
284
|
}
|
@@ -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;
|