@formio/js 5.1.0-dev.6058.189ce78 → 5.1.0-dev.6059.845a6e3
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 +13 -131
- package/README.md +1 -28
- package/dist/formio.builder.css +17 -19
- package/dist/formio.builder.min.css +1 -1
- package/dist/formio.embed.js +1 -1
- package/dist/formio.embed.min.js +1 -1
- package/dist/formio.embed.min.js.LICENSE.txt +1 -1
- package/dist/formio.form.css +17 -19
- package/dist/formio.form.js +176 -102
- package/dist/formio.form.min.css +1 -1
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.form.min.js.LICENSE.txt +3 -3
- package/dist/formio.full.css +17 -19
- package/dist/formio.full.js +86 -108
- package/dist/formio.full.min.css +2 -2
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.full.min.js.LICENSE.txt +3 -3
- package/dist/formio.js +10 -10
- package/dist/formio.min.js +1 -1
- package/dist/formio.min.js.LICENSE.txt +1 -1
- package/dist/formio.utils.js +3 -3
- package/dist/formio.utils.min.js +1 -1
- package/dist/formio.utils.min.js.LICENSE.txt +1 -1
- package/lib/cjs/CDN.d.ts +1 -1
- package/lib/cjs/CDN.js +2 -2
- package/lib/cjs/Embed.js +1 -1
- package/lib/cjs/Form.d.ts +6 -4
- package/lib/cjs/Form.js +8 -16
- package/lib/cjs/Formio.js +1 -1
- package/lib/cjs/PDFBuilder.js +4 -4
- package/lib/cjs/Webform.d.ts +13 -16
- package/lib/cjs/Webform.js +148 -162
- package/lib/cjs/WebformBuilder.js +28 -17
- package/lib/cjs/Wizard.js +1 -1
- package/lib/cjs/WizardBuilder.js +2 -15
- package/lib/cjs/components/Components.d.ts +0 -3
- package/lib/cjs/components/_classes/component/Component.d.ts +0 -1
- package/lib/cjs/components/_classes/component/Component.js +11 -38
- package/lib/cjs/components/_classes/component/editForm/Component.edit.conditional.js +1 -1
- package/lib/cjs/components/_classes/component/editForm/Component.edit.data.d.ts +0 -37
- package/lib/cjs/components/_classes/component/editForm/Component.edit.data.js +2 -32
- package/lib/cjs/components/_classes/component/editForm/utils.d.ts +0 -1
- package/lib/cjs/components/_classes/component/editForm/utils.js +0 -3
- package/lib/cjs/components/_classes/input/Input.js +1 -23
- package/lib/cjs/components/_classes/list/ListComponent.js +4 -4
- package/lib/cjs/components/_classes/multivalue/Multivalue.d.ts +1 -1
- package/lib/cjs/components/_classes/multivalue/Multivalue.js +3 -10
- package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.d.ts +0 -2
- package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.js +31 -52
- package/lib/cjs/components/address/Address.js +1 -1
- package/lib/cjs/components/button/Button.js +6 -6
- package/lib/cjs/components/checkbox/Checkbox.d.ts +1 -1
- package/lib/cjs/components/checkbox/Checkbox.js +2 -2
- package/lib/cjs/components/datagrid/DataGrid.d.ts +0 -2
- package/lib/cjs/components/datagrid/DataGrid.js +26 -41
- package/lib/cjs/components/day/Day.js +7 -9
- package/lib/cjs/components/editgrid/EditGrid.d.ts +1 -1
- package/lib/cjs/components/editgrid/EditGrid.js +8 -26
- package/lib/cjs/components/file/File.d.ts +1 -1
- package/lib/cjs/components/file/File.js +17 -23
- package/lib/cjs/components/form/Form.d.ts +1 -1
- package/lib/cjs/components/form/Form.js +5 -9
- package/lib/cjs/components/form/editForm/Form.edit.form.js +3 -3
- package/lib/cjs/components/hidden/Hidden.d.ts +1 -0
- package/lib/cjs/components/hidden/Hidden.js +1 -1
- package/lib/cjs/components/number/Number.js +5 -12
- package/lib/cjs/components/radio/Radio.js +0 -10
- package/lib/cjs/components/recaptcha/ReCaptcha.js +2 -2
- package/lib/cjs/components/select/Select.d.ts +1 -0
- package/lib/cjs/components/select/Select.js +33 -12
- package/lib/cjs/components/select/editForm/Select.edit.data.d.ts +1 -1
- package/lib/cjs/components/select/editForm/Select.edit.data.js +2 -3
- package/lib/cjs/components/selectboxes/SelectBoxes.js +2 -2
- package/lib/cjs/components/signature/Signature.d.ts +1 -1
- package/lib/cjs/components/signature/Signature.js +3 -5
- package/lib/cjs/components/signature/editForm/Signature.edit.display.d.ts +6 -0
- package/lib/cjs/components/signature/editForm/Signature.edit.display.js +1 -0
- package/lib/cjs/components/survey/Survey.js +2 -2
- package/lib/cjs/components/tags/Tags.d.ts +1 -1
- package/lib/cjs/components/tags/Tags.js +2 -2
- package/lib/cjs/components/textarea/TextArea.js +6 -6
- package/lib/cjs/formio.form.js +0 -5
- package/lib/cjs/providers/storage/googleDrive.js +2 -3
- package/lib/cjs/providers/storage/s3.js +3 -3
- package/lib/cjs/providers/storage/xhr.d.ts +0 -1
- package/lib/cjs/providers/storage/xhr.js +1 -6
- package/lib/cjs/translations/en.d.ts +81 -234
- package/lib/cjs/translations/en.js +81 -8
- package/lib/cjs/utils/ChoicesWrapper.d.ts +25 -4
- package/lib/cjs/utils/ChoicesWrapper.js +124 -47
- package/lib/cjs/utils/formUtils.d.ts +2 -2
- package/lib/cjs/utils/i18n.d.ts +2 -5
- package/lib/cjs/utils/i18n.js +5 -32
- package/lib/cjs/widgets/CalendarWidget.js +27 -27
- package/lib/mjs/CDN.d.ts +1 -1
- package/lib/mjs/CDN.js +2 -2
- package/lib/mjs/Embed.js +1 -1
- package/lib/mjs/Form.d.ts +6 -4
- package/lib/mjs/Form.js +9 -17
- package/lib/mjs/Formio.js +1 -1
- package/lib/mjs/PDFBuilder.js +4 -4
- package/lib/mjs/Webform.d.ts +13 -16
- package/lib/mjs/Webform.js +158 -171
- package/lib/mjs/WebformBuilder.js +28 -17
- package/lib/mjs/Wizard.js +1 -1
- package/lib/mjs/WizardBuilder.js +2 -15
- package/lib/mjs/components/Components.d.ts +0 -3
- package/lib/mjs/components/_classes/component/Component.d.ts +0 -1
- package/lib/mjs/components/_classes/component/Component.js +11 -27
- package/lib/mjs/components/_classes/component/editForm/Component.edit.conditional.js +1 -1
- package/lib/mjs/components/_classes/component/editForm/Component.edit.data.d.ts +0 -37
- package/lib/mjs/components/_classes/component/editForm/Component.edit.data.js +2 -32
- package/lib/mjs/components/_classes/component/editForm/utils.d.ts +0 -1
- package/lib/mjs/components/_classes/component/editForm/utils.js +0 -3
- package/lib/mjs/components/_classes/input/Input.js +1 -22
- package/lib/mjs/components/_classes/list/ListComponent.js +4 -4
- package/lib/mjs/components/_classes/multivalue/Multivalue.d.ts +1 -1
- package/lib/mjs/components/_classes/multivalue/Multivalue.js +3 -10
- package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.d.ts +0 -2
- package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.js +31 -53
- package/lib/mjs/components/address/Address.js +1 -1
- package/lib/mjs/components/button/Button.js +6 -6
- package/lib/mjs/components/checkbox/Checkbox.d.ts +1 -1
- package/lib/mjs/components/checkbox/Checkbox.js +2 -2
- package/lib/mjs/components/datagrid/DataGrid.d.ts +0 -2
- package/lib/mjs/components/datagrid/DataGrid.js +26 -41
- package/lib/mjs/components/day/Day.js +7 -9
- package/lib/mjs/components/editgrid/EditGrid.d.ts +1 -1
- package/lib/mjs/components/editgrid/EditGrid.js +7 -25
- package/lib/mjs/components/file/File.d.ts +1 -1
- package/lib/mjs/components/file/File.js +17 -23
- package/lib/mjs/components/form/Form.d.ts +1 -1
- package/lib/mjs/components/form/Form.js +5 -8
- package/lib/mjs/components/form/editForm/Form.edit.form.js +3 -3
- package/lib/mjs/components/hidden/Hidden.d.ts +1 -0
- package/lib/mjs/components/hidden/Hidden.js +1 -1
- package/lib/mjs/components/number/Number.js +5 -12
- package/lib/mjs/components/radio/Radio.js +0 -10
- package/lib/mjs/components/recaptcha/ReCaptcha.js +2 -2
- package/lib/mjs/components/select/Select.d.ts +1 -0
- package/lib/mjs/components/select/Select.js +34 -14
- package/lib/mjs/components/select/editForm/Select.edit.data.d.ts +1 -1
- package/lib/mjs/components/select/editForm/Select.edit.data.js +2 -3
- package/lib/mjs/components/selectboxes/SelectBoxes.js +2 -2
- package/lib/mjs/components/signature/Signature.d.ts +1 -1
- package/lib/mjs/components/signature/Signature.js +3 -5
- package/lib/mjs/components/signature/editForm/Signature.edit.display.d.ts +6 -0
- package/lib/mjs/components/signature/editForm/Signature.edit.display.js +1 -0
- package/lib/mjs/components/survey/Survey.js +2 -2
- package/lib/mjs/components/tags/Tags.d.ts +1 -1
- package/lib/mjs/components/tags/Tags.js +2 -2
- package/lib/mjs/components/textarea/TextArea.js +6 -6
- package/lib/mjs/formio.form.js +0 -5
- package/lib/mjs/providers/storage/googleDrive.js +2 -3
- package/lib/mjs/providers/storage/s3.js +3 -3
- package/lib/mjs/providers/storage/xhr.d.ts +0 -1
- package/lib/mjs/providers/storage/xhr.js +1 -6
- package/lib/mjs/translations/en.d.ts +81 -234
- package/lib/mjs/translations/en.js +1 -87
- package/lib/mjs/utils/ChoicesWrapper.d.ts +25 -4
- package/lib/mjs/utils/ChoicesWrapper.js +119 -26
- package/lib/mjs/utils/formUtils.d.ts +2 -2
- package/lib/mjs/utils/i18n.d.ts +2 -5
- package/lib/mjs/utils/i18n.js +5 -32
- package/lib/mjs/widgets/CalendarWidget.js +27 -27
- package/package.json +11 -27
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import _ from 'lodash';
|
|
3
3
|
import { Utils } from '@formio/core/utils';
|
|
4
4
|
const { getComponentPaths } = Utils;
|
|
5
|
-
import { componentValueTypes
|
|
5
|
+
import { componentValueTypes } from '../../../utils/utils';
|
|
6
6
|
import Component from '../component/Component';
|
|
7
7
|
import NestedDataComponent from '../nesteddata/NestedDataComponent';
|
|
8
8
|
export default class NestedArrayComponent extends NestedDataComponent {
|
|
@@ -18,7 +18,7 @@ export default class NestedArrayComponent extends NestedDataComponent {
|
|
|
18
18
|
return this.iteratableRows[component.rowIndex].data;
|
|
19
19
|
}
|
|
20
20
|
get iteratableRows() {
|
|
21
|
-
throw new Error(
|
|
21
|
+
throw new Error('Getter #iteratableRows() is not implemented');
|
|
22
22
|
}
|
|
23
23
|
get rowIndex() {
|
|
24
24
|
return this._rowIndex;
|
|
@@ -63,7 +63,7 @@ export default class NestedArrayComponent extends NestedDataComponent {
|
|
|
63
63
|
return this.validateComponents([this.component], data, flags);
|
|
64
64
|
}
|
|
65
65
|
checkRow(...args) {
|
|
66
|
-
console.log(
|
|
66
|
+
console.log('Deprecation Warning: checkRow method has been replaced with processRow');
|
|
67
67
|
return this.processRow.call(this, ...args);
|
|
68
68
|
}
|
|
69
69
|
processRow(method, data, opts, row, components, silentCheck) {
|
|
@@ -110,60 +110,38 @@ export default class NestedArrayComponent extends NestedDataComponent {
|
|
|
110
110
|
}
|
|
111
111
|
});
|
|
112
112
|
}
|
|
113
|
-
_getEmailTableHeader(options) {
|
|
114
|
-
let row = '';
|
|
115
|
-
const getHeaderCell = (component) => {
|
|
116
|
-
if (!component.isInputComponent || !component.visible || component.skipInEmail) {
|
|
117
|
-
return '';
|
|
118
|
-
}
|
|
119
|
-
const label = component.label || component.key;
|
|
120
|
-
return `<th style="padding: 5px 10px;">${this.t(label, { _userInput: true })}</th>`;
|
|
121
|
-
};
|
|
122
|
-
const components = this.getComponents(0);
|
|
123
|
-
for (const component of components) {
|
|
124
|
-
if (component.isInputComponent) {
|
|
125
|
-
row += getHeaderCell(component);
|
|
126
|
-
}
|
|
127
|
-
else if (isLayoutComponent(component) && typeof component.everyComponent === 'function') {
|
|
128
|
-
component.everyComponent((comp) => {
|
|
129
|
-
row += getHeaderCell(comp);
|
|
130
|
-
}, options);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
return `<thead><tr>${row}</tr></thead>`;
|
|
134
|
-
}
|
|
135
|
-
_getEmailTableBody(options) {
|
|
136
|
-
const getBodyCell = (component) => {
|
|
137
|
-
if (!component.isInputComponent || !component.visible || component.skipInEmail) {
|
|
138
|
-
return '';
|
|
139
|
-
}
|
|
140
|
-
return `<td style="padding: 5px 10px;">${component.getView(component.dataValue, options)}</td>`;
|
|
141
|
-
};
|
|
142
|
-
const rows = [];
|
|
143
|
-
for (const { components } of this.iteratableRows) {
|
|
144
|
-
let row = '';
|
|
145
|
-
for (const component of components) {
|
|
146
|
-
if (component.isInputComponent) {
|
|
147
|
-
row += getBodyCell(component);
|
|
148
|
-
}
|
|
149
|
-
else if (isLayoutComponent(component) && typeof component.everyComponent === 'function') {
|
|
150
|
-
component.everyComponent((comp) => {
|
|
151
|
-
row += getBodyCell(comp);
|
|
152
|
-
}, options);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
rows.push(`<tr>${row}</tr>`);
|
|
156
|
-
}
|
|
157
|
-
return `<tbody>${rows.join('')}</tbody>`;
|
|
158
|
-
}
|
|
159
113
|
getValueAsString(value, options) {
|
|
160
114
|
if (options?.email) {
|
|
161
|
-
|
|
115
|
+
let result = (`
|
|
162
116
|
<table border="1" style="width:100%">
|
|
163
|
-
|
|
164
|
-
|
|
117
|
+
<thead>
|
|
118
|
+
<tr>
|
|
119
|
+
`);
|
|
120
|
+
this.component.components?.forEach((component) => {
|
|
121
|
+
const label = component.label || component.key;
|
|
122
|
+
result += `<th style="padding: 5px 10px;">${label}</th>`;
|
|
123
|
+
});
|
|
124
|
+
result += (`
|
|
125
|
+
</tr>
|
|
126
|
+
</thead>
|
|
127
|
+
<tbody>
|
|
128
|
+
`);
|
|
129
|
+
this.iteratableRows.forEach(({ components }) => {
|
|
130
|
+
result += '<tr>';
|
|
131
|
+
_.each(components, (component) => {
|
|
132
|
+
result += '<td style="padding:5px 10px;">';
|
|
133
|
+
if (component.isInputComponent && component.visible && !component.skipInEmail) {
|
|
134
|
+
result += component.getView(component.dataValue, options);
|
|
135
|
+
}
|
|
136
|
+
result += '</td>';
|
|
137
|
+
});
|
|
138
|
+
result += '</tr>';
|
|
139
|
+
});
|
|
140
|
+
result += (`
|
|
141
|
+
</tbody>
|
|
165
142
|
</table>
|
|
166
|
-
|
|
143
|
+
`);
|
|
144
|
+
return result;
|
|
167
145
|
}
|
|
168
146
|
if (!value || !value.length) {
|
|
169
147
|
return '';
|
|
@@ -317,7 +317,7 @@ export default class AddressComponent extends ContainerComponent {
|
|
|
317
317
|
return !this.isMultiple && (this.builderMode || this.manualModeEnabled);
|
|
318
318
|
}
|
|
319
319
|
get addAnother() {
|
|
320
|
-
return this.t(this.component.addAnother || '
|
|
320
|
+
return this.t(this.component.addAnother || 'Add Another');
|
|
321
321
|
}
|
|
322
322
|
renderElement(value) {
|
|
323
323
|
return this.renderTemplate(this.templateName, {
|
|
@@ -336,17 +336,17 @@ export default class ButtonComponent extends Field {
|
|
|
336
336
|
break;
|
|
337
337
|
case 'oauth':
|
|
338
338
|
if (this.root === this) {
|
|
339
|
-
console.warn(
|
|
339
|
+
console.warn('You must add the OAuth button to a form for it to function properly');
|
|
340
340
|
return;
|
|
341
341
|
}
|
|
342
342
|
// Display Alert if OAuth config is missing
|
|
343
343
|
if (!this.oauthConfig) {
|
|
344
|
-
this.root.setAlert('danger',
|
|
344
|
+
this.root.setAlert('danger', 'OAuth not configured. You must configure oauth for your project before it will work.');
|
|
345
345
|
break;
|
|
346
346
|
}
|
|
347
347
|
// Display Alert if oAuth has an error is missing
|
|
348
348
|
if (this.oauthConfig.error) {
|
|
349
|
-
this.root.setAlert('danger',
|
|
349
|
+
this.root.setAlert('danger', `The Following Error Has Occured ${this.oauthConfig.error}`);
|
|
350
350
|
break;
|
|
351
351
|
}
|
|
352
352
|
this.openOauth(this.oauthConfig);
|
|
@@ -355,7 +355,7 @@ export default class ButtonComponent extends Field {
|
|
|
355
355
|
}
|
|
356
356
|
openOauth(settings) {
|
|
357
357
|
if (!this.root.formio) {
|
|
358
|
-
console.warn(
|
|
358
|
+
console.warn('You must attach a Form API url to your form in order to use OAuth buttons.');
|
|
359
359
|
return;
|
|
360
360
|
}
|
|
361
361
|
/*eslint-disable camelcase */
|
|
@@ -403,7 +403,7 @@ export default class ButtonComponent extends Field {
|
|
|
403
403
|
}
|
|
404
404
|
// TODO: check for error response here
|
|
405
405
|
if (settings.state !== params.state) {
|
|
406
|
-
this.root.setAlert('danger',
|
|
406
|
+
this.root.setAlert('danger', 'OAuth state does not match. Please try logging in again.');
|
|
407
407
|
return;
|
|
408
408
|
}
|
|
409
409
|
// Depending on where the settings came from, submit to either the submission endpoint (old) or oauth endpoint (new).
|
|
@@ -436,7 +436,7 @@ export default class ButtonComponent extends Field {
|
|
|
436
436
|
}
|
|
437
437
|
catch (error) {
|
|
438
438
|
if (error.name !== 'SecurityError' && (error.name !== 'Error' || error.message !== 'Permission denied')) {
|
|
439
|
-
this.root.setAlert('danger',
|
|
439
|
+
this.root.setAlert('danger', error.message || error);
|
|
440
440
|
}
|
|
441
441
|
}
|
|
442
442
|
if (!popup || popup.closed || popup.closed === undefined) {
|
|
@@ -43,7 +43,7 @@ export default class CheckBoxComponent extends Field {
|
|
|
43
43
|
attach(element: any): Promise<void>;
|
|
44
44
|
input: any;
|
|
45
45
|
detach(element: any): void;
|
|
46
|
-
get emptyValue(): false |
|
|
46
|
+
get emptyValue(): false | null;
|
|
47
47
|
getValueAt(index: any): any;
|
|
48
48
|
get checked(): boolean;
|
|
49
49
|
setCheckedState(value: any): any;
|
|
@@ -116,7 +116,7 @@ export default class CheckBoxComponent extends Field {
|
|
|
116
116
|
super.detach();
|
|
117
117
|
}
|
|
118
118
|
get emptyValue() {
|
|
119
|
-
return this.component.inputType === 'radio' ?
|
|
119
|
+
return this.component.inputType === 'radio' ? null : false;
|
|
120
120
|
}
|
|
121
121
|
isEmpty(value = this.dataValue) {
|
|
122
122
|
return super.isEmpty(value) || value === false;
|
|
@@ -187,7 +187,7 @@ export default class CheckBoxComponent extends Field {
|
|
|
187
187
|
if (_.isUndefined(value) && this.inDataTable) {
|
|
188
188
|
return '';
|
|
189
189
|
}
|
|
190
|
-
return this.t(hasValue ? '
|
|
190
|
+
return this.t(hasValue ? 'Yes' : 'No');
|
|
191
191
|
}
|
|
192
192
|
updateValue(value, flags) {
|
|
193
193
|
// If this is a radio and is alredy checked, uncheck it.
|
|
@@ -12,7 +12,6 @@ export default class DataGridComponent extends NestedArrayComponent {
|
|
|
12
12
|
tabIndex: number;
|
|
13
13
|
rows: any[] | undefined;
|
|
14
14
|
columns: any[] | undefined;
|
|
15
|
-
dragulaReady: Promise<any> | undefined;
|
|
16
15
|
visibleColumns: {} | undefined;
|
|
17
16
|
set dataValue(value: any[]);
|
|
18
17
|
get dataValue(): any[];
|
|
@@ -71,7 +70,6 @@ export default class DataGridComponent extends NestedArrayComponent {
|
|
|
71
70
|
*/
|
|
72
71
|
reorderValues(valuesArr: any, oldPosition: number, newPosition: number, movedBelow: boolean | any): void;
|
|
73
72
|
onReorder(element: any, _target: any, _source: any, sibling: any): void;
|
|
74
|
-
onCloned(el: any, original: any): void;
|
|
75
73
|
focusOnNewRowElement(row: any): void;
|
|
76
74
|
addRow(): void;
|
|
77
75
|
updateComponentsRowIndex(components: any, rowIndex: any): void;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
2
|
import NestedArrayComponent from '../_classes/nestedarray/NestedArrayComponent';
|
|
3
3
|
import { fastCloneDeep, getFocusableElements } from '../../utils/utils';
|
|
4
|
+
import dragula from 'dragula';
|
|
4
5
|
export default class DataGridComponent extends NestedArrayComponent {
|
|
5
6
|
static schema(...extend) {
|
|
6
7
|
return NestedArrayComponent.schema({
|
|
@@ -37,9 +38,6 @@ export default class DataGridComponent extends NestedArrayComponent {
|
|
|
37
38
|
if (this.initRows || !_.isEqual(this.dataValue, this.emptyValue)) {
|
|
38
39
|
this.createRows(true);
|
|
39
40
|
}
|
|
40
|
-
if (this.allowReorder) {
|
|
41
|
-
this.dragulaReady = this.getDragula();
|
|
42
|
-
}
|
|
43
41
|
this.visibleColumns = {};
|
|
44
42
|
this.prevHasAddButton = this.hasAddButton();
|
|
45
43
|
this.checkColumns();
|
|
@@ -272,25 +270,31 @@ export default class DataGridComponent extends NestedArrayComponent {
|
|
|
272
270
|
this.refs[`${this.datagridKey}-row`].forEach((row, index) => {
|
|
273
271
|
row.dragInfo = { index };
|
|
274
272
|
});
|
|
275
|
-
this.
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
273
|
+
this.dragula = dragula([this.refs[`${this.datagridKey}-tbody`]], {
|
|
274
|
+
moves: (_draggedElement, _oldParent, clickedElement) => {
|
|
275
|
+
const clickedElementKey = clickedElement.getAttribute('data-key');
|
|
276
|
+
const oldParentKey = _oldParent.getAttribute('data-key');
|
|
277
|
+
//Check if the clicked button belongs to that container, if false, it belongs to the nested container
|
|
278
|
+
if (oldParentKey === clickedElementKey) {
|
|
279
|
+
return clickedElement.classList.contains('formio-drag-button');
|
|
280
|
+
}
|
|
282
281
|
}
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
if (
|
|
289
|
-
|
|
282
|
+
}).on('drop', this.onReorder.bind(this));
|
|
283
|
+
this.dragula.on('cloned', (el, original) => {
|
|
284
|
+
if (el && el.children && original && original.children) {
|
|
285
|
+
_.each(original.children, (child, index) => {
|
|
286
|
+
const styles = getComputedStyle(child, null);
|
|
287
|
+
if (styles.cssText !== '') {
|
|
288
|
+
el.children[index].style.cssText = styles.cssText;
|
|
290
289
|
}
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
290
|
+
else {
|
|
291
|
+
const cssText = Object.values(styles).reduce((css, propertyName) => {
|
|
292
|
+
return `${css}${propertyName}:${styles.getPropertyValue(propertyName)};`;
|
|
293
|
+
}, '');
|
|
294
|
+
el.children[index].style.cssText = cssText;
|
|
295
|
+
}
|
|
296
|
+
});
|
|
297
|
+
}
|
|
294
298
|
});
|
|
295
299
|
}
|
|
296
300
|
this.refs[`${this.datagridKey}-addRow`].forEach((addButton) => {
|
|
@@ -339,7 +343,7 @@ export default class DataGridComponent extends NestedArrayComponent {
|
|
|
339
343
|
}
|
|
340
344
|
onReorder(element, _target, _source, sibling) {
|
|
341
345
|
if (!element.dragInfo || (sibling && !sibling.dragInfo)) {
|
|
342
|
-
console.warn(
|
|
346
|
+
console.warn('There is no Drag Info available for either dragged or sibling element');
|
|
343
347
|
return;
|
|
344
348
|
}
|
|
345
349
|
const oldPosition = element.dragInfo.index;
|
|
@@ -350,29 +354,10 @@ export default class DataGridComponent extends NestedArrayComponent {
|
|
|
350
354
|
this.reorderValues(dataValue, oldPosition, newPosition, movedBelow);
|
|
351
355
|
//reorder select data
|
|
352
356
|
this.reorderValues(_.get(this.root, `submission.metadata.selectData.${this.path}`, []), oldPosition, newPosition, movedBelow);
|
|
353
|
-
// When components are reordered we need to set the dataGrid and form pristine properties to false
|
|
354
|
-
this.root.pristine = false;
|
|
355
|
-
this.pristine = false;
|
|
356
357
|
//need to re-build rows to re-calculate indexes and other indexed fields for component instance (like rows for ex.)
|
|
357
358
|
this.setValue(dataValue, { isReordered: true });
|
|
358
359
|
this.rebuild();
|
|
359
360
|
}
|
|
360
|
-
onCloned(el, original) {
|
|
361
|
-
if (el && el.children && original && original.children) {
|
|
362
|
-
_.each(original.children, (child, index) => {
|
|
363
|
-
const styles = getComputedStyle(child, null);
|
|
364
|
-
if (styles.cssText !== '') {
|
|
365
|
-
el.children[index].style.cssText = styles.cssText;
|
|
366
|
-
}
|
|
367
|
-
else {
|
|
368
|
-
const cssText = Object.values(styles).reduce((css, propertyName) => {
|
|
369
|
-
return `${css}${propertyName}:${styles.getPropertyValue(propertyName)};`;
|
|
370
|
-
}, '');
|
|
371
|
-
el.children[index].style.cssText = cssText;
|
|
372
|
-
}
|
|
373
|
-
});
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
361
|
focusOnNewRowElement(row) {
|
|
377
362
|
Object.keys(row).find((key) => {
|
|
378
363
|
const element = row[key].element;
|
|
@@ -430,7 +415,7 @@ export default class DataGridComponent extends NestedArrayComponent {
|
|
|
430
415
|
}
|
|
431
416
|
removeRow(index) {
|
|
432
417
|
const makeEmpty = index === 0 && this.rows.length === 1;
|
|
433
|
-
const flags = { isReordered: !makeEmpty, resetValue: makeEmpty
|
|
418
|
+
const flags = { isReordered: !makeEmpty, resetValue: makeEmpty };
|
|
434
419
|
this.splice(index, flags);
|
|
435
420
|
this.emit('dataGridDeleteRow', { index });
|
|
436
421
|
const [row] = this.rows.splice(index, 1);
|
|
@@ -53,13 +53,11 @@ export default class DayComponent extends Field {
|
|
|
53
53
|
// Empty value used before 9.3.x
|
|
54
54
|
static oldEmptyValue = '00/00/0000';
|
|
55
55
|
constructor(component, options, data) {
|
|
56
|
-
if (
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
component.minDate = moment(component.minDate, 'YYYY-MM-DD').toISOString();
|
|
62
|
-
}
|
|
56
|
+
if (component.maxDate && component.maxDate.indexOf('moment(') === -1) {
|
|
57
|
+
component.maxDate = moment(component.maxDate, 'YYYY-MM-DD').toISOString();
|
|
58
|
+
}
|
|
59
|
+
if (component.minDate && component.minDate.indexOf('moment(') === -1) {
|
|
60
|
+
component.minDate = moment(component.minDate, 'YYYY-MM-DD').toISOString();
|
|
63
61
|
}
|
|
64
62
|
super(component, options, data);
|
|
65
63
|
}
|
|
@@ -176,7 +174,7 @@ export default class DayComponent extends Field {
|
|
|
176
174
|
this._months = [
|
|
177
175
|
{
|
|
178
176
|
value: '',
|
|
179
|
-
label: _.get(this.component, 'fields.month.placeholder') || (this.hideInputLabels ? this.t('
|
|
177
|
+
label: _.get(this.component, 'fields.month.placeholder') || (this.hideInputLabels ? this.t('Month') : '')
|
|
180
178
|
},
|
|
181
179
|
{ value: 1, label: 'January' },
|
|
182
180
|
{ value: 2, label: 'February' },
|
|
@@ -270,7 +268,7 @@ export default class DayComponent extends Field {
|
|
|
270
268
|
this.saveCaretPosition(element, name);
|
|
271
269
|
}
|
|
272
270
|
catch (err) {
|
|
273
|
-
console.warn(
|
|
271
|
+
console.warn('An error occurred while trying to save caret position', err);
|
|
274
272
|
}
|
|
275
273
|
this.updateValue(null, {
|
|
276
274
|
modified: true,
|
|
@@ -43,7 +43,7 @@ export default class EditGridComponent extends NestedArrayComponent {
|
|
|
43
43
|
get defaultValue(): any[];
|
|
44
44
|
hasRemoveButtons(): boolean;
|
|
45
45
|
editRows: any;
|
|
46
|
-
checkRowVariableTypeComponents(editRow: any, rowIndex: any):
|
|
46
|
+
checkRowVariableTypeComponents(editRow: any, rowIndex: any): void;
|
|
47
47
|
setVariableTypeComponents(): void;
|
|
48
48
|
variableTypeComponentsIndexes: any[] | undefined;
|
|
49
49
|
isOpen(editRow: any): boolean;
|
|
@@ -115,10 +115,10 @@ export default class EditGridComponent extends NestedArrayComponent {
|
|
|
115
115
|
}
|
|
116
116
|
get defaultDialogTemplate() {
|
|
117
117
|
return `
|
|
118
|
-
<h3 ${this._referenceAttributeName}="dialogHeader">${this.t('
|
|
118
|
+
<h3 ${this._referenceAttributeName}="dialogHeader">${this.t('Do you want to clear data?')}</h3>
|
|
119
119
|
<div style="display:flex; justify-content: flex-end;">
|
|
120
|
-
<button ${this._referenceAttributeName}="dialogCancelButton" class="btn btn-secondary" aria-label="${this.t('
|
|
121
|
-
<button ${this._referenceAttributeName}="dialogYesButton" class="btn btn-danger" aria-label="${this.t('
|
|
120
|
+
<button ${this._referenceAttributeName}="dialogCancelButton" class="btn btn-secondary" aria-label="${this.t('Cancel')}">${this.t('Cancel')}</button>
|
|
121
|
+
<button ${this._referenceAttributeName}="dialogYesButton" class="btn btn-danger" aria-label="${this.t('Yes, delete it')}">${this.t('Yes, delete it')}</button>
|
|
122
122
|
</div>
|
|
123
123
|
`;
|
|
124
124
|
}
|
|
@@ -289,15 +289,12 @@ export default class EditGridComponent extends NestedArrayComponent {
|
|
|
289
289
|
}
|
|
290
290
|
checkRowVariableTypeComponents(editRow, rowIndex) {
|
|
291
291
|
const rowComponents = editRow.components;
|
|
292
|
-
let typeChanged = false;
|
|
293
292
|
if (_.some(this.variableTypeComponentsIndexes, (compIndex) => {
|
|
294
293
|
const variableTypeComp = rowComponents[compIndex];
|
|
295
294
|
return variableTypeComp.type !== variableTypeComp.component.type;
|
|
296
295
|
})) {
|
|
297
296
|
editRow.components = this.createRowComponents(editRow.data, rowIndex, true);
|
|
298
|
-
typeChanged = true;
|
|
299
297
|
}
|
|
300
|
-
return typeChanged;
|
|
301
298
|
}
|
|
302
299
|
setVariableTypeComponents() {
|
|
303
300
|
//set components which type is changing within a row (e.g.,by mergeComponentSchema action)
|
|
@@ -664,11 +661,6 @@ export default class EditGridComponent extends NestedArrayComponent {
|
|
|
664
661
|
}
|
|
665
662
|
},
|
|
666
663
|
}, this.component.saveRow || 'Save'));
|
|
667
|
-
this.emit('editGridOpenModal', {
|
|
668
|
-
component: this.component,
|
|
669
|
-
row: editRow,
|
|
670
|
-
instance: this,
|
|
671
|
-
});
|
|
672
664
|
return this.attachComponents(modalContent, components);
|
|
673
665
|
}
|
|
674
666
|
showDialog(rowIndex) {
|
|
@@ -726,11 +718,6 @@ export default class EditGridComponent extends NestedArrayComponent {
|
|
|
726
718
|
editRow.data = dataSnapshot;
|
|
727
719
|
this.restoreRowContext(editRow);
|
|
728
720
|
}
|
|
729
|
-
this.emit('editGridEditRow', {
|
|
730
|
-
component: this.component,
|
|
731
|
-
row: editRow,
|
|
732
|
-
instance: this,
|
|
733
|
-
});
|
|
734
721
|
if (this.component.modal) {
|
|
735
722
|
return this.addRowModal(rowIndex);
|
|
736
723
|
}
|
|
@@ -939,10 +926,8 @@ export default class EditGridComponent extends NestedArrayComponent {
|
|
|
939
926
|
this.validateRow(editRow, false, false);
|
|
940
927
|
}
|
|
941
928
|
if (this.variableTypeComponentsIndexes.length) {
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
this.redraw();
|
|
945
|
-
}
|
|
929
|
+
this.checkRowVariableTypeComponents(editRow, rowIndex);
|
|
930
|
+
this.redraw();
|
|
946
931
|
}
|
|
947
932
|
};
|
|
948
933
|
const comp = this.createComponent(_.assign({}, column, { row: options.row }), options, row, null, recreatePartially && currentRowComponents ? currentRowComponents[colIndex] : null);
|
|
@@ -1023,16 +1008,13 @@ export default class EditGridComponent extends NestedArrayComponent {
|
|
|
1023
1008
|
if (valid === null) {
|
|
1024
1009
|
editRow.errors.push({
|
|
1025
1010
|
type: 'error',
|
|
1026
|
-
message:
|
|
1011
|
+
message: `Invalid row validation for ${this.key}`
|
|
1027
1012
|
});
|
|
1028
1013
|
}
|
|
1029
1014
|
}
|
|
1030
|
-
if (
|
|
1015
|
+
if (!this.component.rowDrafts || this.root?.submitted) {
|
|
1031
1016
|
this.showRowErrorAlerts(editRow, editRow.errors);
|
|
1032
1017
|
}
|
|
1033
|
-
else if (editRow.errors?.length) {
|
|
1034
|
-
this.setCustomValidity(editRow.errors, dirty);
|
|
1035
|
-
}
|
|
1036
1018
|
return editRow.errors;
|
|
1037
1019
|
}
|
|
1038
1020
|
showRowErrorAlerts(editRow, errors) {
|
|
@@ -33,7 +33,7 @@ export default class FileComponent extends Field {
|
|
|
33
33
|
get dataReady(): Promise<any>;
|
|
34
34
|
loadImage(fileInfo: any): any;
|
|
35
35
|
get emptyValue(): never[];
|
|
36
|
-
getValueAsString(value: any
|
|
36
|
+
getValueAsString(value: any): any;
|
|
37
37
|
get defaultValue(): any[];
|
|
38
38
|
get hasTypes(): any;
|
|
39
39
|
_fileBrowseHidden: any;
|
|
@@ -98,18 +98,12 @@ export default class FileComponent extends Field {
|
|
|
98
98
|
if (this.component.privateDownload) {
|
|
99
99
|
fileInfo.private = true;
|
|
100
100
|
}
|
|
101
|
-
|
|
102
|
-
return this.fileService.downloadFile(fileInfo, this.component).then((result) => result.url);
|
|
101
|
+
return this.fileService.downloadFile(fileInfo).then((result) => result.url);
|
|
103
102
|
}
|
|
104
103
|
get emptyValue() {
|
|
105
104
|
return [];
|
|
106
105
|
}
|
|
107
|
-
getValueAsString(value
|
|
108
|
-
if (options?.review && !this.component.uploadOnly) {
|
|
109
|
-
return _.map(value, (val, index) => {
|
|
110
|
-
return `<a href="${val.url || '#'}" target="_blank" data-path='${this.path}' data-fileindex='${index}'>${val.originalName}</a>`;
|
|
111
|
-
}).join(', ');
|
|
112
|
-
}
|
|
106
|
+
getValueAsString(value) {
|
|
113
107
|
if (_.isArray(value)) {
|
|
114
108
|
return _.map(value, 'originalName').join(', ');
|
|
115
109
|
}
|
|
@@ -202,7 +196,7 @@ export default class FileComponent extends Field {
|
|
|
202
196
|
this.videoStream = stream;
|
|
203
197
|
const { videoPlayer } = this.refs;
|
|
204
198
|
if (!videoPlayer) {
|
|
205
|
-
console.warn(
|
|
199
|
+
console.warn('Video player not found in template.');
|
|
206
200
|
this.cameraMode = false;
|
|
207
201
|
this.redraw();
|
|
208
202
|
return;
|
|
@@ -227,7 +221,7 @@ export default class FileComponent extends Field {
|
|
|
227
221
|
takePicture() {
|
|
228
222
|
const { videoPlayer } = this.refs;
|
|
229
223
|
if (!videoPlayer) {
|
|
230
|
-
console.warn(
|
|
224
|
+
console.warn('Video player not found in template.');
|
|
231
225
|
this.cameraMode = false;
|
|
232
226
|
this.redraw();
|
|
233
227
|
return;
|
|
@@ -632,7 +626,7 @@ export default class FileComponent extends Field {
|
|
|
632
626
|
file,
|
|
633
627
|
size: file.size,
|
|
634
628
|
status: 'info',
|
|
635
|
-
message: this.t('
|
|
629
|
+
message: this.t('Processing file. Please wait...'),
|
|
636
630
|
hash: '',
|
|
637
631
|
};
|
|
638
632
|
}
|
|
@@ -661,7 +655,7 @@ export default class FileComponent extends Field {
|
|
|
661
655
|
return fileWithSameNameUploaded || fileWithSameNameUploading
|
|
662
656
|
? {
|
|
663
657
|
status: 'error',
|
|
664
|
-
message: this.t(fileWithSameNameUploading ? '
|
|
658
|
+
message: this.t(`File with the same name is already ${fileWithSameNameUploading ? 'being ' : ''}uploaded`),
|
|
665
659
|
}
|
|
666
660
|
: {};
|
|
667
661
|
}
|
|
@@ -670,7 +664,7 @@ export default class FileComponent extends Field {
|
|
|
670
664
|
if (this.component.filePattern && !this.validatePattern(file, this.component.filePattern)) {
|
|
671
665
|
return {
|
|
672
666
|
status: 'error',
|
|
673
|
-
message: this.t('
|
|
667
|
+
message: this.t('File is the wrong type; it must be {{ pattern }}', {
|
|
674
668
|
pattern: this.component.filePattern,
|
|
675
669
|
}),
|
|
676
670
|
};
|
|
@@ -679,7 +673,7 @@ export default class FileComponent extends Field {
|
|
|
679
673
|
if (this.component.fileMinSize && !this.validateMinSize(file, this.component.fileMinSize)) {
|
|
680
674
|
return {
|
|
681
675
|
status: 'error',
|
|
682
|
-
message: this.t('
|
|
676
|
+
message: this.t('File is too small; it must be at least {{ size }}', {
|
|
683
677
|
size: this.component.fileMinSize,
|
|
684
678
|
}),
|
|
685
679
|
};
|
|
@@ -688,7 +682,7 @@ export default class FileComponent extends Field {
|
|
|
688
682
|
if (this.component.fileMaxSize && !this.validateMaxSize(file, this.component.fileMaxSize)) {
|
|
689
683
|
return {
|
|
690
684
|
status: 'error',
|
|
691
|
-
message: this.t('
|
|
685
|
+
message: this.t('File is too big; it must be at most {{ size }}', {
|
|
692
686
|
size: this.component.fileMaxSize,
|
|
693
687
|
}),
|
|
694
688
|
};
|
|
@@ -700,7 +694,7 @@ export default class FileComponent extends Field {
|
|
|
700
694
|
return !fileService
|
|
701
695
|
? {
|
|
702
696
|
status: 'error',
|
|
703
|
-
message: this.t('
|
|
697
|
+
message: this.t('File Service not provided.'),
|
|
704
698
|
}
|
|
705
699
|
: {};
|
|
706
700
|
}
|
|
@@ -748,7 +742,7 @@ export default class FileComponent extends Field {
|
|
|
748
742
|
this.fileDropHidden = false;
|
|
749
743
|
return {
|
|
750
744
|
status: 'error',
|
|
751
|
-
message: this.t('
|
|
745
|
+
message: this.t('File processing has been failed.'),
|
|
752
746
|
};
|
|
753
747
|
}
|
|
754
748
|
finally {
|
|
@@ -782,7 +776,7 @@ export default class FileComponent extends Field {
|
|
|
782
776
|
return this.filesToSync.filesToUpload.push(fileToSync);
|
|
783
777
|
}
|
|
784
778
|
if (this.autoSync) {
|
|
785
|
-
fileToSync.message = this.t('
|
|
779
|
+
fileToSync.message = this.t('Ready to be uploaded into storage');
|
|
786
780
|
}
|
|
787
781
|
this.filesToSync.filesToUpload.push({
|
|
788
782
|
...fileToSync,
|
|
@@ -820,8 +814,8 @@ export default class FileComponent extends Field {
|
|
|
820
814
|
...fileInfo,
|
|
821
815
|
status: 'info',
|
|
822
816
|
message: this.autoSync
|
|
823
|
-
? this.t('
|
|
824
|
-
: this.t('
|
|
817
|
+
? this.t('Ready to be removed from storage')
|
|
818
|
+
: this.t('Preparing file to remove'),
|
|
825
819
|
});
|
|
826
820
|
const index = this.dataValue.findIndex(file => file.name === fileInfo.name);
|
|
827
821
|
this.splice(index);
|
|
@@ -859,7 +853,7 @@ export default class FileComponent extends Field {
|
|
|
859
853
|
}
|
|
860
854
|
await this.deleteFile(fileToSync);
|
|
861
855
|
fileToSync.status = 'success';
|
|
862
|
-
fileToSync.message = this.t('
|
|
856
|
+
fileToSync.message = this.t('Succefully removed');
|
|
863
857
|
}
|
|
864
858
|
catch (response) {
|
|
865
859
|
fileToSync.status = 'error';
|
|
@@ -927,7 +921,7 @@ export default class FileComponent extends Field {
|
|
|
927
921
|
}
|
|
928
922
|
fileInfo = await this.uploadFile(fileToSync);
|
|
929
923
|
fileToSync.status = 'success';
|
|
930
|
-
fileToSync.message = this.t('
|
|
924
|
+
fileToSync.message = this.t('Succefully uploaded');
|
|
931
925
|
fileInfo.originalName = fileToSync.originalName;
|
|
932
926
|
fileInfo.hash = fileToSync.hash;
|
|
933
927
|
}
|
|
@@ -1026,7 +1020,7 @@ export default class FileComponent extends Field {
|
|
|
1026
1020
|
}
|
|
1027
1021
|
await this.syncFiles();
|
|
1028
1022
|
return this.shouldSyncFiles
|
|
1029
|
-
? Promise.reject(
|
|
1023
|
+
? Promise.reject('Synchronization is failed')
|
|
1030
1024
|
: Promise.resolve();
|
|
1031
1025
|
}
|
|
1032
1026
|
catch (error) {
|