From 690b64e948c4d17f757b0ad44ce0b4c811436260 Mon Sep 17 00:00:00 2001 From: Tobias Nteireho Date: Mon, 12 Feb 2024 17:23:09 -0600 Subject: [PATCH 01/10] wip date bounds enforcement --- src/mobile/pages/fields/field/field.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/mobile/pages/fields/field/field.js b/src/mobile/pages/fields/field/field.js index 112998cd..8de4865e 100644 --- a/src/mobile/pages/fields/field/field.js +++ b/src/mobile/pages/fields/field/field.js @@ -308,9 +308,19 @@ 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()) // render formatted date for end user + + if (Date.parse(value) < Date.parse(field.min)){ + value = field.min + } else if (Date.parse(value) > Date.parse(field.max)){ + value = field.min + } + + + $el.val(value) } else { value = $el.val() From 9a3ce25d1a0d94882c1161fbd4053699e9fe884e Mon Sep 17 00:00:00 2001 From: Tobias Nteireho Date: Mon, 12 Feb 2024 18:35:13 -0600 Subject: [PATCH 02/10] check max --- src/mobile/pages/fields/field/field.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/mobile/pages/fields/field/field.js b/src/mobile/pages/fields/field/field.js index 8de4865e..72106539 100644 --- a/src/mobile/pages/fields/field/field.js +++ b/src/mobile/pages/fields/field/field.js @@ -311,15 +311,19 @@ export const FieldVM = DefineMap.extend('FieldVM', { // format date to (mm/dd/yyyy) from acceptable inputs value = this.normalizeDateInput($el.val()) - // render formatted date for end user + + console.log("changed") + if (Date.parse(value) < Date.parse(field.min)){ + console.log("smaller") value = field.min } else if (Date.parse(value) > Date.parse(field.max)){ - value = field.min + console.log("bigger") + value = field.max } - + // render formatted date for end user $el.val(value) } else { From deb6ae9f89d993c1b132982af646e2f5ba2b04d1 Mon Sep 17 00:00:00 2001 From: Tobias Nteireho Date: Mon, 12 Feb 2024 18:43:52 -0600 Subject: [PATCH 03/10] debug --- src/mobile/pages/fields/field/field.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/mobile/pages/fields/field/field.js b/src/mobile/pages/fields/field/field.js index 72106539..1ed83194 100644 --- a/src/mobile/pages/fields/field/field.js +++ b/src/mobile/pages/fields/field/field.js @@ -313,6 +313,11 @@ export const FieldVM = DefineMap.extend('FieldVM', { value = this.normalizeDateInput($el.val()) console.log("changed") + console.log(value) + console.log(field.min) + console.log(field.max) + console.log(field) + if (Date.parse(value) < Date.parse(field.min)){ From 9bb801afad650841d919993e5da1f51149aec09a Mon Sep 17 00:00:00 2001 From: Tobias Nteireho Date: Mon, 12 Feb 2024 19:11:05 -0600 Subject: [PATCH 04/10] normalize min and max --- src/mobile/pages/fields/field/field.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mobile/pages/fields/field/field.js b/src/mobile/pages/fields/field/field.js index 1ed83194..4b79b0a0 100644 --- a/src/mobile/pages/fields/field/field.js +++ b/src/mobile/pages/fields/field/field.js @@ -320,10 +320,10 @@ export const FieldVM = DefineMap.extend('FieldVM', { - if (Date.parse(value) < Date.parse(field.min)){ + if (Date.parse(value) < Date.parse(normalizeDateInput(field.min))){ console.log("smaller") value = field.min - } else if (Date.parse(value) > Date.parse(field.max)){ + } else if (Date.parse(value) > Date.parse(normalizeDateInput(field.max))){ console.log("bigger") value = field.max } From c2b0b65eed078da0d783714c54cb7d985eb99da2 Mon Sep 17 00:00:00 2001 From: Tobias Nteireho Date: Wed, 14 Feb 2024 14:11:34 -0600 Subject: [PATCH 05/10] use denormalize max and min --- src/mobile/pages/fields/field/field.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/mobile/pages/fields/field/field.js b/src/mobile/pages/fields/field/field.js index 4b79b0a0..e8231283 100644 --- a/src/mobile/pages/fields/field/field.js +++ b/src/mobile/pages/fields/field/field.js @@ -320,12 +320,24 @@ export const FieldVM = DefineMap.extend('FieldVM', { - if (Date.parse(value) < Date.parse(normalizeDateInput(field.min))){ + let maxDate = Date.parse( + field.max.substr(0,2) + "/" + + field.max.substr(2,2) + "/" + + field.max.substr(4)) + + let minDate = Date.parse( + field.min.substr(0,2) + "/" + + field.min.substr(2,2) + "/" + + field.min.substr(4)) + + + + if (Date.parse(value) < minDate){ console.log("smaller") - value = field.min - } else if (Date.parse(value) > Date.parse(normalizeDateInput(field.max))){ + value = minDate //field.min + } else if (Date.parse(value) > maxDate){ console.log("bigger") - value = field.max + value = maxDate //field.max } // render formatted date for end user From 2170b5a0782abedbc792b4f3535ca80703cceb73 Mon Sep 17 00:00:00 2001 From: Tobias Nteireho Date: Wed, 14 Feb 2024 14:21:45 -0600 Subject: [PATCH 06/10] parse min and max only in comparison --- src/mobile/pages/fields/field/field.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/mobile/pages/fields/field/field.js b/src/mobile/pages/fields/field/field.js index e8231283..aa5c8a47 100644 --- a/src/mobile/pages/fields/field/field.js +++ b/src/mobile/pages/fields/field/field.js @@ -320,22 +320,22 @@ export const FieldVM = DefineMap.extend('FieldVM', { - let maxDate = Date.parse( + let maxDate = field.max.substr(0,2) + "/" + field.max.substr(2,2) + "/" + - field.max.substr(4)) + field.max.substr(4) - let minDate = Date.parse( + let minDate = field.min.substr(0,2) + "/" + field.min.substr(2,2) + "/" + - field.min.substr(4)) + field.min.substr(4) - if (Date.parse(value) < minDate){ + if (Date.parse(value) < Date.parse(minDate)){ console.log("smaller") value = minDate //field.min - } else if (Date.parse(value) > maxDate){ + } else if (Date.parse(value) > Date.parse(maxDate)){ console.log("bigger") value = maxDate //field.max } From a018970e00e0758e68570c3c084c2718abe83b09 Mon Sep 17 00:00:00 2001 From: Tobias Nteireho Date: Wed, 14 Feb 2024 15:02:23 -0600 Subject: [PATCH 07/10] cleanup --- src/mobile/pages/fields/field/field.js | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/mobile/pages/fields/field/field.js b/src/mobile/pages/fields/field/field.js index aa5c8a47..4e55f3f6 100644 --- a/src/mobile/pages/fields/field/field.js +++ b/src/mobile/pages/fields/field/field.js @@ -312,14 +312,9 @@ export const FieldVM = DefineMap.extend('FieldVM', { // format date to (mm/dd/yyyy) from acceptable inputs value = this.normalizeDateInput($el.val()) - console.log("changed") - console.log(value) - console.log(field.min) - console.log(field.max) - console.log(field) - - + // date bounds are in 6 or 8 digit texts + // need to change to same format as value let maxDate = field.max.substr(0,2) + "/" + field.max.substr(2,2) + "/" + @@ -330,13 +325,9 @@ export const FieldVM = DefineMap.extend('FieldVM', { field.min.substr(2,2) + "/" + field.min.substr(4) - - if (Date.parse(value) < Date.parse(minDate)){ - console.log("smaller") value = minDate //field.min } else if (Date.parse(value) > Date.parse(maxDate)){ - console.log("bigger") value = maxDate //field.max } From 984cc291235a21bab8d3b79409a8862edce5d0b0 Mon Sep 17 00:00:00 2001 From: Tobias Nteireho Date: Wed, 14 Feb 2024 15:03:21 -0600 Subject: [PATCH 08/10] update prerel ver --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9b970751..7cfb9ce5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@caliorg/a2jviewer", - "version": "8.2.0-1", + "version": "8.2.0-8", "description": "A2J Viewer standalone and preview app.", "main": "a2jviewer/app", "scripts": { From 67d03b2f1d213f80ad20b267726a4efba0287b22 Mon Sep 17 00:00:00 2001 From: Tobias Nteireho Date: Thu, 15 Feb 2024 07:34:15 -0600 Subject: [PATCH 09/10] add more comments --- src/mobile/pages/fields/field/field.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/mobile/pages/fields/field/field.js b/src/mobile/pages/fields/field/field.js index 4e55f3f6..83080237 100644 --- a/src/mobile/pages/fields/field/field.js +++ b/src/mobile/pages/fields/field/field.js @@ -315,6 +315,10 @@ export const FieldVM = DefineMap.extend('FieldVM', { // 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) + "/" + From eed84ea8ca01848daf50819e70dfbe928b2542b8 Mon Sep 17 00:00:00 2001 From: Tobias Nteireho Date: Thu, 15 Feb 2024 19:13:59 -0600 Subject: [PATCH 10/10] fix failing tests by not always assuming bounds for dates exist. --- index.dev.html | 2 +- index.html | 2 +- package-lock.json | 4 +-- package.json | 2 +- src/mobile/pages/fields/field/field.js | 37 +++++++++++++++----------- 5 files changed, 26 insertions(+), 21 deletions(-) diff --git a/index.dev.html b/index.dev.html index 6b57e8eb..f93d3ae3 100644 --- a/index.dev.html +++ b/index.dev.html @@ -59,6 +59,6 @@ errRepURL: '' })); - + \ No newline at end of file diff --git a/index.html b/index.html index f93d3ae3..80dbcb37 100644 --- a/index.html +++ b/index.html @@ -59,6 +59,6 @@ errRepURL: '' })); - + \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index ce8cb92f..676177c4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@caliorg/a2jviewer", - "version": "8.2.0-1", + "version": "8.2.0-8", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@caliorg/a2jviewer", - "version": "8.2.0-1", + "version": "8.2.0-8", "license": "GNU AGPL v3.0", "dependencies": { "@caliorg/a2jdeps": "^7.1.7", diff --git a/package.json b/package.json index 7cfb9ce5..5489e81a 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/src/mobile/pages/fields/field/field.js b/src/mobile/pages/fields/field/field.js index 83080237..8c56dc4a 100644 --- a/src/mobile/pages/fields/field/field.js +++ b/src/mobile/pages/fields/field/field.js @@ -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