@formio/js 5.1.0-dev.6002.16f1966 → 5.1.0-dev.6010.98e774d
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 +6 -6
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.full.js +9 -9
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.js +2 -2
- package/dist/formio.min.js +1 -1
- package/dist/formio.utils.js +1 -1
- package/dist/formio.utils.min.js +1 -1
- package/lib/cjs/Webform.d.ts +4 -1
- package/lib/cjs/Webform.js +18 -13
- package/lib/cjs/components/_classes/component/Component.js +10 -1
- package/lib/cjs/components/datetime/DateTime.d.ts +1 -1
- package/lib/cjs/components/datetime/DateTime.js +5 -5
- package/lib/cjs/components/form/editForm/Form.edit.data.js +1 -1
- package/lib/cjs/components/form/editForm/Form.edit.form.js +2 -2
- package/lib/cjs/components/select/editForm/Select.edit.data.js +2 -2
- package/lib/cjs/providers/storage/s3.js +3 -3
- package/lib/cjs/providers/storage/xhr.d.ts +1 -0
- package/lib/cjs/providers/storage/xhr.js +6 -1
- package/lib/cjs/utils/utils.d.ts +2 -1
- package/lib/cjs/utils/utils.js +3 -2
- package/lib/mjs/Webform.d.ts +4 -1
- package/lib/mjs/Webform.js +18 -13
- package/lib/mjs/components/_classes/component/Component.js +10 -1
- package/lib/mjs/components/datetime/DateTime.d.ts +1 -1
- package/lib/mjs/components/datetime/DateTime.js +5 -5
- package/lib/mjs/components/form/editForm/Form.edit.data.js +1 -1
- package/lib/mjs/components/form/editForm/Form.edit.form.js +2 -2
- package/lib/mjs/components/select/editForm/Select.edit.data.js +2 -2
- package/lib/mjs/providers/storage/s3.js +3 -3
- package/lib/mjs/providers/storage/xhr.d.ts +1 -0
- package/lib/mjs/providers/storage/xhr.js +6 -1
- package/lib/mjs/utils/utils.d.ts +2 -1
- package/lib/mjs/utils/utils.js +3 -2
- package/package.json +1 -1
package/lib/cjs/Webform.d.ts
CHANGED
@@ -190,7 +190,10 @@ declare class Webform extends NestedDataComponent {
|
|
190
190
|
get language(): string;
|
191
191
|
root: this;
|
192
192
|
localRoot: this;
|
193
|
+
beforeInit(): void;
|
194
|
+
executeFormController: any;
|
193
195
|
get emptyValue(): null;
|
196
|
+
get shouldCallFormController(): any;
|
194
197
|
get shadowRoot(): any;
|
195
198
|
/**
|
196
199
|
* Add a language for translations
|
@@ -360,7 +363,7 @@ declare class Webform extends NestedDataComponent {
|
|
360
363
|
* @returns {Promise} - The promise that is triggered when the form is built.
|
361
364
|
*/
|
362
365
|
init(): Promise<any>;
|
363
|
-
|
366
|
+
_executeFormController(): void;
|
364
367
|
build(element: any): Promise<any>;
|
365
368
|
getClassName(): string;
|
366
369
|
render(): string;
|
package/lib/cjs/Webform.js
CHANGED
@@ -315,12 +315,24 @@ class Webform extends NestedDataComponent_1.default {
|
|
315
315
|
this.localRoot = this;
|
316
316
|
}
|
317
317
|
/* eslint-enable max-statements */
|
318
|
+
beforeInit() {
|
319
|
+
this.executeFormController = lodash_1.default.once(this._executeFormController);
|
320
|
+
}
|
318
321
|
get language() {
|
319
322
|
return this.options.language;
|
320
323
|
}
|
321
324
|
get emptyValue() {
|
322
325
|
return null;
|
323
326
|
}
|
327
|
+
get shouldCallFormController() {
|
328
|
+
// If no controller value or
|
329
|
+
// hidden and set to clearOnHide (Don't calculate a value for a hidden field set to clear when hidden)
|
330
|
+
return (this.form &&
|
331
|
+
this.form.controller &&
|
332
|
+
!((!this.visible || this.component.hidden) &&
|
333
|
+
this.component.clearOnHide &&
|
334
|
+
!this.rootPristine));
|
335
|
+
}
|
324
336
|
componentContext() {
|
325
337
|
return this._data;
|
326
338
|
}
|
@@ -899,19 +911,12 @@ class Webform extends NestedDataComponent_1.default {
|
|
899
911
|
this.on('resetForm', () => this.resetValue(), true);
|
900
912
|
this.on('deleteSubmission', () => this.deleteSubmission(), true);
|
901
913
|
this.on('refreshData', () => this.updateValue(), true);
|
902
|
-
this.
|
914
|
+
if (this.shouldCallFormController) {
|
915
|
+
this.executeFormController();
|
916
|
+
}
|
903
917
|
return this.formReady;
|
904
918
|
}
|
905
|
-
|
906
|
-
// If no controller value or
|
907
|
-
// hidden and set to clearOnHide (Don't calculate a value for a hidden field set to clear when hidden)
|
908
|
-
if (!this.form ||
|
909
|
-
!this.form.controller ||
|
910
|
-
((!this.visible || this.component.hidden) &&
|
911
|
-
this.component.clearOnHide &&
|
912
|
-
!this.rootPristine)) {
|
913
|
-
return false;
|
914
|
-
}
|
919
|
+
_executeFormController() {
|
915
920
|
this.formReady.then(() => {
|
916
921
|
this.evaluate(this.form.controller, {
|
917
922
|
components: this.components,
|
@@ -1534,11 +1539,11 @@ class Webform extends NestedDataComponent_1.default {
|
|
1534
1539
|
return;
|
1535
1540
|
}
|
1536
1541
|
const captchaComponent = [];
|
1537
|
-
|
1542
|
+
(0, formUtils_1.eachComponent)(this.components, (component) => {
|
1538
1543
|
if (/^(re)?captcha$/.test(component.type) && component.component.eventType === 'formLoad') {
|
1539
1544
|
captchaComponent.push(component);
|
1540
1545
|
}
|
1541
|
-
});
|
1546
|
+
}, true);
|
1542
1547
|
if (captchaComponent.length > 0) {
|
1543
1548
|
if (this.parent) {
|
1544
1549
|
this.parent.subFormReady.then(() => {
|
@@ -453,6 +453,9 @@ class Component extends Element_1.default {
|
|
453
453
|
// Allow anyone to hook into the component creation.
|
454
454
|
this.hook('component');
|
455
455
|
if (!this.options.skipInit) {
|
456
|
+
if (typeof this.beforeInit === 'function') {
|
457
|
+
this.beforeInit();
|
458
|
+
}
|
456
459
|
this.init();
|
457
460
|
}
|
458
461
|
}
|
@@ -1948,15 +1951,21 @@ class Component extends Element_1.default {
|
|
1948
1951
|
}
|
1949
1952
|
// Check advanced conditions (and cache the result)
|
1950
1953
|
const isConditionallyHidden = this.checkConditionallyHidden(data, row) || this._parentConditionallyHidden;
|
1954
|
+
let shouldClear = false;
|
1951
1955
|
if (isConditionallyHidden !== this._conditionallyHidden) {
|
1952
1956
|
this._conditionallyHidden = isConditionallyHidden;
|
1953
|
-
|
1957
|
+
shouldClear = true;
|
1954
1958
|
}
|
1955
1959
|
// Check visibility
|
1956
1960
|
const visible = (this.hasCondition() ? !this.conditionallyHidden : !this.component.hidden);
|
1957
1961
|
if (this.visible !== visible) {
|
1958
1962
|
this.visible = visible;
|
1959
1963
|
}
|
1964
|
+
// Wait for visibility to update for nested components, so the component state is up-to-date when
|
1965
|
+
// calling clearOnHide
|
1966
|
+
if (shouldClear) {
|
1967
|
+
this.clearOnHide();
|
1968
|
+
}
|
1960
1969
|
return visible;
|
1961
1970
|
}
|
1962
1971
|
/**
|
@@ -20,6 +20,6 @@ export default class DateTimeComponent extends Input {
|
|
20
20
|
get momentFormat(): string;
|
21
21
|
createWrapper(): boolean;
|
22
22
|
checkValidity(data: any, dirty: any, rowData: any): boolean;
|
23
|
-
getValueAsString(value: any): any;
|
23
|
+
getValueAsString(value: any, options: any): any;
|
24
24
|
}
|
25
25
|
import Input from '../_classes/input/Input';
|
@@ -104,8 +104,8 @@ class DateTimeComponent extends Input_1.default {
|
|
104
104
|
/* eslint-disable camelcase */
|
105
105
|
this.component.widget = Object.assign({ type: 'calendar', timezone, displayInTimezone: lodash_1.default.get(this.component, 'displayInTimezone', 'viewer'), locale: this.options.language, useLocaleSettings: lodash_1.default.get(this.component, 'useLocaleSettings', false), allowInput: lodash_1.default.get(this.component, 'allowInput', true), mode: 'single', enableTime: lodash_1.default.get(this.component, 'enableTime', true), noCalendar: !lodash_1.default.get(this.component, 'enableDate', true), format: this.component.format, hourIncrement: lodash_1.default.get(this.component, 'timePicker.hourStep', 1), minuteIncrement: lodash_1.default.get(this.component, 'timePicker.minuteStep', 5), time_24hr: time24hr, readOnly: this.options.readOnly, minDate: lodash_1.default.get(this.component, 'datePicker.minDate'), disabledDates: lodash_1.default.get(this.component, 'datePicker.disable'), disableWeekends: lodash_1.default.get(this.component, 'datePicker.disableWeekends'), disableWeekdays: lodash_1.default.get(this.component, 'datePicker.disableWeekdays'), disableFunction: lodash_1.default.get(this.component, 'datePicker.disableFunction'), maxDate: lodash_1.default.get(this.component, 'datePicker.maxDate') }, customOptions);
|
106
106
|
// update originalComponent to include widget and other updated settings
|
107
|
-
// it is done here since these settings depend on properties present after the component is initialized
|
108
|
-
// originalComponent is used to restore the component (and widget) after evaluating field logic
|
107
|
+
// it is done here since these settings depend on properties present after the component is initialized
|
108
|
+
// originalComponent is used to restore the component (and widget) after evaluating field logic
|
109
109
|
this.originalComponent = (0, utils_2.fastCloneDeep)(this.component);
|
110
110
|
/* eslint-enable camelcase */
|
111
111
|
}
|
@@ -153,15 +153,15 @@ class DateTimeComponent extends Input_1.default {
|
|
153
153
|
}
|
154
154
|
return super.checkValidity(data, dirty, rowData);
|
155
155
|
}
|
156
|
-
getValueAsString(value) {
|
156
|
+
getValueAsString(value, options) {
|
157
157
|
let format = utils_1.default.convertFormatToMoment(this.component.format);
|
158
158
|
format += format.match(/z$/) ? '' : ' z';
|
159
159
|
const timezone = this.timezone;
|
160
160
|
if (value && !this.attached && timezone) {
|
161
161
|
if (Array.isArray(value) && this.component.multiple) {
|
162
|
-
return value.map(item => lodash_1.default.trim(utils_1.default.momentDate(item, format, timezone).format(format))).join(', ');
|
162
|
+
return value.map(item => lodash_1.default.trim(utils_1.default.momentDate(item, format, timezone, options).format(format))).join(', ');
|
163
163
|
}
|
164
|
-
return lodash_1.default.trim(utils_1.default.momentDate(value, format, timezone).format(format));
|
164
|
+
return lodash_1.default.trim(utils_1.default.momentDate(value, format, timezone, options).format(format));
|
165
165
|
}
|
166
166
|
if (Array.isArray(value) && this.component.multiple) {
|
167
167
|
return value.map(item => lodash_1.default.trim((0, moment_1.default)(item).format(format))).join(', ');
|
@@ -11,7 +11,7 @@ exports.default = [
|
|
11
11
|
{
|
12
12
|
weight: 140,
|
13
13
|
type: 'checkbox',
|
14
|
-
label: '
|
14
|
+
label: 'Omit Value From Submission Data When Conditionally Hidden',
|
15
15
|
key: 'clearOnHide',
|
16
16
|
defaultValue: true,
|
17
17
|
tooltip: 'When a field is hidden, clear the value.',
|
@@ -69,7 +69,7 @@ exports.default = [
|
|
69
69
|
input: true,
|
70
70
|
weight: 20,
|
71
71
|
key: 'reference',
|
72
|
-
label: '
|
73
|
-
tooltip: '
|
72
|
+
label: 'Submit as reference',
|
73
|
+
tooltip: 'When "Submit as reference" is enabled, the form submission will be recorded against the Parent Form as well as the Child Form. When a submission recorded with "Submit as reference" is edited, the update is applied to each submission made against the Parent Form and Child Form.'
|
74
74
|
}
|
75
75
|
];
|
@@ -641,8 +641,8 @@ exports.default = [
|
|
641
641
|
input: true,
|
642
642
|
weight: 25,
|
643
643
|
key: 'reference',
|
644
|
-
label: '
|
645
|
-
tooltip: 'Using this option will
|
644
|
+
label: 'Submit as reference',
|
645
|
+
tooltip: 'Using this option will submit this field as a reference id and link its value to the value of the origin record.',
|
646
646
|
conditional: {
|
647
647
|
json: { '===': [{ var: 'data.dataSrc' }, 'resource'] },
|
648
648
|
},
|
@@ -115,7 +115,7 @@ function s3(formio) {
|
|
115
115
|
const { changeMessage } = multipart;
|
116
116
|
changeMessage('Completing AWS S3 multipart upload...');
|
117
117
|
const token = formio.getToken();
|
118
|
-
const response = yield fetch(`${formio.formUrl}/storage/s3/multipart/complete`, {
|
118
|
+
const response = yield xhr_1.default.fetch(`${formio.formUrl}/storage/s3/multipart/complete`, {
|
119
119
|
method: 'POST',
|
120
120
|
headers: Object.assign({ 'Content-Type': 'application/json' }, (token ? { 'x-jwt-token': token } : {})),
|
121
121
|
body: JSON.stringify({ parts, uploadId: serverResponse.uploadId, key: serverResponse.key })
|
@@ -134,7 +134,7 @@ function s3(formio) {
|
|
134
134
|
abortMultipartUpload(serverResponse) {
|
135
135
|
const { uploadId, key } = serverResponse;
|
136
136
|
const token = formio.getToken();
|
137
|
-
fetch(`${formio.formUrl}/storage/s3/multipart/abort`, {
|
137
|
+
xhr_1.default.fetch(`${formio.formUrl}/storage/s3/multipart/abort`, {
|
138
138
|
method: 'POST',
|
139
139
|
headers: Object.assign({ 'Content-Type': 'application/json' }, (token ? { 'x-jwt-token': token } : {})),
|
140
140
|
body: JSON.stringify({ uploadId, key })
|
@@ -148,7 +148,7 @@ function s3(formio) {
|
|
148
148
|
const start = i * partSize;
|
149
149
|
const end = (i + 1) * partSize;
|
150
150
|
const blob = i < urls.length ? file.slice(start, end) : file.slice(start);
|
151
|
-
const promise = fetch(urls[i], {
|
151
|
+
const promise = xhr_1.default.fetch(urls[i], {
|
152
152
|
method: 'PUT',
|
153
153
|
headers,
|
154
154
|
body: blob,
|
@@ -3,6 +3,7 @@ export default XHR;
|
|
3
3
|
declare namespace XHR {
|
4
4
|
function trim(text: any): any;
|
5
5
|
function path(items: any): any;
|
6
|
+
function fetch(url: any, options: any): Promise<Response>;
|
6
7
|
function upload(formio: any, type: any, xhrCallback: any, file: any, fileName: any, dir: any, progressCallback: any, groupPermissions: any, groupId: any, abortCallback: any, multipartOptions: any): Promise<any>;
|
7
8
|
function makeXhrRequest(formio: any, xhrCallback: any, serverResponse: any, progressCallback: any, abortCallback: any): Promise<any>;
|
8
9
|
}
|
@@ -14,6 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
15
15
|
exports.setXhrHeaders = void 0;
|
16
16
|
const trim_1 = __importDefault(require("lodash/trim"));
|
17
|
+
const Formio_1 = require("../../Formio");
|
17
18
|
const setXhrHeaders = (formio, xhr) => {
|
18
19
|
const { headers } = formio.options;
|
19
20
|
if (headers) {
|
@@ -36,13 +37,17 @@ const XHR = {
|
|
36
37
|
path(items) {
|
37
38
|
return items.filter(item => !!item).map(XHR.trim).join('/');
|
38
39
|
},
|
40
|
+
fetch(url, options) {
|
41
|
+
options = Formio_1.Formio.pluginAlter('requestOptions', options, url);
|
42
|
+
return fetch(url, options);
|
43
|
+
},
|
39
44
|
upload(formio, type, xhrCallback, file, fileName, dir, progressCallback, groupPermissions, groupId, abortCallback, multipartOptions) {
|
40
45
|
return __awaiter(this, void 0, void 0, function* () {
|
41
46
|
// make request to Form.io server
|
42
47
|
const token = formio.getToken();
|
43
48
|
let response;
|
44
49
|
try {
|
45
|
-
response = yield fetch(`${formio.formUrl}/storage/${type}`, {
|
50
|
+
response = yield XHR.fetch(`${formio.formUrl}/storage/${type}`, {
|
46
51
|
method: 'POST',
|
47
52
|
headers: Object.assign({ 'Accept': 'application/json', 'Content-Type': 'application/json; charset=UTF-8' }, (token ? { 'x-jwt-token': token } : {})),
|
48
53
|
body: JSON.stringify({
|
package/lib/cjs/utils/utils.d.ts
CHANGED
@@ -208,9 +208,10 @@ export function loadZones(url: string, timezone: string): Promise<any> | any;
|
|
208
208
|
* @param {string|Date} value - The value to convert into a moment date.
|
209
209
|
* @param {string} format - The format to convert the date to.
|
210
210
|
* @param {string} timezone - The timezone to convert the date to.
|
211
|
+
* @param {object} options - The options object
|
211
212
|
* @returns {Date} - The moment date object.
|
212
213
|
*/
|
213
|
-
export function momentDate(value: string | Date, format: string, timezone: string): Date;
|
214
|
+
export function momentDate(value: string | Date, format: string, timezone: string, options: object): Date;
|
214
215
|
/**
|
215
216
|
* Format a date provided a value, format, and timezone object.
|
216
217
|
* @param {string} timezonesUrl - The URL to load the timezone data from.
|
package/lib/cjs/utils/utils.js
CHANGED
@@ -687,9 +687,10 @@ exports.loadZones = loadZones;
|
|
687
687
|
* @param {string|Date} value - The value to convert into a moment date.
|
688
688
|
* @param {string} format - The format to convert the date to.
|
689
689
|
* @param {string} timezone - The timezone to convert the date to.
|
690
|
+
* @param {object} options - The options object
|
690
691
|
* @returns {Date} - The moment date object.
|
691
692
|
*/
|
692
|
-
function momentDate(value, format, timezone) {
|
693
|
+
function momentDate(value, format, timezone, options) {
|
693
694
|
const momentDate = (0, moment_timezone_1.default)(value);
|
694
695
|
if (!timezone) {
|
695
696
|
return momentDate;
|
@@ -697,7 +698,7 @@ function momentDate(value, format, timezone) {
|
|
697
698
|
if (timezone === 'UTC') {
|
698
699
|
timezone = 'Etc/UTC';
|
699
700
|
}
|
700
|
-
if ((timezone !== currentTimezone() || (format && format.match(/\s(z$|z\s)/))) && moment_timezone_1.default.zonesLoaded) {
|
701
|
+
if ((timezone !== currentTimezone() || (format && format.match(/\s(z$|z\s)/))) && (moment_timezone_1.default.zonesLoaded || (options === null || options === void 0 ? void 0 : options.email))) {
|
701
702
|
return momentDate.tz(timezone);
|
702
703
|
}
|
703
704
|
return momentDate;
|
package/lib/mjs/Webform.d.ts
CHANGED
@@ -190,7 +190,10 @@ declare class Webform extends NestedDataComponent {
|
|
190
190
|
get language(): string;
|
191
191
|
root: this;
|
192
192
|
localRoot: this;
|
193
|
+
beforeInit(): void;
|
194
|
+
executeFormController: any;
|
193
195
|
get emptyValue(): null;
|
196
|
+
get shouldCallFormController(): any;
|
194
197
|
get shadowRoot(): any;
|
195
198
|
/**
|
196
199
|
* Add a language for translations
|
@@ -360,7 +363,7 @@ declare class Webform extends NestedDataComponent {
|
|
360
363
|
* @returns {Promise} - The promise that is triggered when the form is built.
|
361
364
|
*/
|
362
365
|
init(): Promise<any>;
|
363
|
-
|
366
|
+
_executeFormController(): void;
|
364
367
|
build(element: any): Promise<any>;
|
365
368
|
getClassName(): string;
|
366
369
|
render(): string;
|
package/lib/mjs/Webform.js
CHANGED
@@ -287,12 +287,24 @@ export default class Webform extends NestedDataComponent {
|
|
287
287
|
this.localRoot = this;
|
288
288
|
}
|
289
289
|
/* eslint-enable max-statements */
|
290
|
+
beforeInit() {
|
291
|
+
this.executeFormController = _.once(this._executeFormController);
|
292
|
+
}
|
290
293
|
get language() {
|
291
294
|
return this.options.language;
|
292
295
|
}
|
293
296
|
get emptyValue() {
|
294
297
|
return null;
|
295
298
|
}
|
299
|
+
get shouldCallFormController() {
|
300
|
+
// If no controller value or
|
301
|
+
// hidden and set to clearOnHide (Don't calculate a value for a hidden field set to clear when hidden)
|
302
|
+
return (this.form &&
|
303
|
+
this.form.controller &&
|
304
|
+
!((!this.visible || this.component.hidden) &&
|
305
|
+
this.component.clearOnHide &&
|
306
|
+
!this.rootPristine));
|
307
|
+
}
|
296
308
|
componentContext() {
|
297
309
|
return this._data;
|
298
310
|
}
|
@@ -902,19 +914,12 @@ export default class Webform extends NestedDataComponent {
|
|
902
914
|
this.on('resetForm', () => this.resetValue(), true);
|
903
915
|
this.on('deleteSubmission', () => this.deleteSubmission(), true);
|
904
916
|
this.on('refreshData', () => this.updateValue(), true);
|
905
|
-
this.
|
917
|
+
if (this.shouldCallFormController) {
|
918
|
+
this.executeFormController();
|
919
|
+
}
|
906
920
|
return this.formReady;
|
907
921
|
}
|
908
|
-
|
909
|
-
// If no controller value or
|
910
|
-
// hidden and set to clearOnHide (Don't calculate a value for a hidden field set to clear when hidden)
|
911
|
-
if (!this.form ||
|
912
|
-
!this.form.controller ||
|
913
|
-
((!this.visible || this.component.hidden) &&
|
914
|
-
this.component.clearOnHide &&
|
915
|
-
!this.rootPristine)) {
|
916
|
-
return false;
|
917
|
-
}
|
922
|
+
_executeFormController() {
|
918
923
|
this.formReady.then(() => {
|
919
924
|
this.evaluate(this.form.controller, {
|
920
925
|
components: this.components,
|
@@ -1534,11 +1539,11 @@ export default class Webform extends NestedDataComponent {
|
|
1534
1539
|
return;
|
1535
1540
|
}
|
1536
1541
|
const captchaComponent = [];
|
1537
|
-
this.
|
1542
|
+
eachComponent(this.components, (component) => {
|
1538
1543
|
if (/^(re)?captcha$/.test(component.type) && component.component.eventType === 'formLoad') {
|
1539
1544
|
captchaComponent.push(component);
|
1540
1545
|
}
|
1541
|
-
});
|
1546
|
+
}, true);
|
1542
1547
|
if (captchaComponent.length > 0) {
|
1543
1548
|
if (this.parent) {
|
1544
1549
|
this.parent.subFormReady.then(() => {
|
@@ -418,6 +418,9 @@ export default class Component extends Element {
|
|
418
418
|
// Allow anyone to hook into the component creation.
|
419
419
|
this.hook('component');
|
420
420
|
if (!this.options.skipInit) {
|
421
|
+
if (typeof this.beforeInit === 'function') {
|
422
|
+
this.beforeInit();
|
423
|
+
}
|
421
424
|
this.init();
|
422
425
|
}
|
423
426
|
}
|
@@ -1914,15 +1917,21 @@ export default class Component extends Element {
|
|
1914
1917
|
}
|
1915
1918
|
// Check advanced conditions (and cache the result)
|
1916
1919
|
const isConditionallyHidden = this.checkConditionallyHidden(data, row) || this._parentConditionallyHidden;
|
1920
|
+
let shouldClear = false;
|
1917
1921
|
if (isConditionallyHidden !== this._conditionallyHidden) {
|
1918
1922
|
this._conditionallyHidden = isConditionallyHidden;
|
1919
|
-
|
1923
|
+
shouldClear = true;
|
1920
1924
|
}
|
1921
1925
|
// Check visibility
|
1922
1926
|
const visible = (this.hasCondition() ? !this.conditionallyHidden : !this.component.hidden);
|
1923
1927
|
if (this.visible !== visible) {
|
1924
1928
|
this.visible = visible;
|
1925
1929
|
}
|
1930
|
+
// Wait for visibility to update for nested components, so the component state is up-to-date when
|
1931
|
+
// calling clearOnHide
|
1932
|
+
if (shouldClear) {
|
1933
|
+
this.clearOnHide();
|
1934
|
+
}
|
1926
1935
|
return visible;
|
1927
1936
|
}
|
1928
1937
|
/**
|
@@ -20,6 +20,6 @@ export default class DateTimeComponent extends Input {
|
|
20
20
|
get momentFormat(): string;
|
21
21
|
createWrapper(): boolean;
|
22
22
|
checkValidity(data: any, dirty: any, rowData: any): boolean;
|
23
|
-
getValueAsString(value: any): any;
|
23
|
+
getValueAsString(value: any, options: any): any;
|
24
24
|
}
|
25
25
|
import Input from '../_classes/input/Input';
|
@@ -128,8 +128,8 @@ export default class DateTimeComponent extends Input {
|
|
128
128
|
...customOptions,
|
129
129
|
};
|
130
130
|
// update originalComponent to include widget and other updated settings
|
131
|
-
// it is done here since these settings depend on properties present after the component is initialized
|
132
|
-
// originalComponent is used to restore the component (and widget) after evaluating field logic
|
131
|
+
// it is done here since these settings depend on properties present after the component is initialized
|
132
|
+
// originalComponent is used to restore the component (and widget) after evaluating field logic
|
133
133
|
this.originalComponent = fastCloneDeep(this.component);
|
134
134
|
/* eslint-enable camelcase */
|
135
135
|
}
|
@@ -177,15 +177,15 @@ export default class DateTimeComponent extends Input {
|
|
177
177
|
}
|
178
178
|
return super.checkValidity(data, dirty, rowData);
|
179
179
|
}
|
180
|
-
getValueAsString(value) {
|
180
|
+
getValueAsString(value, options) {
|
181
181
|
let format = FormioUtils.convertFormatToMoment(this.component.format);
|
182
182
|
format += format.match(/z$/) ? '' : ' z';
|
183
183
|
const timezone = this.timezone;
|
184
184
|
if (value && !this.attached && timezone) {
|
185
185
|
if (Array.isArray(value) && this.component.multiple) {
|
186
|
-
return value.map(item => _.trim(FormioUtils.momentDate(item, format, timezone).format(format))).join(', ');
|
186
|
+
return value.map(item => _.trim(FormioUtils.momentDate(item, format, timezone, options).format(format))).join(', ');
|
187
187
|
}
|
188
|
-
return _.trim(FormioUtils.momentDate(value, format, timezone).format(format));
|
188
|
+
return _.trim(FormioUtils.momentDate(value, format, timezone, options).format(format));
|
189
189
|
}
|
190
190
|
if (Array.isArray(value) && this.component.multiple) {
|
191
191
|
return value.map(item => _.trim(moment(item).format(format))).join(', ');
|
@@ -66,7 +66,7 @@ export default [
|
|
66
66
|
input: true,
|
67
67
|
weight: 20,
|
68
68
|
key: 'reference',
|
69
|
-
label: '
|
70
|
-
tooltip: '
|
69
|
+
label: 'Submit as reference',
|
70
|
+
tooltip: 'When "Submit as reference" is enabled, the form submission will be recorded against the Parent Form as well as the Child Form. When a submission recorded with "Submit as reference" is edited, the update is applied to each submission made against the Parent Form and Child Form.'
|
71
71
|
}
|
72
72
|
];
|
@@ -635,8 +635,8 @@ export default [
|
|
635
635
|
input: true,
|
636
636
|
weight: 25,
|
637
637
|
key: 'reference',
|
638
|
-
label: '
|
639
|
-
tooltip: 'Using this option will
|
638
|
+
label: 'Submit as reference',
|
639
|
+
tooltip: 'Using this option will submit this field as a reference id and link its value to the value of the origin record.',
|
640
640
|
conditional: {
|
641
641
|
json: { '===': [{ var: 'data.dataSrc' }, 'resource'] },
|
642
642
|
},
|
@@ -75,7 +75,7 @@ function s3(formio) {
|
|
75
75
|
const { changeMessage } = multipart;
|
76
76
|
changeMessage('Completing AWS S3 multipart upload...');
|
77
77
|
const token = formio.getToken();
|
78
|
-
const response = await fetch(`${formio.formUrl}/storage/s3/multipart/complete`, {
|
78
|
+
const response = await XHR.fetch(`${formio.formUrl}/storage/s3/multipart/complete`, {
|
79
79
|
method: 'POST',
|
80
80
|
headers: {
|
81
81
|
'Content-Type': 'application/json',
|
@@ -96,7 +96,7 @@ function s3(formio) {
|
|
96
96
|
abortMultipartUpload(serverResponse) {
|
97
97
|
const { uploadId, key } = serverResponse;
|
98
98
|
const token = formio.getToken();
|
99
|
-
fetch(`${formio.formUrl}/storage/s3/multipart/abort`, {
|
99
|
+
XHR.fetch(`${formio.formUrl}/storage/s3/multipart/abort`, {
|
100
100
|
method: 'POST',
|
101
101
|
headers: {
|
102
102
|
'Content-Type': 'application/json',
|
@@ -113,7 +113,7 @@ function s3(formio) {
|
|
113
113
|
const start = i * partSize;
|
114
114
|
const end = (i + 1) * partSize;
|
115
115
|
const blob = i < urls.length ? file.slice(start, end) : file.slice(start);
|
116
|
-
const promise = fetch(urls[i], {
|
116
|
+
const promise = XHR.fetch(urls[i], {
|
117
117
|
method: 'PUT',
|
118
118
|
headers,
|
119
119
|
body: blob,
|
@@ -3,6 +3,7 @@ export default XHR;
|
|
3
3
|
declare namespace XHR {
|
4
4
|
function trim(text: any): any;
|
5
5
|
function path(items: any): any;
|
6
|
+
function fetch(url: any, options: any): Promise<Response>;
|
6
7
|
function upload(formio: any, type: any, xhrCallback: any, file: any, fileName: any, dir: any, progressCallback: any, groupPermissions: any, groupId: any, abortCallback: any, multipartOptions: any): Promise<any>;
|
7
8
|
function makeXhrRequest(formio: any, xhrCallback: any, serverResponse: any, progressCallback: any, abortCallback: any): Promise<any>;
|
8
9
|
}
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import _trim from 'lodash/trim';
|
2
|
+
import { Formio } from '../../Formio';
|
2
3
|
export const setXhrHeaders = (formio, xhr) => {
|
3
4
|
const { headers } = formio.options;
|
4
5
|
if (headers) {
|
@@ -20,12 +21,16 @@ const XHR = {
|
|
20
21
|
path(items) {
|
21
22
|
return items.filter(item => !!item).map(XHR.trim).join('/');
|
22
23
|
},
|
24
|
+
fetch(url, options) {
|
25
|
+
options = Formio.pluginAlter('requestOptions', options, url);
|
26
|
+
return fetch(url, options);
|
27
|
+
},
|
23
28
|
async upload(formio, type, xhrCallback, file, fileName, dir, progressCallback, groupPermissions, groupId, abortCallback, multipartOptions) {
|
24
29
|
// make request to Form.io server
|
25
30
|
const token = formio.getToken();
|
26
31
|
let response;
|
27
32
|
try {
|
28
|
-
response = await fetch(`${formio.formUrl}/storage/${type}`, {
|
33
|
+
response = await XHR.fetch(`${formio.formUrl}/storage/${type}`, {
|
29
34
|
method: 'POST',
|
30
35
|
headers: {
|
31
36
|
'Accept': 'application/json',
|
package/lib/mjs/utils/utils.d.ts
CHANGED
@@ -208,9 +208,10 @@ export function loadZones(url: string, timezone: string): Promise<any> | any;
|
|
208
208
|
* @param {string|Date} value - The value to convert into a moment date.
|
209
209
|
* @param {string} format - The format to convert the date to.
|
210
210
|
* @param {string} timezone - The timezone to convert the date to.
|
211
|
+
* @param {object} options - The options object
|
211
212
|
* @returns {Date} - The moment date object.
|
212
213
|
*/
|
213
|
-
export function momentDate(value: string | Date, format: string, timezone: string): Date;
|
214
|
+
export function momentDate(value: string | Date, format: string, timezone: string, options: object): Date;
|
214
215
|
/**
|
215
216
|
* Format a date provided a value, format, and timezone object.
|
216
217
|
* @param {string} timezonesUrl - The URL to load the timezone data from.
|
package/lib/mjs/utils/utils.js
CHANGED
@@ -632,9 +632,10 @@ export function loadZones(url, timezone) {
|
|
632
632
|
* @param {string|Date} value - The value to convert into a moment date.
|
633
633
|
* @param {string} format - The format to convert the date to.
|
634
634
|
* @param {string} timezone - The timezone to convert the date to.
|
635
|
+
* @param {object} options - The options object
|
635
636
|
* @returns {Date} - The moment date object.
|
636
637
|
*/
|
637
|
-
export function momentDate(value, format, timezone) {
|
638
|
+
export function momentDate(value, format, timezone, options) {
|
638
639
|
const momentDate = moment(value);
|
639
640
|
if (!timezone) {
|
640
641
|
return momentDate;
|
@@ -642,7 +643,7 @@ export function momentDate(value, format, timezone) {
|
|
642
643
|
if (timezone === 'UTC') {
|
643
644
|
timezone = 'Etc/UTC';
|
644
645
|
}
|
645
|
-
if ((timezone !== currentTimezone() || (format && format.match(/\s(z$|z\s)/))) && moment.zonesLoaded) {
|
646
|
+
if ((timezone !== currentTimezone() || (format && format.match(/\s(z$|z\s)/))) && (moment.zonesLoaded || options?.email)) {
|
646
647
|
return momentDate.tz(timezone);
|
647
648
|
}
|
648
649
|
return momentDate;
|