Skip to content

Commit

Permalink
Merge pull request #5834 from formio/FIO-9086-time-component-default-…
Browse files Browse the repository at this point in the history
…value-validation

FIO-9086: time component default value validation
  • Loading branch information
brendanbond authored Oct 15, 2024
2 parents 6f0fa61 + b72f609 commit 6801a11
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 29 deletions.
29 changes: 15 additions & 14 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- FIO-8234/FIO-7195: Fixes an issue where value properties are shown instead of labels for Select component with Resource/URL data sources in read only mode and for modal preview
- FIO-8986: fixed setting default value for day component with hidden day and month
- FIO-8719: fixed error message display for nested wizard components
- FIO-9086: time component with default value validation fix
- FIO-9080 checkbox radio validation error
- FIO-9147: fixed an issue where the simple conditionally visible component is not validated on change
- FIO-9056: Fix enabling multiple values for address component
Expand Down Expand Up @@ -109,7 +110,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- FIO-9153-9154: fixed console errors when navigating tagpad validation errors
- FIO-9127 fixed saving an empty value for day component after deleting values
- FIO-9120: Fix issue with unchecking radio default value
- FIO-7195/FIO-8234: Fixes an issue where Select renders value properties instead of labels in DataTable
- FIO-7195/FIO-8234: Fixes an issue where Select renders value properties instead of labels in DataTable

### New Features

Expand Down Expand Up @@ -160,7 +161,7 @@ This is a **Breaking Change** so please see the section below for more informati
The 5.x renderer incorporates our new Core validation engine found @ https://github.com/formio/core/tree/master/src/process. This process can be briefly described within the pull request notes @ https://github.com/formio/formio.js/pull/5317. This will also improve our Iso-morphic behavior for our renderer validation and significantly improve memory and processor consumption for server-side form validations. This feature does have a **Breaking Change** which is described below.

#### Core SDK
With the 5.x renderer, the Formio SDK is now part of our Core library found @ https://github.com/formio/core/tree/master/src/sdk. It is now imported directly into the @formio/js library and is re-exported to support reverse compatability. Because of this, there should not be any code upgrade involved.
With the 5.x renderer, the Formio SDK is now part of our Core library found @ https://github.com/formio/core/tree/master/src/sdk. It is now imported directly into the @formio/js library and is re-exported to support reverse compatability. Because of this, there should not be any code upgrade involved.

For example, the following code still works.

Expand Down Expand Up @@ -201,7 +202,7 @@ With the 5.x version of the renderer/builder, there has been much effort into re
- formio.form.min.js ~ 1.4mb => ~30% size reduction
- formio.min.js (SDK) ~ 235k => ~50% size reduction

#### New lazy-loading Embedding method.
#### New lazy-loading Embedding method.
One of the more exciting new additions to the 5.x renderer is the new lazy-loading process for adding the renderer to your application. There is a new file that is included with the 5.x renderer called "formio.embed.js". This file is tiny coming in at ~10kb. What this file does, however, is make it so that you can bundle a lazy-loading renderer within your application without increasing the build sizes of your application.

