@formio/js 5.0.0-rc.94 → 5.0.0-rc.96
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.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.js +25 -14
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.form.min.js.LICENSE.txt +1 -1
- package/dist/formio.full.js +25 -14
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.full.min.js.LICENSE.txt +1 -1
- package/dist/formio.js +195 -3
- package/dist/formio.min.js +1 -1
- package/dist/formio.min.js.LICENSE.txt +3 -1
- package/dist/formio.utils.js +16 -5
- package/dist/formio.utils.min.js +1 -1
- package/dist/formio.utils.min.js.LICENSE.txt +1 -1
- package/lib/cjs/Wizard.js +1 -1
- package/lib/cjs/components/_classes/nested/NestedComponent.js +3 -0
- package/lib/cjs/components/editgrid/EditGrid.js +6 -8
- package/lib/cjs/components/editgrid/fixtures/comp20.d.ts +43 -0
- package/lib/cjs/components/editgrid/fixtures/comp20.js +44 -0
- package/lib/cjs/components/editgrid/fixtures/index.d.ts +2 -1
- package/lib/cjs/components/editgrid/fixtures/index.js +3 -1
- package/lib/cjs/components/form/Form.js +1 -1
- package/lib/cjs/components/number/Number.js +7 -1
- package/lib/cjs/components/number/fixtures/index.js +1 -1
- package/lib/cjs/components/number/fixtures/scientificNotation.d.ts +14 -0
- package/lib/cjs/components/number/fixtures/scientificNotation.js +15 -0
- package/lib/cjs/components/select/Select.d.ts +1 -1
- package/lib/cjs/components/select/Select.js +13 -6
- package/lib/mjs/Wizard.js +1 -1
- package/lib/mjs/components/_classes/nested/NestedComponent.js +3 -0
- package/lib/mjs/components/editgrid/EditGrid.js +6 -8
- package/lib/mjs/components/editgrid/fixtures/comp20.d.ts +43 -0
- package/lib/mjs/components/editgrid/fixtures/comp20.js +42 -0
- package/lib/mjs/components/editgrid/fixtures/index.d.ts +2 -1
- package/lib/mjs/components/editgrid/fixtures/index.js +2 -1
- package/lib/mjs/components/form/Form.js +1 -1
- package/lib/mjs/components/number/Number.js +7 -1
- package/lib/mjs/components/number/fixtures/index.js +1 -1
- package/lib/mjs/components/number/fixtures/scientificNotation.d.ts +14 -0
- package/lib/mjs/components/number/fixtures/scientificNotation.js +13 -0
- package/lib/mjs/components/select/Select.d.ts +1 -1
- package/lib/mjs/components/select/Select.js +12 -5
- package/package.json +3 -3
@@ -20,7 +20,7 @@
|
|
20
20
|
|
21
21
|
/*! @license DOMPurify 3.1.6 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.1.6/LICENSE */
|
22
22
|
|
23
|
-
/*! formiojs v5.0.0-rc.
|
23
|
+
/*! formiojs v5.0.0-rc.96 | https://unpkg.com/formiojs@5.0.0-rc.96/LICENSE.txt */
|
24
24
|
|
25
25
|
/**
|
26
26
|
* @license
|
package/lib/cjs/Wizard.js
CHANGED
@@ -716,7 +716,7 @@ class Wizard extends Webform_1.default {
|
|
716
716
|
else {
|
717
717
|
this.currentPage.components.forEach((comp) => comp.setPristine(false));
|
718
718
|
this.scrollIntoView(this.element, true);
|
719
|
-
return Promise.reject(
|
719
|
+
return Promise.reject(super.showErrors(errors, true));
|
720
720
|
}
|
721
721
|
}
|
722
722
|
validateCurrentPage(flags = {}) {
|
@@ -693,6 +693,9 @@ class NestedComponent extends Field_1.default {
|
|
693
693
|
if (!instance) {
|
694
694
|
return;
|
695
695
|
}
|
696
|
+
if (!instance.component.path) {
|
697
|
+
instance.component.path = component.path;
|
698
|
+
}
|
696
699
|
instance.checkComponentValidity(data, dirty, row, flags, scope.errors);
|
697
700
|
if (instance.processOwnValidation) {
|
698
701
|
scope.noRecurse = true;
|
@@ -13,7 +13,6 @@ const utils_1 = require("../../utils/utils");
|
|
13
13
|
const EditRowState = {
|
14
14
|
New: 'new',
|
15
15
|
Editing: 'editing',
|
16
|
-
Saving: 'saving',
|
17
16
|
Saved: 'saved',
|
18
17
|
Viewing: 'viewing',
|
19
18
|
Removed: 'removed',
|
@@ -799,10 +798,6 @@ class EditGridComponent extends NestedArrayComponent_1.default {
|
|
799
798
|
if (!this.component.rowDrafts) {
|
800
799
|
editRow.components.forEach((comp) => comp.setPristine(false));
|
801
800
|
}
|
802
|
-
// Mark the row with a 'Saving' state to trigger validation for future row changes
|
803
|
-
if (editRow.state === EditRowState.New) {
|
804
|
-
editRow.state = EditRowState.Saving;
|
805
|
-
}
|
806
801
|
const errors = this.validateRow(editRow, true);
|
807
802
|
if (!this.component.rowDrafts) {
|
808
803
|
if (errors.length) {
|
@@ -815,7 +810,7 @@ class EditGridComponent extends NestedArrayComponent_1.default {
|
|
815
810
|
this.root.focusedComponent = null;
|
816
811
|
}
|
817
812
|
switch (editRow.state) {
|
818
|
-
case EditRowState.
|
813
|
+
case EditRowState.New: {
|
819
814
|
const newIndex = dataValue.length;
|
820
815
|
dataValue.push(editRow.data);
|
821
816
|
editRow.components.forEach(component => component.rowIndex = newIndex);
|
@@ -975,7 +970,7 @@ class EditGridComponent extends NestedArrayComponent_1.default {
|
|
975
970
|
}
|
976
971
|
shouldValidateRow(editRow, dirty, fromSubmission) {
|
977
972
|
return this.shouldValidateDraft(editRow) ||
|
978
|
-
editRow.state === EditRowState.
|
973
|
+
editRow.state === EditRowState.New ||
|
979
974
|
editRow.state === EditRowState.Editing ||
|
980
975
|
editRow.alerts ||
|
981
976
|
fromSubmission ||
|
@@ -991,7 +986,7 @@ class EditGridComponent extends NestedArrayComponent_1.default {
|
|
991
986
|
editGridValue[editRow.rowIndex] = editRow.data;
|
992
987
|
lodash_1.default.set(rootValue, this.path, editGridValue);
|
993
988
|
const validationProcessorProcess = (context) => this.validationProcessor(context, { dirty, silentCheck });
|
994
|
-
|
989
|
+
const errors = (0, process_1.processSync)({
|
995
990
|
components: (0, utils_1.fastCloneDeep)(this.component.components).map((component) => {
|
996
991
|
component.parentPath = `${this.path}[${editRow.rowIndex}]`;
|
997
992
|
return component;
|
@@ -1008,6 +1003,9 @@ class EditGridComponent extends NestedArrayComponent_1.default {
|
|
1008
1003
|
}
|
1009
1004
|
]
|
1010
1005
|
}).errors;
|
1006
|
+
editRow.errors = (this.component.modal || this.component.rowDrafts)
|
1007
|
+
? errors
|
1008
|
+
: errors.filter((err) => lodash_1.default.find(this.visibleErrors, ['component.id', err.component.id]));
|
1011
1009
|
}
|
1012
1010
|
// TODO: this is essentially running its own custom validation and should be moved into a validation rule
|
1013
1011
|
if (this.component.validate && this.component.validate.row) {
|
@@ -0,0 +1,43 @@
|
|
1
|
+
declare namespace _default {
|
2
|
+
let title: string;
|
3
|
+
let name: string;
|
4
|
+
let path: string;
|
5
|
+
let type: string;
|
6
|
+
let display: string;
|
7
|
+
let components: ({
|
8
|
+
label: string;
|
9
|
+
alwaysEnabled: boolean;
|
10
|
+
tableView: boolean;
|
11
|
+
key: string;
|
12
|
+
type: string;
|
13
|
+
input: boolean;
|
14
|
+
validateWhenHidden?: undefined;
|
15
|
+
rowDrafts?: undefined;
|
16
|
+
displayAsTable?: undefined;
|
17
|
+
components?: undefined;
|
18
|
+
} | {
|
19
|
+
label: string;
|
20
|
+
tableView: boolean;
|
21
|
+
validateWhenHidden: boolean;
|
22
|
+
rowDrafts: boolean;
|
23
|
+
key: string;
|
24
|
+
type: string;
|
25
|
+
displayAsTable: boolean;
|
26
|
+
input: boolean;
|
27
|
+
components: {
|
28
|
+
label: string;
|
29
|
+
applyMaskOn: string;
|
30
|
+
tableView: boolean;
|
31
|
+
validate: {
|
32
|
+
custom: string;
|
33
|
+
};
|
34
|
+
validateWhenHidden: boolean;
|
35
|
+
key: string;
|
36
|
+
type: string;
|
37
|
+
alwaysEnabled: boolean;
|
38
|
+
input: boolean;
|
39
|
+
}[];
|
40
|
+
alwaysEnabled?: undefined;
|
41
|
+
})[];
|
42
|
+
}
|
43
|
+
export default _default;
|
@@ -0,0 +1,44 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.default = {
|
4
|
+
title: "edit grid validation",
|
5
|
+
name: "EG_validation",
|
6
|
+
path: "EG_validation",
|
7
|
+
type: "form",
|
8
|
+
display: "form",
|
9
|
+
components: [
|
10
|
+
{
|
11
|
+
label: 'Root Text',
|
12
|
+
alwaysEnabled: false,
|
13
|
+
tableView: true,
|
14
|
+
key: 'text',
|
15
|
+
type: 'textfield',
|
16
|
+
input: true
|
17
|
+
},
|
18
|
+
{
|
19
|
+
label: "Edit Grid",
|
20
|
+
tableView: false,
|
21
|
+
validateWhenHidden: false,
|
22
|
+
rowDrafts: false,
|
23
|
+
key: "editGrid",
|
24
|
+
type: "editgrid",
|
25
|
+
displayAsTable: false,
|
26
|
+
input: true,
|
27
|
+
components: [
|
28
|
+
{
|
29
|
+
label: 'Textfield - EG',
|
30
|
+
applyMaskOn: 'change',
|
31
|
+
tableView: true,
|
32
|
+
validate: {
|
33
|
+
custom: "valid = (input === data.text) ? true : 'data must match root textfield';"
|
34
|
+
},
|
35
|
+
validateWhenHidden: false,
|
36
|
+
key: 'rootTest',
|
37
|
+
type: 'textfield',
|
38
|
+
alwaysEnabled: false,
|
39
|
+
input: true
|
40
|
+
},
|
41
|
+
],
|
42
|
+
},
|
43
|
+
],
|
44
|
+
};
|
@@ -16,7 +16,8 @@ import comp15 from './comp15';
|
|
16
16
|
import comp16 from './comp16';
|
17
17
|
import comp18 from './comp18';
|
18
18
|
import comp19 from './comp19';
|
19
|
+
import comp20 from './comp20';
|
19
20
|
import compOpenWhenEmpty from './comp-openWhenEmpty';
|
20
21
|
import withOpenWhenEmptyAndConditions from './comp-with-conditions-and-openWhenEmpty';
|
21
22
|
import compWithCustomDefaultValue from './comp-with-custom-default-value';
|
22
|
-
export { comp1, comp2, comp3, comp4, comp5, comp6, comp7, comp8, comp9, comp10, comp11, comp12, comp13, comp14, comp15, comp16, comp17, comp18, comp19, compOpenWhenEmpty, withOpenWhenEmptyAndConditions, compWithCustomDefaultValue, compTestEvents };
|
23
|
+
export { comp1, comp2, comp3, comp4, comp5, comp6, comp7, comp8, comp9, comp10, comp11, comp12, comp13, comp14, comp15, comp16, comp17, comp18, comp19, comp20, compOpenWhenEmpty, withOpenWhenEmptyAndConditions, compWithCustomDefaultValue, compTestEvents };
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.compTestEvents = exports.compWithCustomDefaultValue = exports.withOpenWhenEmptyAndConditions = exports.compOpenWhenEmpty = exports.comp19 = exports.comp18 = exports.comp17 = exports.comp16 = exports.comp15 = exports.comp14 = exports.comp13 = exports.comp12 = exports.comp11 = exports.comp10 = exports.comp9 = exports.comp8 = exports.comp7 = exports.comp6 = exports.comp5 = exports.comp4 = exports.comp3 = exports.comp2 = exports.comp1 = void 0;
|
6
|
+
exports.compTestEvents = exports.compWithCustomDefaultValue = exports.withOpenWhenEmptyAndConditions = exports.compOpenWhenEmpty = exports.comp20 = exports.comp19 = exports.comp18 = exports.comp17 = exports.comp16 = exports.comp15 = exports.comp14 = exports.comp13 = exports.comp12 = exports.comp11 = exports.comp10 = exports.comp9 = exports.comp8 = exports.comp7 = exports.comp6 = exports.comp5 = exports.comp4 = exports.comp3 = exports.comp2 = exports.comp1 = void 0;
|
7
7
|
const comp1_1 = __importDefault(require("./comp1"));
|
8
8
|
exports.comp1 = comp1_1.default;
|
9
9
|
const comp2_1 = __importDefault(require("./comp2"));
|
@@ -42,6 +42,8 @@ const comp18_1 = __importDefault(require("./comp18"));
|
|
42
42
|
exports.comp18 = comp18_1.default;
|
43
43
|
const comp19_1 = __importDefault(require("./comp19"));
|
44
44
|
exports.comp19 = comp19_1.default;
|
45
|
+
const comp20_1 = __importDefault(require("./comp20"));
|
46
|
+
exports.comp20 = comp20_1.default;
|
45
47
|
const comp_with_conditions_and_openWhenEmpty_1 = __importDefault(require("./comp-with-conditions-and-openWhenEmpty"));
|
46
48
|
exports.withOpenWhenEmptyAndConditions = comp_with_conditions_and_openWhenEmpty_1.default;
|
47
49
|
const comp_openWhenEmpty_1 = __importDefault(require("./comp-openWhenEmpty"));
|
@@ -476,7 +476,7 @@ class FormComponent extends Component_1.default {
|
|
476
476
|
checkComponentValidity(data, dirty, row, options, errors = []) {
|
477
477
|
options = options || {};
|
478
478
|
const silentCheck = options.silentCheck || false;
|
479
|
-
if (this.subForm) {
|
479
|
+
if (this.subForm && !this.isNestedWizard) {
|
480
480
|
return this.subForm.checkValidity(this.subFormData, dirty, null, silentCheck, errors);
|
481
481
|
}
|
482
482
|
return super.checkComponentValidity(data, dirty, row, options, errors);
|
@@ -172,7 +172,13 @@ class NumberComponent extends Input_1.default {
|
|
172
172
|
}
|
173
173
|
let value = parseFloat(input);
|
174
174
|
if (!lodash_1.default.isNaN(value)) {
|
175
|
-
|
175
|
+
// Format scientific notation
|
176
|
+
if (/e/i.test(String(value))) {
|
177
|
+
value = value.toExponential(this.decimalLimit);
|
178
|
+
}
|
179
|
+
else {
|
180
|
+
value = String(value).replace('.', this.decimalSeparator);
|
181
|
+
}
|
176
182
|
}
|
177
183
|
else {
|
178
184
|
value = null;
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.comp11 = exports.comp10 = exports.comp9 = exports.comp8 = exports.comp7 = exports.comp6 = exports.comp5 = exports.comp4 = exports.comp3 = exports.comp2 = exports.comp1 = void 0;
|
6
|
+
exports.scientificNotation = exports.comp11 = exports.comp10 = exports.comp9 = exports.comp8 = exports.comp7 = exports.comp6 = exports.comp5 = exports.comp4 = exports.comp3 = exports.comp2 = exports.comp1 = void 0;
|
7
7
|
const comp1_1 = __importDefault(require("./comp1"));
|
8
8
|
exports.comp1 = comp1_1.default;
|
9
9
|
const comp2_1 = __importDefault(require("./comp2"));
|
@@ -0,0 +1,14 @@
|
|
1
|
+
declare namespace _default {
|
2
|
+
let label: string;
|
3
|
+
let mask: boolean;
|
4
|
+
let spellcheck: boolean;
|
5
|
+
let tableView: boolean;
|
6
|
+
let delimiter: boolean;
|
7
|
+
let requireDecimal: boolean;
|
8
|
+
let inputFormat: string;
|
9
|
+
let key: string;
|
10
|
+
let type: string;
|
11
|
+
let decimalLimit: number;
|
12
|
+
let input: boolean;
|
13
|
+
}
|
14
|
+
export default _default;
|
@@ -0,0 +1,15 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.default = {
|
4
|
+
'label': 'Number',
|
5
|
+
'mask': false,
|
6
|
+
'spellcheck': true,
|
7
|
+
'tableView': true,
|
8
|
+
'delimiter': true,
|
9
|
+
'requireDecimal': true,
|
10
|
+
'inputFormat': 'plain',
|
11
|
+
'key': 'number',
|
12
|
+
'type': 'number',
|
13
|
+
'decimalLimit': 2,
|
14
|
+
'input': true
|
15
|
+
};
|
@@ -131,7 +131,7 @@ export default class SelectComponent extends ListComponent {
|
|
131
131
|
addCurrentChoices(values: any, items: any, keyValue: any): any;
|
132
132
|
getValueAsString(data: any, options: any): any;
|
133
133
|
normalizeSingleValue(value: any): any;
|
134
|
-
setMetadata(value: any): any;
|
134
|
+
setMetadata(value: any, flags?: {}): any;
|
135
135
|
updateValue(value: any, flags: any): boolean;
|
136
136
|
undoValueTyping(value: any): any;
|
137
137
|
setValue(value: any, flags?: {}): boolean;
|
@@ -1205,8 +1205,8 @@ class SelectComponent extends ListComponent_1.default {
|
|
1205
1205
|
}
|
1206
1206
|
return super.normalizeValue(this.normalizeSingleValue(value));
|
1207
1207
|
}
|
1208
|
-
setMetadata(value) {
|
1209
|
-
var _a;
|
1208
|
+
setMetadata(value, flags = {}) {
|
1209
|
+
var _a, _b;
|
1210
1210
|
if (lodash_1.default.isNil(value)) {
|
1211
1211
|
return;
|
1212
1212
|
}
|
@@ -1217,7 +1217,7 @@ class SelectComponent extends ListComponent_1.default {
|
|
1217
1217
|
}
|
1218
1218
|
// Check to see if we need to save off the template data into our metadata.
|
1219
1219
|
const templateValue = this.component.reference && (value === null || value === void 0 ? void 0 : value._id) ? value._id.toString() : value;
|
1220
|
-
const shouldSaveData = !valueIsObject || this.component.reference;
|
1220
|
+
const shouldSaveData = (!valueIsObject || this.component.reference) && !this.inDataTable;
|
1221
1221
|
if (!lodash_1.default.isNil(templateValue) && shouldSaveData && this.templateData && this.templateData[templateValue] && ((_a = this.root) === null || _a === void 0 ? void 0 : _a.submission)) {
|
1222
1222
|
const submission = this.root.submission;
|
1223
1223
|
if (!submission.metadata) {
|
@@ -1240,15 +1240,22 @@ class SelectComponent extends ListComponent_1.default {
|
|
1240
1240
|
}
|
1241
1241
|
lodash_1.default.set(submission.metadata.selectData, this.path, templateData);
|
1242
1242
|
}
|
1243
|
+
if (flags.resetValue && ((_b = this.root) === null || _b === void 0 ? void 0 : _b.submission)) {
|
1244
|
+
const submission = this.root.submission;
|
1245
|
+
if (!submission.metadata) {
|
1246
|
+
submission.metadata = {};
|
1247
|
+
}
|
1248
|
+
submission.metadata.selectData = {};
|
1249
|
+
}
|
1243
1250
|
}
|
1244
1251
|
updateValue(value, flags) {
|
1245
1252
|
const changed = super.updateValue(value, flags);
|
1246
|
-
if (changed || !this.selectMetadata) {
|
1253
|
+
if (changed || !this.selectMetadata || flags.resetValue) {
|
1247
1254
|
if (this.component.multiple && Array.isArray(this.dataValue)) {
|
1248
|
-
this.dataValue.forEach(singleValue => this.setMetadata(singleValue));
|
1255
|
+
this.dataValue.forEach(singleValue => this.setMetadata(singleValue, flags));
|
1249
1256
|
}
|
1250
1257
|
else {
|
1251
|
-
this.setMetadata(this.dataValue);
|
1258
|
+
this.setMetadata(this.dataValue, flags);
|
1252
1259
|
}
|
1253
1260
|
}
|
1254
1261
|
return changed;
|
package/lib/mjs/Wizard.js
CHANGED
@@ -706,7 +706,7 @@ export default class Wizard extends Webform {
|
|
706
706
|
else {
|
707
707
|
this.currentPage.components.forEach((comp) => comp.setPristine(false));
|
708
708
|
this.scrollIntoView(this.element, true);
|
709
|
-
return Promise.reject(
|
709
|
+
return Promise.reject(super.showErrors(errors, true));
|
710
710
|
}
|
711
711
|
}
|
712
712
|
validateCurrentPage(flags = {}) {
|
@@ -688,6 +688,9 @@ export default class NestedComponent extends Field {
|
|
688
688
|
if (!instance) {
|
689
689
|
return;
|
690
690
|
}
|
691
|
+
if (!instance.component.path) {
|
692
|
+
instance.component.path = component.path;
|
693
|
+
}
|
691
694
|
instance.checkComponentValidity(data, dirty, row, flags, scope.errors);
|
692
695
|
if (instance.processOwnValidation) {
|
693
696
|
scope.noRecurse = true;
|
@@ -8,7 +8,6 @@ import { fastCloneDeep, Evaluator, getArrayFromComponentPath, eachComponent } fr
|
|
8
8
|
const EditRowState = {
|
9
9
|
New: 'new',
|
10
10
|
Editing: 'editing',
|
11
|
-
Saving: 'saving',
|
12
11
|
Saved: 'saved',
|
13
12
|
Viewing: 'viewing',
|
14
13
|
Removed: 'removed',
|
@@ -789,10 +788,6 @@ export default class EditGridComponent extends NestedArrayComponent {
|
|
789
788
|
if (!this.component.rowDrafts) {
|
790
789
|
editRow.components.forEach((comp) => comp.setPristine(false));
|
791
790
|
}
|
792
|
-
// Mark the row with a 'Saving' state to trigger validation for future row changes
|
793
|
-
if (editRow.state === EditRowState.New) {
|
794
|
-
editRow.state = EditRowState.Saving;
|
795
|
-
}
|
796
791
|
const errors = this.validateRow(editRow, true);
|
797
792
|
if (!this.component.rowDrafts) {
|
798
793
|
if (errors.length) {
|
@@ -805,7 +800,7 @@ export default class EditGridComponent extends NestedArrayComponent {
|
|
805
800
|
this.root.focusedComponent = null;
|
806
801
|
}
|
807
802
|
switch (editRow.state) {
|
808
|
-
case EditRowState.
|
803
|
+
case EditRowState.New: {
|
809
804
|
const newIndex = dataValue.length;
|
810
805
|
dataValue.push(editRow.data);
|
811
806
|
editRow.components.forEach(component => component.rowIndex = newIndex);
|
@@ -965,7 +960,7 @@ export default class EditGridComponent extends NestedArrayComponent {
|
|
965
960
|
}
|
966
961
|
shouldValidateRow(editRow, dirty, fromSubmission) {
|
967
962
|
return this.shouldValidateDraft(editRow) ||
|
968
|
-
editRow.state === EditRowState.
|
963
|
+
editRow.state === EditRowState.New ||
|
969
964
|
editRow.state === EditRowState.Editing ||
|
970
965
|
editRow.alerts ||
|
971
966
|
fromSubmission ||
|
@@ -980,7 +975,7 @@ export default class EditGridComponent extends NestedArrayComponent {
|
|
980
975
|
editGridValue[editRow.rowIndex] = editRow.data;
|
981
976
|
_.set(rootValue, this.path, editGridValue);
|
982
977
|
const validationProcessorProcess = (context) => this.validationProcessor(context, { dirty, silentCheck });
|
983
|
-
|
978
|
+
const errors = processSync({
|
984
979
|
components: fastCloneDeep(this.component.components).map((component) => {
|
985
980
|
component.parentPath = `${this.path}[${editRow.rowIndex}]`;
|
986
981
|
return component;
|
@@ -997,6 +992,9 @@ export default class EditGridComponent extends NestedArrayComponent {
|
|
997
992
|
}
|
998
993
|
]
|
999
994
|
}).errors;
|
995
|
+
editRow.errors = (this.component.modal || this.component.rowDrafts)
|
996
|
+
? errors
|
997
|
+
: errors.filter((err) => _.find(this.visibleErrors, ['component.id', err.component.id]));
|
1000
998
|
}
|
1001
999
|
// TODO: this is essentially running its own custom validation and should be moved into a validation rule
|
1002
1000
|
if (this.component.validate && this.component.validate.row) {
|
@@ -0,0 +1,43 @@
|
|
1
|
+
declare namespace _default {
|
2
|
+
let title: string;
|
3
|
+
let name: string;
|
4
|
+
let path: string;
|
5
|
+
let type: string;
|
6
|
+
let display: string;
|
7
|
+
let components: ({
|
8
|
+
label: string;
|
9
|
+
alwaysEnabled: boolean;
|
10
|
+
tableView: boolean;
|
11
|
+
key: string;
|
12
|
+
type: string;
|
13
|
+
input: boolean;
|
14
|
+
validateWhenHidden?: undefined;
|
15
|
+
rowDrafts?: undefined;
|
16
|
+
displayAsTable?: undefined;
|
17
|
+
components?: undefined;
|
18
|
+
} | {
|
19
|
+
label: string;
|
20
|
+
tableView: boolean;
|
21
|
+
validateWhenHidden: boolean;
|
22
|
+
rowDrafts: boolean;
|
23
|
+
key: string;
|
24
|
+
type: string;
|
25
|
+
displayAsTable: boolean;
|
26
|
+
input: boolean;
|
27
|
+
components: {
|
28
|
+
label: string;
|
29
|
+
applyMaskOn: string;
|
30
|
+
tableView: boolean;
|
31
|
+
validate: {
|
32
|
+
custom: string;
|
33
|
+
};
|
34
|
+
validateWhenHidden: boolean;
|
35
|
+
key: string;
|
36
|
+
type: string;
|
37
|
+
alwaysEnabled: boolean;
|
38
|
+
input: boolean;
|
39
|
+
}[];
|
40
|
+
alwaysEnabled?: undefined;
|
41
|
+
})[];
|
42
|
+
}
|
43
|
+
export default _default;
|
@@ -0,0 +1,42 @@
|
|
1
|
+
export default {
|
2
|
+
title: "edit grid validation",
|
3
|
+
name: "EG_validation",
|
4
|
+
path: "EG_validation",
|
5
|
+
type: "form",
|
6
|
+
display: "form",
|
7
|
+
components: [
|
8
|
+
{
|
9
|
+
label: 'Root Text',
|
10
|
+
alwaysEnabled: false,
|
11
|
+
tableView: true,
|
12
|
+
key: 'text',
|
13
|
+
type: 'textfield',
|
14
|
+
input: true
|
15
|
+
},
|
16
|
+
{
|
17
|
+
label: "Edit Grid",
|
18
|
+
tableView: false,
|
19
|
+
validateWhenHidden: false,
|
20
|
+
rowDrafts: false,
|
21
|
+
key: "editGrid",
|
22
|
+
type: "editgrid",
|
23
|
+
displayAsTable: false,
|
24
|
+
input: true,
|
25
|
+
components: [
|
26
|
+
{
|
27
|
+
label: 'Textfield - EG',
|
28
|
+
applyMaskOn: 'change',
|
29
|
+
tableView: true,
|
30
|
+
validate: {
|
31
|
+
custom: "valid = (input === data.text) ? true : 'data must match root textfield';"
|
32
|
+
},
|
33
|
+
validateWhenHidden: false,
|
34
|
+
key: 'rootTest',
|
35
|
+
type: 'textfield',
|
36
|
+
alwaysEnabled: false,
|
37
|
+
input: true
|
38
|
+
},
|
39
|
+
],
|
40
|
+
},
|
41
|
+
],
|
42
|
+
};
|
@@ -16,7 +16,8 @@ import comp15 from './comp15';
|
|
16
16
|
import comp16 from './comp16';
|
17
17
|
import comp18 from './comp18';
|
18
18
|
import comp19 from './comp19';
|
19
|
+
import comp20 from './comp20';
|
19
20
|
import compOpenWhenEmpty from './comp-openWhenEmpty';
|
20
21
|
import withOpenWhenEmptyAndConditions from './comp-with-conditions-and-openWhenEmpty';
|
21
22
|
import compWithCustomDefaultValue from './comp-with-custom-default-value';
|
22
|
-
export { comp1, comp2, comp3, comp4, comp5, comp6, comp7, comp8, comp9, comp10, comp11, comp12, comp13, comp14, comp15, comp16, comp17, comp18, comp19, compOpenWhenEmpty, withOpenWhenEmptyAndConditions, compWithCustomDefaultValue, compTestEvents };
|
23
|
+
export { comp1, comp2, comp3, comp4, comp5, comp6, comp7, comp8, comp9, comp10, comp11, comp12, comp13, comp14, comp15, comp16, comp17, comp18, comp19, comp20, compOpenWhenEmpty, withOpenWhenEmptyAndConditions, compWithCustomDefaultValue, compTestEvents };
|
@@ -17,8 +17,9 @@ import comp16 from './comp16';
|
|
17
17
|
import comp17 from './comp17';
|
18
18
|
import comp18 from './comp18';
|
19
19
|
import comp19 from './comp19';
|
20
|
+
import comp20 from './comp20';
|
20
21
|
import withOpenWhenEmptyAndConditions from './comp-with-conditions-and-openWhenEmpty';
|
21
22
|
import compOpenWhenEmpty from './comp-openWhenEmpty';
|
22
23
|
import compWithCustomDefaultValue from './comp-with-custom-default-value';
|
23
24
|
import compTestEvents from './comp-test-events';
|
24
|
-
export { comp1, comp2, comp3, comp4, comp5, comp6, comp7, comp8, comp9, comp10, comp11, comp12, comp13, comp14, comp15, comp16, comp17, comp18, comp19, compOpenWhenEmpty, withOpenWhenEmptyAndConditions, compWithCustomDefaultValue, compTestEvents };
|
25
|
+
export { comp1, comp2, comp3, comp4, comp5, comp6, comp7, comp8, comp9, comp10, comp11, comp12, comp13, comp14, comp15, comp16, comp17, comp18, comp19, comp20, compOpenWhenEmpty, withOpenWhenEmptyAndConditions, compWithCustomDefaultValue, compTestEvents };
|
@@ -470,7 +470,7 @@ export default class FormComponent extends Component {
|
|
470
470
|
checkComponentValidity(data, dirty, row, options, errors = []) {
|
471
471
|
options = options || {};
|
472
472
|
const silentCheck = options.silentCheck || false;
|
473
|
-
if (this.subForm) {
|
473
|
+
if (this.subForm && !this.isNestedWizard) {
|
474
474
|
return this.subForm.checkValidity(this.subFormData, dirty, null, silentCheck, errors);
|
475
475
|
}
|
476
476
|
return super.checkComponentValidity(data, dirty, row, options, errors);
|
@@ -170,7 +170,13 @@ export default class NumberComponent extends Input {
|
|
170
170
|
}
|
171
171
|
let value = parseFloat(input);
|
172
172
|
if (!_.isNaN(value)) {
|
173
|
-
|
173
|
+
// Format scientific notation
|
174
|
+
if (/e/i.test(String(value))) {
|
175
|
+
value = value.toExponential(this.decimalLimit);
|
176
|
+
}
|
177
|
+
else {
|
178
|
+
value = String(value).replace('.', this.decimalSeparator);
|
179
|
+
}
|
174
180
|
}
|
175
181
|
else {
|
176
182
|
value = null;
|
@@ -9,4 +9,4 @@ import comp8 from './comp8';
|
|
9
9
|
import comp9 from './comp9';
|
10
10
|
import comp10 from './comp10';
|
11
11
|
import comp11 from './comp11';
|
12
|
-
export { comp1, comp2, comp3, comp4, comp5, comp6, comp7, comp8, comp9, comp10, comp11 };
|
12
|
+
export { comp1, comp2, comp3, comp4, comp5, comp6, comp7, comp8, comp9, comp10, comp11, scientificNotation };
|
@@ -0,0 +1,14 @@
|
|
1
|
+
declare namespace _default {
|
2
|
+
let label: string;
|
3
|
+
let mask: boolean;
|
4
|
+
let spellcheck: boolean;
|
5
|
+
let tableView: boolean;
|
6
|
+
let delimiter: boolean;
|
7
|
+
let requireDecimal: boolean;
|
8
|
+
let inputFormat: string;
|
9
|
+
let key: string;
|
10
|
+
let type: string;
|
11
|
+
let decimalLimit: number;
|
12
|
+
let input: boolean;
|
13
|
+
}
|
14
|
+
export default _default;
|
@@ -0,0 +1,13 @@
|
|
1
|
+
export default {
|
2
|
+
'label': 'Number',
|
3
|
+
'mask': false,
|
4
|
+
'spellcheck': true,
|
5
|
+
'tableView': true,
|
6
|
+
'delimiter': true,
|
7
|
+
'requireDecimal': true,
|
8
|
+
'inputFormat': 'plain',
|
9
|
+
'key': 'number',
|
10
|
+
'type': 'number',
|
11
|
+
'decimalLimit': 2,
|
12
|
+
'input': true
|
13
|
+
};
|
@@ -131,7 +131,7 @@ export default class SelectComponent extends ListComponent {
|
|
131
131
|
addCurrentChoices(values: any, items: any, keyValue: any): any;
|
132
132
|
getValueAsString(data: any, options: any): any;
|
133
133
|
normalizeSingleValue(value: any): any;
|
134
|
-
setMetadata(value: any): any;
|
134
|
+
setMetadata(value: any, flags?: {}): any;
|
135
135
|
updateValue(value: any, flags: any): boolean;
|
136
136
|
undoValueTyping(value: any): any;
|
137
137
|
setValue(value: any, flags?: {}): boolean;
|
@@ -1234,7 +1234,7 @@ export default class SelectComponent extends ListComponent {
|
|
1234
1234
|
}
|
1235
1235
|
return super.normalizeValue(this.normalizeSingleValue(value));
|
1236
1236
|
}
|
1237
|
-
setMetadata(value) {
|
1237
|
+
setMetadata(value, flags = {}) {
|
1238
1238
|
if (_.isNil(value)) {
|
1239
1239
|
return;
|
1240
1240
|
}
|
@@ -1245,7 +1245,7 @@ export default class SelectComponent extends ListComponent {
|
|
1245
1245
|
}
|
1246
1246
|
// Check to see if we need to save off the template data into our metadata.
|
1247
1247
|
const templateValue = this.component.reference && value?._id ? value._id.toString() : value;
|
1248
|
-
const shouldSaveData = !valueIsObject || this.component.reference;
|
1248
|
+
const shouldSaveData = (!valueIsObject || this.component.reference) && !this.inDataTable;
|
1249
1249
|
if (!_.isNil(templateValue) && shouldSaveData && this.templateData && this.templateData[templateValue] && this.root?.submission) {
|
1250
1250
|
const submission = this.root.submission;
|
1251
1251
|
if (!submission.metadata) {
|
@@ -1268,15 +1268,22 @@ export default class SelectComponent extends ListComponent {
|
|
1268
1268
|
}
|
1269
1269
|
_.set(submission.metadata.selectData, this.path, templateData);
|
1270
1270
|
}
|
1271
|
+
if (flags.resetValue && this.root?.submission) {
|
1272
|
+
const submission = this.root.submission;
|
1273
|
+
if (!submission.metadata) {
|
1274
|
+
submission.metadata = {};
|
1275
|
+
}
|
1276
|
+
submission.metadata.selectData = {};
|
1277
|
+
}
|
1271
1278
|
}
|
1272
1279
|
updateValue(value, flags) {
|
1273
1280
|
const changed = super.updateValue(value, flags);
|
1274
|
-
if (changed || !this.selectMetadata) {
|
1281
|
+
if (changed || !this.selectMetadata || flags.resetValue) {
|
1275
1282
|
if (this.component.multiple && Array.isArray(this.dataValue)) {
|
1276
|
-
this.dataValue.forEach(singleValue => this.setMetadata(singleValue));
|
1283
|
+
this.dataValue.forEach(singleValue => this.setMetadata(singleValue, flags));
|
1277
1284
|
}
|
1278
1285
|
else {
|
1279
|
-
this.setMetadata(this.dataValue);
|
1286
|
+
this.setMetadata(this.dataValue, flags);
|
1280
1287
|
}
|
1281
1288
|
}
|
1282
1289
|
return changed;
|