@formio/js 5.0.0-dev.5632.8d1873d → 5.0.0-dev.5633.3e0990b
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/Changelog.md +8 -0
- package/dist/formio.builder.css +0 -4
- package/dist/formio.builder.min.css +1 -1
- package/dist/formio.form.css +0 -4
- package/dist/formio.form.js +4 -4
- package/dist/formio.form.min.css +1 -1
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.full.css +0 -4
- package/dist/formio.full.js +5 -5
- package/dist/formio.full.min.css +1 -1
- package/dist/formio.full.min.js +1 -1
- package/lib/cjs/Webform.d.ts +7 -0
- package/lib/cjs/Webform.js +15 -5
- package/lib/cjs/WebformBuilder.js +8 -2
- package/lib/cjs/components/_classes/component/Component.d.ts +14 -1
- package/lib/cjs/components/_classes/component/Component.js +24 -14
- package/lib/cjs/components/form/Form.d.ts +7 -0
- package/lib/cjs/components/form/Form.js +17 -7
- package/lib/cjs/components/signature/Signature.js +1 -1
- package/lib/mjs/Webform.d.ts +7 -0
- package/lib/mjs/Webform.js +15 -5
- package/lib/mjs/WebformBuilder.js +8 -2
- package/lib/mjs/components/_classes/component/Component.d.ts +14 -1
- package/lib/mjs/components/_classes/component/Component.js +32 -14
- package/lib/mjs/components/form/Form.d.ts +7 -0
- package/lib/mjs/components/form/Form.js +15 -5
- package/lib/mjs/components/signature/Signature.js +1 -1
- package/package.json +1 -1
package/lib/cjs/Webform.d.ts
CHANGED
|
@@ -356,6 +356,13 @@ declare class Webform extends NestedDataComponent {
|
|
|
356
356
|
* @returns {Object}
|
|
357
357
|
*/
|
|
358
358
|
get submission(): Object;
|
|
359
|
+
/**
|
|
360
|
+
* Sets the submission value
|
|
361
|
+
* @param {object|null|undefined} submission - The submission to set.
|
|
362
|
+
* @param {object|null|undefined} flags - Any flags to apply when setting the submission.
|
|
363
|
+
* @return {void}
|
|
364
|
+
*/
|
|
365
|
+
onSetSubmission(submission: object | null | undefined, flags?: object | null | undefined): void;
|
|
359
366
|
/**
|
|
360
367
|
* Sets a submission and returns the promise when it is ready.
|
|
361
368
|
* @param submission
|
package/lib/cjs/Webform.js
CHANGED
|
@@ -716,6 +716,18 @@ class Webform extends NestedDataComponent_1.default {
|
|
|
716
716
|
set submission(submission) {
|
|
717
717
|
this.setSubmission(submission);
|
|
718
718
|
}
|
|
719
|
+
/**
|
|
720
|
+
* Sets the submission value
|
|
721
|
+
* @param {object|null|undefined} submission - The submission to set.
|
|
722
|
+
* @param {object|null|undefined} flags - Any flags to apply when setting the submission.
|
|
723
|
+
* @return {void}
|
|
724
|
+
*/
|
|
725
|
+
onSetSubmission(submission, flags = {}) {
|
|
726
|
+
this.submissionSet = true;
|
|
727
|
+
this.triggerChange(flags);
|
|
728
|
+
this.emit('beforeSetSubmission', submission);
|
|
729
|
+
this.setValue(submission, flags);
|
|
730
|
+
}
|
|
719
731
|
/**
|
|
720
732
|
* Sets a submission and returns the promise when it is ready.
|
|
721
733
|
* @param submission
|
|
@@ -728,10 +740,7 @@ class Webform extends NestedDataComponent_1.default {
|
|
|
728
740
|
if (resolveFlags) {
|
|
729
741
|
flags = Object.assign(Object.assign({}, flags), resolveFlags);
|
|
730
742
|
}
|
|
731
|
-
this.
|
|
732
|
-
this.triggerChange(flags);
|
|
733
|
-
this.emit('beforeSetSubmission', submission);
|
|
734
|
-
this.setValue(submission, flags);
|
|
743
|
+
this.onSetSubmission(submission, flags);
|
|
735
744
|
return this.submissionReadyResolve(submission);
|
|
736
745
|
}, (err) => this.submissionReadyReject(err)).catch((err) => this.submissionReadyReject(err));
|
|
737
746
|
}
|
|
@@ -787,7 +796,8 @@ class Webform extends NestedDataComponent_1.default {
|
|
|
787
796
|
formio.loadSubmissions({
|
|
788
797
|
params: {
|
|
789
798
|
state: 'draft',
|
|
790
|
-
owner: userId
|
|
799
|
+
owner: userId,
|
|
800
|
+
sort: '-created'
|
|
791
801
|
}
|
|
792
802
|
}).then(submissions => {
|
|
793
803
|
if (submissions.length > 0 && !this.options.skipDraftRestore) {
|
|
@@ -986,8 +986,14 @@ class WebformBuilder extends Component_1.default {
|
|
|
986
986
|
else if (parent.formioComponent && parent.formioComponent.removeChildComponent) {
|
|
987
987
|
parent.formioComponent.removeChildComponent(component);
|
|
988
988
|
}
|
|
989
|
-
if (component.input && componentInstance &&
|
|
990
|
-
lodash_1.default.
|
|
989
|
+
if (component.input && componentInstance && parent.formioComponent) {
|
|
990
|
+
const parentDefaultValue = lodash_1.default.get(parent.formioComponent, 'component.defaultValue', null);
|
|
991
|
+
if (Array.isArray(parentDefaultValue)) {
|
|
992
|
+
parentDefaultValue.forEach(v => lodash_1.default.unset(v, componentInstance.key));
|
|
993
|
+
}
|
|
994
|
+
else if (typeof parentDefaultValue === 'object') {
|
|
995
|
+
lodash_1.default.unset(parentDefaultValue, componentInstance.key);
|
|
996
|
+
}
|
|
991
997
|
}
|
|
992
998
|
const rebuild = parent.formioComponent.rebuild() || Promise.resolve();
|
|
993
999
|
rebuild.then(() => {
|
|
@@ -327,10 +327,23 @@ declare class Component extends Element {
|
|
|
327
327
|
*/
|
|
328
328
|
loadRefs(element: HTMLElement, refs: object, referenceAttributeName?: string | undefined): void;
|
|
329
329
|
setOpenModalElement(template: any): void;
|
|
330
|
-
|
|
330
|
+
/**
|
|
331
|
+
* Renders a modal preview template and returns the markup as a string
|
|
332
|
+
* @param {object|null|undefined} ctx - The rendering context
|
|
333
|
+
* @return {string} - The modal preview markup
|
|
334
|
+
*/
|
|
335
|
+
renderModalPreview(ctx: object | null | undefined): string;
|
|
336
|
+
getModalPreviewTemplate(): string;
|
|
331
337
|
build(element: any): Promise<void>;
|
|
332
338
|
get hasModalSaveButton(): boolean;
|
|
333
339
|
render(children?: string, topLevel?: boolean): any;
|
|
340
|
+
/**
|
|
341
|
+
* Creates the tooltip instance using tippy.js and returns it
|
|
342
|
+
* @param {HTMLElement} tooltipEl - HTML element to attach the tooltip
|
|
343
|
+
* @param {object|null|undefined} settings - tippy.js options
|
|
344
|
+
* @return {import('tippy.js').Tippy} - tippy.js instance
|
|
345
|
+
*/
|
|
346
|
+
createTooltip(tooltipEl: HTMLElement, settings?: object | null | undefined): import('tippy.js').Tippy;
|
|
334
347
|
attachTooltips(toolTipsRefs: any): void;
|
|
335
348
|
createComponentModal(element: any, modalShouldBeOpened: any, currentValue: any): ComponentModal;
|
|
336
349
|
attach(element: any): Promise<void>;
|
|
@@ -1029,6 +1029,14 @@ class Component extends Element_1.default {
|
|
|
1029
1029
|
setOpenModalElement(template) {
|
|
1030
1030
|
this.componentModal.setOpenModalElement(template || this.getModalPreviewTemplate());
|
|
1031
1031
|
}
|
|
1032
|
+
/**
|
|
1033
|
+
* Renders a modal preview template and returns the markup as a string
|
|
1034
|
+
* @param {object|null|undefined} ctx - The rendering context
|
|
1035
|
+
* @return {string} - The modal preview markup
|
|
1036
|
+
*/
|
|
1037
|
+
renderModalPreview(ctx) {
|
|
1038
|
+
return this.renderTemplate('modalPreview', ctx || {});
|
|
1039
|
+
}
|
|
1032
1040
|
getModalPreviewTemplate() {
|
|
1033
1041
|
var _a;
|
|
1034
1042
|
const dataValue = this.component.type === 'password' ? this.dataValue.replace(/./g, '•') : this.dataValue;
|
|
@@ -1036,7 +1044,7 @@ class Component extends Element_1.default {
|
|
|
1036
1044
|
if (this.hasInput && ((_a = this.component.validate) === null || _a === void 0 ? void 0 : _a.required) && !this.isPDFReadOnlyMode) {
|
|
1037
1045
|
modalLabel = { className: 'field-required' };
|
|
1038
1046
|
}
|
|
1039
|
-
return this.
|
|
1047
|
+
return this.renderModalPreview({
|
|
1040
1048
|
previewText: this.getValueAsString(dataValue, { modalPreview: true }) || this.t('Click to set value'),
|
|
1041
1049
|
messages: '',
|
|
1042
1050
|
labelInfo: modalLabel,
|
|
@@ -1074,21 +1082,23 @@ class Component extends Element_1.default {
|
|
|
1074
1082
|
}, topLevel);
|
|
1075
1083
|
}
|
|
1076
1084
|
}
|
|
1085
|
+
/**
|
|
1086
|
+
* Creates the tooltip instance using tippy.js and returns it
|
|
1087
|
+
* @param {HTMLElement} tooltipEl - HTML element to attach the tooltip
|
|
1088
|
+
* @param {object|null|undefined} settings - tippy.js options
|
|
1089
|
+
* @return {import('tippy.js').Tippy} - tippy.js instance
|
|
1090
|
+
*/
|
|
1091
|
+
createTooltip(tooltipEl, settings = {}) {
|
|
1092
|
+
const tooltipAttribute = tooltipEl.getAttribute('data-tooltip');
|
|
1093
|
+
const tooltipDataTitle = tooltipEl.getAttribute('data-title');
|
|
1094
|
+
const tooltipText = this.interpolate(tooltipDataTitle || tooltipAttribute)
|
|
1095
|
+
.replace(/(?:\r\n|\r|\n)/g, '<br />');
|
|
1096
|
+
return (0, tippy_js_1.default)(tooltipEl, Object.assign(Object.assign({ allowHTML: true, trigger: 'mouseenter click focus', placement: 'right', zIndex: 10000, interactive: true }, settings), { content: this.t(this.sanitize(tooltipText), { _userInput: true }) }));
|
|
1097
|
+
}
|
|
1077
1098
|
attachTooltips(toolTipsRefs) {
|
|
1078
1099
|
toolTipsRefs === null || toolTipsRefs === void 0 ? void 0 : toolTipsRefs.forEach((tooltip, index) => {
|
|
1079
1100
|
if (tooltip) {
|
|
1080
|
-
|
|
1081
|
-
const tooltipDataTitle = tooltip.getAttribute('data-title');
|
|
1082
|
-
const tooltipText = this.interpolate(tooltipDataTitle || tooltipAttribute)
|
|
1083
|
-
.replace(/(?:\r\n|\r|\n)/g, '<br />');
|
|
1084
|
-
this.tooltips[index] = (0, tippy_js_1.default)(tooltip, {
|
|
1085
|
-
allowHTML: true,
|
|
1086
|
-
trigger: 'mouseenter click focus',
|
|
1087
|
-
placement: 'right',
|
|
1088
|
-
zIndex: 10000,
|
|
1089
|
-
interactive: true,
|
|
1090
|
-
content: this.t(this.sanitize(tooltipText), { _userInput: true }),
|
|
1091
|
-
});
|
|
1101
|
+
this.tooltips[index] = this.createTooltip(tooltip);
|
|
1092
1102
|
}
|
|
1093
1103
|
});
|
|
1094
1104
|
}
|
|
@@ -2559,7 +2569,7 @@ class Component extends Element_1.default {
|
|
|
2559
2569
|
}
|
|
2560
2570
|
this.calculatedValue = (0, utils_1.fastCloneDeep)(calculatedValue);
|
|
2561
2571
|
if (changed) {
|
|
2562
|
-
if (!flags.noPristineChangeOnModified) {
|
|
2572
|
+
if (!flags.noPristineChangeOnModified && this.root.initialized) {
|
|
2563
2573
|
this.pristine = false;
|
|
2564
2574
|
}
|
|
2565
2575
|
flags.triggeredComponentId = this.id;
|
|
@@ -79,6 +79,13 @@ export default class FormComponent extends Component {
|
|
|
79
79
|
isHidden(): boolean;
|
|
80
80
|
setValue(submission: any, flags?: {}): boolean;
|
|
81
81
|
setSubFormValue(submission: any, flags: any): void;
|
|
82
|
+
/**
|
|
83
|
+
* Sets the subform value
|
|
84
|
+
* @param {object|null|undefined} submission - The submission to set.
|
|
85
|
+
* @param {object|null|undefined} flags - Any flags to apply when setting the submission.
|
|
86
|
+
* @return {void}
|
|
87
|
+
*/
|
|
88
|
+
onSetSubFormValue(submission: object | null | undefined, flags: object | null | undefined): void;
|
|
82
89
|
areAllComponentsEmpty(data: any): boolean;
|
|
83
90
|
updateSubFormVisibility(): void;
|
|
84
91
|
/**
|
|
@@ -431,7 +431,7 @@ class FormComponent extends Component_1.default {
|
|
|
431
431
|
* Load the subform.
|
|
432
432
|
*/
|
|
433
433
|
loadSubForm(fromAttach) {
|
|
434
|
-
var _a, _b, _c;
|
|
434
|
+
var _a, _b, _c, _d, _e;
|
|
435
435
|
if (this.builderMode || this.isHidden() || (this.isSubFormLazyLoad() && !fromAttach)) {
|
|
436
436
|
return Promise.resolve();
|
|
437
437
|
}
|
|
@@ -445,7 +445,7 @@ class FormComponent extends Component_1.default {
|
|
|
445
445
|
}
|
|
446
446
|
else if (this.formSrc) {
|
|
447
447
|
this.subFormLoading = true;
|
|
448
|
-
const options = ((_b = this.root
|
|
448
|
+
const options = ((_c = (_b = this.root) === null || _b === void 0 ? void 0 : _b.formio) === null || _c === void 0 ? void 0 : _c.base) && ((_e = (_d = this.root) === null || _d === void 0 ? void 0 : _d.formio) === null || _e === void 0 ? void 0 : _e.projectUrl)
|
|
449
449
|
? {
|
|
450
450
|
base: this.root.formio.base,
|
|
451
451
|
project: this.root.formio.projectUrl,
|
|
@@ -625,15 +625,16 @@ class FormComponent extends Component_1.default {
|
|
|
625
625
|
return changed;
|
|
626
626
|
}
|
|
627
627
|
setSubFormValue(submission, flags) {
|
|
628
|
-
var _a, _b;
|
|
628
|
+
var _a, _b, _c, _d;
|
|
629
629
|
const shouldLoadSubmissionById = submission
|
|
630
630
|
&& submission._id
|
|
631
631
|
&& this.subForm.formio
|
|
632
632
|
&& lodash_1.default.isEmpty(submission.data);
|
|
633
|
-
|
|
633
|
+
const shouldLoadDraftById = this.options.saveDraft && lodash_1.default.isEmpty(submission.data) && lodash_1.default.get(this.subForm, 'submission._id');
|
|
634
|
+
if (shouldLoadSubmissionById || shouldLoadDraftById) {
|
|
634
635
|
const formId = submission.form || this.formObj.form || this.component.form;
|
|
635
|
-
const submissionUrl = `${this.subForm.formio.formsUrl}/${formId}/submission/${submission._id}`;
|
|
636
|
-
const options = ((_a = this.root
|
|
636
|
+
const submissionUrl = `${this.subForm.formio.formsUrl}/${formId}/submission/${submission._id || this.subForm.submission._id}`;
|
|
637
|
+
const options = ((_b = (_a = this.root) === null || _a === void 0 ? void 0 : _a.formio) === null || _b === void 0 ? void 0 : _b.base) && ((_d = (_c = this.root) === null || _c === void 0 ? void 0 : _c.formio) === null || _d === void 0 ? void 0 : _d.projectUrl)
|
|
637
638
|
? {
|
|
638
639
|
base: this.root.formio.base,
|
|
639
640
|
project: this.root.formio.projectUrl,
|
|
@@ -645,9 +646,18 @@ class FormComponent extends Component_1.default {
|
|
|
645
646
|
});
|
|
646
647
|
}
|
|
647
648
|
else {
|
|
648
|
-
this.
|
|
649
|
+
this.onSetSubFormValue(submission, flags);
|
|
649
650
|
}
|
|
650
651
|
}
|
|
652
|
+
/**
|
|
653
|
+
* Sets the subform value
|
|
654
|
+
* @param {object|null|undefined} submission - The submission to set.
|
|
655
|
+
* @param {object|null|undefined} flags - Any flags to apply when setting the submission.
|
|
656
|
+
* @return {void}
|
|
657
|
+
*/
|
|
658
|
+
onSetSubFormValue(submission, flags) {
|
|
659
|
+
this.subForm.setValue(submission, flags);
|
|
660
|
+
}
|
|
651
661
|
isEmpty(value = this.dataValue) {
|
|
652
662
|
return value === null || lodash_1.default.isEqual(value, this.emptyValue) || (this.areAllComponentsEmpty(value === null || value === void 0 ? void 0 : value.data) && !(value === null || value === void 0 ? void 0 : value._id));
|
|
653
663
|
}
|
|
@@ -172,7 +172,7 @@ class SignatureComponent extends Input_1.default {
|
|
|
172
172
|
return false;
|
|
173
173
|
}
|
|
174
174
|
getModalPreviewTemplate() {
|
|
175
|
-
return this.
|
|
175
|
+
return this.renderModalPreview({
|
|
176
176
|
previewText: this.dataValue ?
|
|
177
177
|
`<img src=${this.dataValue} ${this._referenceAttributeName}='openModal' style="width: 100%;height: 100%;" />` :
|
|
178
178
|
this.t('Click to Sign')
|
package/lib/mjs/Webform.d.ts
CHANGED
|
@@ -356,6 +356,13 @@ declare class Webform extends NestedDataComponent {
|
|
|
356
356
|
* @returns {Object}
|
|
357
357
|
*/
|
|
358
358
|
get submission(): Object;
|
|
359
|
+
/**
|
|
360
|
+
* Sets the submission value
|
|
361
|
+
* @param {object|null|undefined} submission - The submission to set.
|
|
362
|
+
* @param {object|null|undefined} flags - Any flags to apply when setting the submission.
|
|
363
|
+
* @return {void}
|
|
364
|
+
*/
|
|
365
|
+
onSetSubmission(submission: object | null | undefined, flags?: object | null | undefined): void;
|
|
359
366
|
/**
|
|
360
367
|
* Sets a submission and returns the promise when it is ready.
|
|
361
368
|
* @param submission
|
package/lib/mjs/Webform.js
CHANGED
|
@@ -714,6 +714,18 @@ export default class Webform extends NestedDataComponent {
|
|
|
714
714
|
set submission(submission) {
|
|
715
715
|
this.setSubmission(submission);
|
|
716
716
|
}
|
|
717
|
+
/**
|
|
718
|
+
* Sets the submission value
|
|
719
|
+
* @param {object|null|undefined} submission - The submission to set.
|
|
720
|
+
* @param {object|null|undefined} flags - Any flags to apply when setting the submission.
|
|
721
|
+
* @return {void}
|
|
722
|
+
*/
|
|
723
|
+
onSetSubmission(submission, flags = {}) {
|
|
724
|
+
this.submissionSet = true;
|
|
725
|
+
this.triggerChange(flags);
|
|
726
|
+
this.emit('beforeSetSubmission', submission);
|
|
727
|
+
this.setValue(submission, flags);
|
|
728
|
+
}
|
|
717
729
|
/**
|
|
718
730
|
* Sets a submission and returns the promise when it is ready.
|
|
719
731
|
* @param submission
|
|
@@ -732,10 +744,7 @@ export default class Webform extends NestedDataComponent {
|
|
|
732
744
|
...resolveFlags
|
|
733
745
|
};
|
|
734
746
|
}
|
|
735
|
-
this.
|
|
736
|
-
this.triggerChange(flags);
|
|
737
|
-
this.emit('beforeSetSubmission', submission);
|
|
738
|
-
this.setValue(submission, flags);
|
|
747
|
+
this.onSetSubmission(submission, flags);
|
|
739
748
|
return this.submissionReadyResolve(submission);
|
|
740
749
|
}, (err) => this.submissionReadyReject(err)).catch((err) => this.submissionReadyReject(err));
|
|
741
750
|
}
|
|
@@ -791,7 +800,8 @@ export default class Webform extends NestedDataComponent {
|
|
|
791
800
|
formio.loadSubmissions({
|
|
792
801
|
params: {
|
|
793
802
|
state: 'draft',
|
|
794
|
-
owner: userId
|
|
803
|
+
owner: userId,
|
|
804
|
+
sort: '-created'
|
|
795
805
|
}
|
|
796
806
|
}).then(submissions => {
|
|
797
807
|
if (submissions.length > 0 && !this.options.skipDraftRestore) {
|
|
@@ -970,8 +970,14 @@ export default class WebformBuilder extends Component {
|
|
|
970
970
|
else if (parent.formioComponent && parent.formioComponent.removeChildComponent) {
|
|
971
971
|
parent.formioComponent.removeChildComponent(component);
|
|
972
972
|
}
|
|
973
|
-
if (component.input && componentInstance &&
|
|
974
|
-
_.
|
|
973
|
+
if (component.input && componentInstance && parent.formioComponent) {
|
|
974
|
+
const parentDefaultValue = _.get(parent.formioComponent, 'component.defaultValue', null);
|
|
975
|
+
if (Array.isArray(parentDefaultValue)) {
|
|
976
|
+
parentDefaultValue.forEach(v => _.unset(v, componentInstance.key));
|
|
977
|
+
}
|
|
978
|
+
else if (typeof parentDefaultValue === 'object') {
|
|
979
|
+
_.unset(parentDefaultValue, componentInstance.key);
|
|
980
|
+
}
|
|
975
981
|
}
|
|
976
982
|
const rebuild = parent.formioComponent.rebuild() || Promise.resolve();
|
|
977
983
|
rebuild.then(() => {
|
|
@@ -327,10 +327,23 @@ declare class Component extends Element {
|
|
|
327
327
|
*/
|
|
328
328
|
loadRefs(element: HTMLElement, refs: object, referenceAttributeName?: string | undefined): void;
|
|
329
329
|
setOpenModalElement(template: any): void;
|
|
330
|
-
|
|
330
|
+
/**
|
|
331
|
+
* Renders a modal preview template and returns the markup as a string
|
|
332
|
+
* @param {object|null|undefined} ctx - The rendering context
|
|
333
|
+
* @return {string} - The modal preview markup
|
|
334
|
+
*/
|
|
335
|
+
renderModalPreview(ctx: object | null | undefined): string;
|
|
336
|
+
getModalPreviewTemplate(): string;
|
|
331
337
|
build(element: any): Promise<void>;
|
|
332
338
|
get hasModalSaveButton(): boolean;
|
|
333
339
|
render(children?: string, topLevel?: boolean): any;
|
|
340
|
+
/**
|
|
341
|
+
* Creates the tooltip instance using tippy.js and returns it
|
|
342
|
+
* @param {HTMLElement} tooltipEl - HTML element to attach the tooltip
|
|
343
|
+
* @param {object|null|undefined} settings - tippy.js options
|
|
344
|
+
* @return {import('tippy.js').Tippy} - tippy.js instance
|
|
345
|
+
*/
|
|
346
|
+
createTooltip(tooltipEl: HTMLElement, settings?: object | null | undefined): import('tippy.js').Tippy;
|
|
334
347
|
attachTooltips(toolTipsRefs: any): void;
|
|
335
348
|
createComponentModal(element: any, modalShouldBeOpened: any, currentValue: any): ComponentModal;
|
|
336
349
|
attach(element: any): Promise<void>;
|
|
@@ -996,13 +996,21 @@ export default class Component extends Element {
|
|
|
996
996
|
setOpenModalElement(template) {
|
|
997
997
|
this.componentModal.setOpenModalElement(template || this.getModalPreviewTemplate());
|
|
998
998
|
}
|
|
999
|
+
/**
|
|
1000
|
+
* Renders a modal preview template and returns the markup as a string
|
|
1001
|
+
* @param {object|null|undefined} ctx - The rendering context
|
|
1002
|
+
* @return {string} - The modal preview markup
|
|
1003
|
+
*/
|
|
1004
|
+
renderModalPreview(ctx) {
|
|
1005
|
+
return this.renderTemplate('modalPreview', ctx || {});
|
|
1006
|
+
}
|
|
999
1007
|
getModalPreviewTemplate() {
|
|
1000
1008
|
const dataValue = this.component.type === 'password' ? this.dataValue.replace(/./g, '•') : this.dataValue;
|
|
1001
1009
|
let modalLabel;
|
|
1002
1010
|
if (this.hasInput && this.component.validate?.required && !this.isPDFReadOnlyMode) {
|
|
1003
1011
|
modalLabel = { className: 'field-required' };
|
|
1004
1012
|
}
|
|
1005
|
-
return this.
|
|
1013
|
+
return this.renderModalPreview({
|
|
1006
1014
|
previewText: this.getValueAsString(dataValue, { modalPreview: true }) || this.t('Click to set value'),
|
|
1007
1015
|
messages: '',
|
|
1008
1016
|
labelInfo: modalLabel,
|
|
@@ -1040,21 +1048,31 @@ export default class Component extends Element {
|
|
|
1040
1048
|
}, topLevel);
|
|
1041
1049
|
}
|
|
1042
1050
|
}
|
|
1051
|
+
/**
|
|
1052
|
+
* Creates the tooltip instance using tippy.js and returns it
|
|
1053
|
+
* @param {HTMLElement} tooltipEl - HTML element to attach the tooltip
|
|
1054
|
+
* @param {object|null|undefined} settings - tippy.js options
|
|
1055
|
+
* @return {import('tippy.js').Tippy} - tippy.js instance
|
|
1056
|
+
*/
|
|
1057
|
+
createTooltip(tooltipEl, settings = {}) {
|
|
1058
|
+
const tooltipAttribute = tooltipEl.getAttribute('data-tooltip');
|
|
1059
|
+
const tooltipDataTitle = tooltipEl.getAttribute('data-title');
|
|
1060
|
+
const tooltipText = this.interpolate(tooltipDataTitle || tooltipAttribute)
|
|
1061
|
+
.replace(/(?:\r\n|\r|\n)/g, '<br />');
|
|
1062
|
+
return tippy(tooltipEl, {
|
|
1063
|
+
allowHTML: true,
|
|
1064
|
+
trigger: 'mouseenter click focus',
|
|
1065
|
+
placement: 'right',
|
|
1066
|
+
zIndex: 10000,
|
|
1067
|
+
interactive: true,
|
|
1068
|
+
...settings,
|
|
1069
|
+
content: this.t(this.sanitize(tooltipText), { _userInput: true }),
|
|
1070
|
+
});
|
|
1071
|
+
}
|
|
1043
1072
|
attachTooltips(toolTipsRefs) {
|
|
1044
1073
|
toolTipsRefs?.forEach((tooltip, index) => {
|
|
1045
1074
|
if (tooltip) {
|
|
1046
|
-
|
|
1047
|
-
const tooltipDataTitle = tooltip.getAttribute('data-title');
|
|
1048
|
-
const tooltipText = this.interpolate(tooltipDataTitle || tooltipAttribute)
|
|
1049
|
-
.replace(/(?:\r\n|\r|\n)/g, '<br />');
|
|
1050
|
-
this.tooltips[index] = tippy(tooltip, {
|
|
1051
|
-
allowHTML: true,
|
|
1052
|
-
trigger: 'mouseenter click focus',
|
|
1053
|
-
placement: 'right',
|
|
1054
|
-
zIndex: 10000,
|
|
1055
|
-
interactive: true,
|
|
1056
|
-
content: this.t(this.sanitize(tooltipText), { _userInput: true }),
|
|
1057
|
-
});
|
|
1075
|
+
this.tooltips[index] = this.createTooltip(tooltip);
|
|
1058
1076
|
}
|
|
1059
1077
|
});
|
|
1060
1078
|
}
|
|
@@ -2527,7 +2545,7 @@ export default class Component extends Element {
|
|
|
2527
2545
|
}
|
|
2528
2546
|
this.calculatedValue = fastCloneDeep(calculatedValue);
|
|
2529
2547
|
if (changed) {
|
|
2530
|
-
if (!flags.noPristineChangeOnModified) {
|
|
2548
|
+
if (!flags.noPristineChangeOnModified && this.root.initialized) {
|
|
2531
2549
|
this.pristine = false;
|
|
2532
2550
|
}
|
|
2533
2551
|
flags.triggeredComponentId = this.id;
|
|
@@ -79,6 +79,13 @@ export default class FormComponent extends Component {
|
|
|
79
79
|
isHidden(): boolean;
|
|
80
80
|
setValue(submission: any, flags?: {}): boolean;
|
|
81
81
|
setSubFormValue(submission: any, flags: any): void;
|
|
82
|
+
/**
|
|
83
|
+
* Sets the subform value
|
|
84
|
+
* @param {object|null|undefined} submission - The submission to set.
|
|
85
|
+
* @param {object|null|undefined} flags - Any flags to apply when setting the submission.
|
|
86
|
+
* @return {void}
|
|
87
|
+
*/
|
|
88
|
+
onSetSubFormValue(submission: object | null | undefined, flags: object | null | undefined): void;
|
|
82
89
|
areAllComponentsEmpty(data: any): boolean;
|
|
83
90
|
updateSubFormVisibility(): void;
|
|
84
91
|
/**
|
|
@@ -440,7 +440,7 @@ export default class FormComponent extends Component {
|
|
|
440
440
|
}
|
|
441
441
|
else if (this.formSrc) {
|
|
442
442
|
this.subFormLoading = true;
|
|
443
|
-
const options = this.root
|
|
443
|
+
const options = this.root?.formio?.base && this.root?.formio?.projectUrl
|
|
444
444
|
? {
|
|
445
445
|
base: this.root.formio.base,
|
|
446
446
|
project: this.root.formio.projectUrl,
|
|
@@ -620,10 +620,11 @@ export default class FormComponent extends Component {
|
|
|
620
620
|
&& submission._id
|
|
621
621
|
&& this.subForm.formio
|
|
622
622
|
&& _.isEmpty(submission.data);
|
|
623
|
-
|
|
623
|
+
const shouldLoadDraftById = this.options.saveDraft && _.isEmpty(submission.data) && _.get(this.subForm, 'submission._id');
|
|
624
|
+
if (shouldLoadSubmissionById || shouldLoadDraftById) {
|
|
624
625
|
const formId = submission.form || this.formObj.form || this.component.form;
|
|
625
|
-
const submissionUrl = `${this.subForm.formio.formsUrl}/${formId}/submission/${submission._id}`;
|
|
626
|
-
const options = this.root
|
|
626
|
+
const submissionUrl = `${this.subForm.formio.formsUrl}/${formId}/submission/${submission._id || this.subForm.submission._id}`;
|
|
627
|
+
const options = this.root?.formio?.base && this.root?.formio?.projectUrl
|
|
627
628
|
? {
|
|
628
629
|
base: this.root.formio.base,
|
|
629
630
|
project: this.root.formio.projectUrl,
|
|
@@ -635,9 +636,18 @@ export default class FormComponent extends Component {
|
|
|
635
636
|
});
|
|
636
637
|
}
|
|
637
638
|
else {
|
|
638
|
-
this.
|
|
639
|
+
this.onSetSubFormValue(submission, flags);
|
|
639
640
|
}
|
|
640
641
|
}
|
|
642
|
+
/**
|
|
643
|
+
* Sets the subform value
|
|
644
|
+
* @param {object|null|undefined} submission - The submission to set.
|
|
645
|
+
* @param {object|null|undefined} flags - Any flags to apply when setting the submission.
|
|
646
|
+
* @return {void}
|
|
647
|
+
*/
|
|
648
|
+
onSetSubFormValue(submission, flags) {
|
|
649
|
+
this.subForm.setValue(submission, flags);
|
|
650
|
+
}
|
|
641
651
|
isEmpty(value = this.dataValue) {
|
|
642
652
|
return value === null || _.isEqual(value, this.emptyValue) || (this.areAllComponentsEmpty(value?.data) && !value?._id);
|
|
643
653
|
}
|
|
@@ -169,7 +169,7 @@ export default class SignatureComponent extends Input {
|
|
|
169
169
|
return false;
|
|
170
170
|
}
|
|
171
171
|
getModalPreviewTemplate() {
|
|
172
|
-
return this.
|
|
172
|
+
return this.renderModalPreview({
|
|
173
173
|
previewText: this.dataValue ?
|
|
174
174
|
`<img src=${this.dataValue} ${this._referenceAttributeName}='openModal' style="width: 100%;height: 100%;" />` :
|
|
175
175
|
this.t('Click to Sign')
|