To use the new lazy-loading features, you will need to change your imports from the following to the new embed source as the following illustrates.
Expand Down Expand Up @@ -296,7 +297,7 @@ Formio.createForm(document.getElementById('formio'), 'https://examples.form.io/e
```js
const isValid = form.getComponent('editgrid').validateRow().length === 0;
```

- In the 5.x renderer, the errors array will always be populated if there are errors in the form. They may not be displayed depending on the "pristine" state of the rendered form, but the error is always populated if there are form errors. This is different in 4.x where the error property would only contain and error if an error is VISIBLE on the form. This means that it is difficult to determine if a form has errors without executing the checkValidity() method with the dirty flag set to "true". You no longer need to do this in the 5.x renderer.

**4.x Renderer**
Expand Down Expand Up @@ -325,7 +326,7 @@ Formio.createForm(document.getElementById('formio'), 'https://examples.form.io/e
console.log(textField.visibleErrors); // This is the equivalent of the 4.x renderer "errors" array.
```

- With the 5.x renderer, all templates are now stored within a separate repo, and are included as a dependency for this renderer.
- With the 5.x renderer, all templates are now stored within a separate repo, and are included as a dependency for this renderer.

### Fixed
- FIO-7525: fixed an issue where new conditional logic based on select boxes does not work
Expand Down Expand Up @@ -468,7 +469,7 @@ Formio.createForm(document.getElementById('formio'), 'https://examples.form.io/e

### Changed
- Add capability for adding sanitize profiles through sanitizeConfig in options

## 5.0.0-rc.26
### Changed
- More improvements to the embed capabilities.
Expand Down Expand Up @@ -549,7 +550,7 @@ Formio.createForm(document.getElementById('formio'), 'https://examples.form.io/e
## 5.0.0-rc.6
### Added
- FIO-5748: added collapsible preview for Form Builder

### Fixed
- FIO-6950: fixed test
- FIO-6669: fixed tooltips cutting off in the component settings modal
Expand All @@ -561,7 +562,7 @@ Formio.createForm(document.getElementById('formio'), 'https://examples.form.io/e
- FIO-6453: added sanitization inside error message container
- FIO-6345: Add rel=noopener to Links to Docs / External Links
- FIO-5042: Logout feature for OIDC

### Fixed
- FIO-6616: fixed issue where the select templates were not getting set correctly in selectData
- FIO-6533: fixed an issue where file upload hash causing delays in file uploads
Expand Down Expand Up @@ -643,7 +644,7 @@ Formio.use(bootstrap4);
### Added
- FIO-4429: Add support for pdf auto conversion fields assignment
- Added basic keyboard accessibility for formbuilder
### Fixed
- FIO-6512: cannot drag and drop components on to pdf first forms using mac
- FIO-6468: fixed an issue where Custom validation on Day component is confusing Day and Year
Expand Down Expand Up @@ -797,9 +798,9 @@ Formio.use(bootstrap4);
- FIO-5069: API driven dataTable
- FIO-5455: Fixes context variables not available in datetime custom disabled dates config
- FIO-5544: added sticky property to the form components when building forms
- Upgrade vanilla text mask and text-mask addons.
- Upgrade vanilla text mask and text-mask addons.
- FIO-3814: fixed fetch data several times when RefreshOnBlur
## 4.15.0-rc.13
### Added
- FIO-4836: hash was added to file
Expand All @@ -808,7 +809,7 @@ Formio.use(bootstrap4);
- FIO-4942: fixed email submission: Custom PDF File Name is not respected
- FIO-4997: extended check for execution on the server side for tabs component
- FIO-4861: fixed restored revision node
- FIO-4976: Fixes select resource data not showing on submission
- FIO-4976: Fixes select resource data not showing on submission
- FIO-5053: fixed an issue where select data with html5 widget type is not showing on view or pdf download after submission
- FIO-5003: fixed that the radio with the value "false" is not displayed in different templates.
- FIO-4970: reduced limit query parameter value for resource requests
Expand Down Expand Up @@ -922,7 +923,7 @@ Formio.use(bootstrap4);
- FIO-4571: Fixea an issue where tooltips do not appear on hover in the component setting modal
- FIO-2645: Made clicking on the error of Container component redirect to it.
- FIO-4595, FIO-4364: Fixes Select with URL keeping default value on pdf submission
- FIO-4362: Fixed issues with checkbox set as radio type.
- FIO-4362: Fixed issues with checkbox set as radio type.
- FIO-4615: Fixing issues with calendar widget with save as text.
## 4.15.0-rc.1
Expand All @@ -943,7 +944,7 @@ Formio.use(bootstrap4);
- FIO-4443: Fixed signature not visible when generating a pdf.
- FIO-4466: Fixed 'Save as reference' in Select resource
- FIO-4496: fixed an issue where response from the resource does not display in the dropdown when more than one object is in the item template
- FIO-4487: Protect the comp variable when iterating in wizards
- FIO-4487: Protect the comp variable when iterating in wizards
- FIO-4405: fixed an issue where form doesn't submit if hidden radio component has storage type as string
- FIO-3715: fixed an issue where validation errors were shown with a submission in draft state if container component inside the form
- FIO-4442: fixed an issue where date is showing the date prior to submitted date on view tab and data tab
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
"dependencies": {
"@formio/bootstrap": "3.0.0-dev.98.17ba6ea",
"@formio/choices.js": "^10.2.1",
"@formio/core": "v2.1.0-dev.165.e6994a9",
"@formio/core": "2.3.0-dev.160.cabaa43",
"@formio/text-mask-addons": "^3.8.0-formio.2",
"@formio/vanilla-text-mask": "^5.1.1-formio.1",
"abortcontroller-polyfill": "^1.7.5",
Expand Down Expand Up @@ -183,7 +183,9 @@
"branches": 63,
"functions": 61,
"lines": 64,
"include": ["src/**/*.js"],
"include": [
"src/**/*.js"
],
"exclude": [
"src/**/fixtures"
],
Expand Down
6 changes: 0 additions & 6 deletions src/components/time/Time.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,6 @@ export default class TimeComponent extends TextFieldComponent {
return value;
}

get validationValue() {
if ((Array.isArray(this.rawData) && !this.rawData.length) || !this.rawData) {
return this.dataValue;
}
return this.rawData;
}

get inputInfo() {
const info = super.inputInfo;
Expand Down
26 changes: 26 additions & 0 deletions test/unit/Time.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,32 @@ describe('Time Component', () => {
}).catch(done);
});

it('Should return error if data in multiple time component is not valid', (done) => {
const formElement = document.createElement('div');
const form = new Webform(formElement);
form.setForm(timeForm2).then(() => {
const component = form.components[1];
Harness.setInputValue(component, 'data[multipleTime]', ['89:19']);
setTimeout(() => {
assert.equal(component.errors[0].message, 'Invalid time', 'Should have an error');
done();
}, 650);
}).catch(done);
});

it('Should not return error if data in multiple time component is not valid', (done) => {
const formElement = document.createElement('div');
const form = new Webform(formElement);
form.setForm(timeForm2).then(() => {
const component = form.components[1];
Harness.setInputValue(component, 'data[multipleTime]', ['10:00:00']);
setTimeout(() => {
assert.equal(component.errors.length, 0, 'Should not have an error');
done();
}, 650);
}).catch(done);
});

it('Should build a time component', (done) => {
Harness.testCreate(TimeComponent, comp3).then((time) => {
assert.deepEqual(time.dataValue, ['10:00:00', '11:00:00'], 'Should be set to default value');
Expand Down
9 changes: 9 additions & 0 deletions test/unit/fixtures/time/timeForm2.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ export default {
'input': true,
'inputMask': '99:99'
},
{
'label': 'Multiple Time',
'inputType': 'text',
'tableView': true,
'key': 'multipleTime',
'type': 'time',
'input': true,
'inputMask': '99:99'
},
{
'label': 'Submit',
'showValidations': false,
Expand Down
39 changes: 32 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -381,10 +381,10 @@
fuse.js "^6.6.2"
redux "^4.2.0"

"@formio/core@v2.1.0-dev.165.e6994a9":
version "2.1.0-dev.165.e6994a9"
resolved "https://registry.yarnpkg.com/@formio/core/-/core-2.1.0-dev.165.e6994a9.tgz#624ead05fcb7d084253cee5970a7420c6b3ea900"
integrity sha512-GgtAuuLcBJSsuBNW+KQ7YxDQ0Jwb8BtnPjYVj1v4QtAnyE4gZ4t/DSxY+f34wXXZPMd3Q69lEIWjpF2ozIhgFg==
"@formio/core@2.3.0-dev.160.cabaa43":
version "2.3.0-dev.160.cabaa43"
resolved "https://registry.yarnpkg.com/@formio/core/-/core-2.3.0-dev.160.cabaa43.tgz#d61abaeecdfe7adb472afa33f68fe40f3f833751"
integrity sha512-GOpg2Fihsxph6aShM76q5SzrUSo5Xg3fm0aV6Up1hS+fZmJZb5xl+Ig5ABh3CnVncxkNPBsPj8I96sLYMdvj/A==
dependencies:
"@types/json-logic-js" "^2.0.7"
browser-cookies "^1.2.0"
Expand Down Expand Up @@ -7325,7 +7325,7 @@ string-replace-loader@^3.1.0:
loader-utils "^2.0.0"
schema-utils "^3.0.0"

"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0, string-width@^4.2.0:
"string-width-cjs@npm:string-width@^4.2.0":
version "4.2.3"
resolved "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
Expand All @@ -7343,6 +7343,15 @@ string-width@^1.0.1, string-width@^1.0.2:
is-fullwidth-code-point "^1.0.0"
strip-ansi "^3.0.0"

string-width@^4.1.0, string-width@^4.2.0:
version "4.2.3"
resolved "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
dependencies:
emoji-regex "^8.0.0"
is-fullwidth-code-point "^3.0.0"
strip-ansi "^6.0.1"

string-width@^5.0.1, string-width@^5.1.2:
version "5.1.2"
resolved "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz#14f8daec6d81e7221d2a357e668cab73bdbca794"
Expand Down Expand Up @@ -7403,7 +7412,7 @@ stringifier@^1.3.0:
traverse "^0.6.6"
type-name "^2.0.1"

"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
version "6.0.1"
resolved "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
Expand All @@ -7424,6 +7433,13 @@ strip-ansi@^4.0.0:
dependencies:
ansi-regex "^3.0.0"

strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
dependencies:
ansi-regex "^5.0.1"

strip-ansi@^7.0.1:
version "7.1.0"
resolved "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45"
Expand Down Expand Up @@ -8486,7 +8502,7 @@ [email protected]:
resolved "https://registry.npmjs.org/workerpool/-/workerpool-6.2.1.tgz#46fc150c17d826b86a008e5a4508656777e9c343"
integrity sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw==

"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
version "7.0.0"
resolved "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
Expand All @@ -8512,6 +8528,15 @@ wrap-ansi@^6.2.0:
string-width "^4.1.0"
strip-ansi "^6.0.0"

wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
dependencies:
ansi-styles "^4.0.0"
string-width "^4.1.0"
strip-ansi "^6.0.0"

wrap-ansi@^8.1.0:
version "8.1.0"
resolved "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"
Expand Down

0 comments on commit 6801a11

Please sign in to comment.