Skip to content

Commit

Permalink
fix failing tests by not always assuming bounds for dates exist.
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasnteireho committed Feb 16, 2024
1 parent 67d03b2 commit eed84ea
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 21 deletions.
2 changes: 1 addition & 1 deletion index.dev.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,6 @@
errRepURL: ''
}));
</script>
<script src="node_modules/steal/steal.production.js?v=1677170402416" cache-key="v" cache-version="1677170402416" main="@caliorg/a2jviewer/app"></script>
<script src="node_modules/steal/steal.production.js?v=1697489872534" cache-key="v" cache-version="1697489872534" main="@caliorg/a2jviewer/app"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,6 @@
errRepURL: ''
}));
</script>
<script src="node_modules/steal/steal.production.js?v=1697489872534" cache-key="v" cache-version="1697489872534" main="@caliorg/a2jviewer/app"></script>
<script src="node_modules/steal/steal.production.js?v=1708045473865" cache-key="v" cache-version="1708045473865" main="@caliorg/a2jviewer/app"></script>
</body>
</html>
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@caliorg/a2jviewer",
"version": "8.2.0-8",
"version": "8.2.0-9",
"description": "A2J Viewer standalone and preview app.",
"main": "a2jviewer/app",
"scripts": {
Expand Down
37 changes: 21 additions & 16 deletions src/mobile/pages/fields/field/field.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,31 +308,36 @@ export const FieldVM = DefineMap.extend('FieldVM', {
} else if (field.type === 'useravatar') { // TODO: validate the JSON string here?
value = JSON.stringify(this.userAvatar.serialize())
} else if (field.type === 'datemdy') {

// format date to (mm/dd/yyyy) from acceptable inputs
value = this.normalizeDateInput($el.val())


// date bounds are in 6 or 8 digit texts
// need to change to same format as value
// it would be sensible to keep bounds in this
// format but we need to support it to properly
// support older released guides without adding
// more complex code
let maxDate =
field.max.substr(0,2) + "/" +
field.max.substr(2,2) + "/" +
field.max.substr(4)

let minDate =
field.min.substr(0,2) + "/" +
field.min.substr(2,2) + "/" +
field.min.substr(4)

if (Date.parse(value) < Date.parse(minDate)){
value = minDate //field.min
} else if (Date.parse(value) > Date.parse(maxDate)){
value = maxDate //field.max

if (field.hasOwnProperty('max')) {
let maxDate =
field.max.substr(0, 2) + '/' +
field.max.substr(2, 2) + '/' +
field.max.substr(4)

if (Date.parse(value) > Date.parse(maxDate)) {
value = maxDate
}
}

if (field.hasOwnProperty('min')) {
let minDate =
field.min.substr(0, 2) + '/' +
field.min.substr(2, 2) + '/' +
field.min.substr(4)

if (Date.parse(value) < Date.parse(minDate)) {
value = minDate
}
}

// render formatted date for end user
Expand Down

0 comments on commit eed84ea

Please sign in to comment.