From 03f9f688afb6dfe18554299f04301a6317003d6f Mon Sep 17 00:00:00 2001 From: Maria-Golomb Date: Tue, 20 Aug 2024 23:47:31 +0300 Subject: [PATCH 1/8] FIO-8798: updated shape of the data of day component with hidden fields --- src/components/day/Day.js | 38 ++++++++++++++++++++-------------- src/components/day/Day.unit.js | 32 ++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 15 deletions(-) diff --git a/src/components/day/Day.js b/src/components/day/Day.js index 3ab93a91df..50b6c1cd8e 100644 --- a/src/components/day/Day.js +++ b/src/components/day/Day.js @@ -26,7 +26,8 @@ export default class DayComponent extends Field { required: false } }, - dayFirst: false + dayFirst: false, + defaultValue: '' }, ...extend); } @@ -41,13 +42,6 @@ export default class DayComponent extends Field { }; } - static get conditionOperatorsSettings() { - return { - ...super.conditionOperatorsSettings, - operators: ['isDateEqual', 'isNotDateEqual', 'isEmpty', 'isNotEmpty','dateLessThan', 'dateGreaterThan', 'dateLessThanOrEqual','dateGreaterThanOrEqual'], - }; - } - static savedValueTypes(schema) { schema = schema || {}; return getComponentSavedTypes(schema) || [componentValueTypes.string]; @@ -386,20 +380,25 @@ export default class DayComponent extends Field { const [DAY, MONTH, YEAR] = this.component.dayFirst ? [0, 1, 2] : [1, 0, 2]; const defaultValue = this.component.defaultValue ? this.component.defaultValue.split('/') : ''; - const getNextPart = (shouldTake, defaultValue) => - dateParts.push(shouldTake ? valueParts.shift() : defaultValue); + const getNextPart = (shouldTake, defaultValue) => { + // Only push the part if it's not an empty string + const part = shouldTake ? valueParts.shift() : defaultValue; + if (part !== '') { + dateParts.push(part); + } + } if (this.dayFirst) { - getNextPart(this.showDay, defaultValue ? defaultValue[DAY] : '00'); + getNextPart(this.showDay, defaultValue ? defaultValue[DAY] : ''); } - getNextPart(this.showMonth, defaultValue ? defaultValue[MONTH] : '00'); + getNextPart(this.showMonth, defaultValue ? defaultValue[MONTH] : ''); if (!this.dayFirst) { - getNextPart(this.showDay, defaultValue ? defaultValue[DAY] : '00'); + getNextPart(this.showDay, defaultValue ? defaultValue[DAY] : ''); } - getNextPart(this.showYear, defaultValue ? defaultValue[YEAR] : '0000'); + getNextPart(this.showYear, defaultValue ? defaultValue[YEAR] : ''); return dateParts.join('/'); } @@ -628,7 +627,16 @@ export default class DayComponent extends Field { } const [DAY, MONTH, YEAR] = this.component.dayFirst ? [0, 1, 2] : [1, 0, 2]; const values = value.split('/'); - return (values[DAY] === '00' || values[MONTH] === '00' || values[YEAR] === '0000'); + // return (values[DAY] === '00' || values[MONTH] === '00' || values[YEAR] === '0000'); + + + + return (values[DAY] === '00' || + values[MONTH] === '00' || + values[YEAR] === '0000' || + values[DAY] === '' || + values[MONTH] === '' || + values[YEAR] === ''); } getValidationFormat() { diff --git a/src/components/day/Day.unit.js b/src/components/day/Day.unit.js index bc6d64cb3d..6fe8f7944d 100644 --- a/src/components/day/Day.unit.js +++ b/src/components/day/Day.unit.js @@ -197,6 +197,38 @@ describe('Day Component', () => { }); }); + it('Should set value if the day field is hidden', (done) => { + comp1.dayFirst = false; + comp1.fields.day.hide = true; + Harness.testCreate(DayComponent, comp1).then((component) => { + component.setValue('12/2023'); + assert.equal(component.data.date, '12/2023'); + done(); + }); + comp1.fields.day.hide = false; + }); + + it('Should set value if the month field is hidden', (done) => { + comp1.fields.month.hide = true; + Harness.testCreate(DayComponent, comp1).then((component) => { + component.setValue('12/2023'); + assert.equal(component.data.date, '12/2023'); + done(); + }); + comp1.fields.month.hide = false; + }); + + it('Should set value if the year field is hidden', (done) => { + comp1.fields.year.hide = true; + Harness.testCreate(DayComponent, comp1).then((component) => { + component.setValue('12/21'); + assert.equal(component.data.date, '12/21'); + done(); + }); + comp1.fields.year.hide = false; + }); + + it('Should use the default day value if the day field is hidden', (done) => { comp1.dayFirst = false; comp1.defaultValue = '00/01/0000'; From 4aea0576d8ac44a63e9091590dd54800bb0d6414 Mon Sep 17 00:00:00 2001 From: Maria-Golomb Date: Wed, 21 Aug 2024 16:08:24 +0300 Subject: [PATCH 2/8] FIO-8798: add conditionOperatorsSettings for Day component --- src/components/day/Day.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/components/day/Day.js b/src/components/day/Day.js index 50b6c1cd8e..5378c59e51 100644 --- a/src/components/day/Day.js +++ b/src/components/day/Day.js @@ -42,6 +42,13 @@ export default class DayComponent extends Field { }; } + static get conditionOperatorsSettings() { + return { + ...super.conditionOperatorsSettings, + operators: ['isDateEqual', 'isNotDateEqual', 'isEmpty', 'isNotEmpty','dateLessThan', 'dateGreaterThan', 'dateLessThanOrEqual','dateGreaterThanOrEqual'], + }; + } + static savedValueTypes(schema) { schema = schema || {}; return getComponentSavedTypes(schema) || [componentValueTypes.string]; From 12a30c3e5abb2b29274f6481f0786cd261f32e8d Mon Sep 17 00:00:00 2001 From: Maria-Golomb Date: Thu, 22 Aug 2024 17:21:40 +0300 Subject: [PATCH 3/8] FIO-8798: update core version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index af40333360..6c4307affd 100644 --- a/package.json +++ b/package.json @@ -81,7 +81,7 @@ "dependencies": { "@formio/bootstrap": "3.0.0-dev.98.17ba6ea", "@formio/choices.js": "^10.2.1", - "@formio/core": "2.1.0-dev.105.1bff2e6", + "@formio/core": "2.1.0-dev.140.129711f", "@formio/text-mask-addons": "^3.8.0-formio.2", "@formio/vanilla-text-mask": "^5.1.1-formio.1", "abortcontroller-polyfill": "^1.7.5", From 80c51277445abc1620aa3f664c2dd2781b428fcd Mon Sep 17 00:00:00 2001 From: Maria-Golomb Date: Thu, 22 Aug 2024 17:34:07 +0300 Subject: [PATCH 4/8] FIO-8798: add yarn.lock --- yarn.lock | 43 ++++++++++++++----------------------------- 1 file changed, 14 insertions(+), 29 deletions(-) diff --git a/yarn.lock b/yarn.lock index 99d376e067..73da879440 100644 --- a/yarn.lock +++ b/yarn.lock @@ -275,21 +275,21 @@ fuse.js "^6.6.2" redux "^4.2.0" -"@formio/core@2.1.0-dev.105.1bff2e6": - version "2.1.0-dev.105.1bff2e6" - resolved "https://registry.yarnpkg.com/@formio/core/-/core-2.1.0-dev.105.1bff2e6.tgz#068bf67444641692f3f8037b16ec4c69c033c91e" - integrity sha512-bIbWLn2/Lg6nYKqUYlNDcuF7EH7pIUNUzQBR1XDQ7P0LucK8ukG5Y8A3WOmVtR8S++VShSw8pzapnCytutDA7g== +"@formio/core@2.1.0-dev.140.129711f": + version "2.1.0-dev.140.129711f" + resolved "https://registry.yarnpkg.com/@formio/core/-/core-2.1.0-dev.140.129711f.tgz#c6203a781301671447610355f544ed2af145a22b" + integrity sha512-9WU/5Tv7pY+8vxT1Hj5kAiAVDHggAlRGS9kVW5ok+Ht7kOCfSdCSaDI+oaaxfQqdzNd4jbicJdpA5ELCTiAvEQ== dependencies: "@types/json-logic-js" "^2.0.7" browser-cookies "^1.2.0" core-js "^3.37.1" - dayjs "^1.11.11" - dompurify "^3.1.4" + dayjs "^1.11.12" + dompurify "^3.1.6" eventemitter3 "^5.0.0" fast-json-patch "^3.1.1" fetch-ponyfill "^7.1.0" - inputmask "5.0.8" - json-logic-js "^2.0.2" + inputmask "5.0.9" + json-logic-js "^2.0.5" lodash "^4.17.21" moment "^2.29.4" @@ -2048,10 +2048,10 @@ date-format@^4.0.14: resolved "https://registry.npmjs.org/date-format/-/date-format-4.0.14.tgz#7a8e584434fb169a521c8b7aa481f355810d9400" integrity sha512-39BOQLs9ZjKh0/patS9nrT8wc3ioX3/eA/zgbKNopnF2wCqJEoxywwwElATYvRsXdnOxA/OQeQoFZ3rFjVajhg== -dayjs@^1.11.11: - version "1.11.11" - resolved "https://registry.npmjs.org/dayjs/-/dayjs-1.11.11.tgz#dfe0e9d54c5f8b68ccf8ca5f72ac603e7e5ed59e" - integrity sha512-okzr3f11N6WuqYtZSvm+F776mB41wRZMhKP+hc34YdW+KmtYYK9iqvHSwo2k9FEH3fhGXvOPV6yz2IcSrfRUDg== +dayjs@^1.11.12: + version "1.11.13" + resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.11.13.tgz#92430b0139055c3ebb60150aa13e860a4b5a366c" + integrity sha512-oaMBel6gjolK862uaPQOVTA7q3TZhuSvuMQAAglQDOWYO9A91IrAOUJEyKVlqJlHE0vq5p5UXxzdPfMH/x6xNg== debounce@^1.2.1: version "1.2.1" @@ -2294,11 +2294,6 @@ domexception@^4.0.0: dependencies: webidl-conversions "^7.0.0" -dompurify@^3.1.4: - version "3.1.5" - resolved "https://registry.npmjs.org/dompurify/-/dompurify-3.1.5.tgz#2c6a113fc728682a0f55684b1388c58ddb79dc38" - integrity sha512-lwG+n5h8QNpxtyrJW/gJWckL+1/DQiYMX8f7t8Z2AZTPw1esVrqjI63i7Zc2Gz0aKzLVMYC1V1PL/ky+aY/NgA== - dompurify@^3.1.6: version "3.1.6" resolved "https://registry.yarnpkg.com/dompurify/-/dompurify-3.1.6.tgz#43c714a94c6a7b8801850f82e756685300a027e2" @@ -3974,14 +3969,9 @@ ini@^1.3.4: resolved "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz#a29da425b48806f34767a4efce397269af28432c" integrity sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew== -inputmask@5.0.8: - version "5.0.8" - resolved "https://registry.npmjs.org/inputmask/-/inputmask-5.0.8.tgz#cd0f70b058c3291a0d4f27de25dbfc179c998bb4" - integrity sha512-1WcbyudPTXP1B28ozWWyFa6QRIUG4KiLoyR6LFHlpT4OfTzRqFfWgHFadNvRuMN1S9XNVz9CdNvCGjJi+uAMqQ== - -inputmask@^5.0.8: +inputmask@5.0.9, inputmask@^5.0.8: version "5.0.9" - resolved "https://registry.npmjs.org/inputmask/-/inputmask-5.0.9.tgz#7bf4e83f5e199c88c0edf28545dc23fa208ef4be" + resolved "https://registry.yarnpkg.com/inputmask/-/inputmask-5.0.9.tgz#7bf4e83f5e199c88c0edf28545dc23fa208ef4be" integrity sha512-s0lUfqcEbel+EQXtehXqwCJGShutgieOaIImFKC/r4reYNvX3foyrChl6LOEvaEgxEbesePIrw1Zi2jhZaDZbQ== internal-slot@^1.0.7: @@ -4553,11 +4543,6 @@ json-buffer@3.0.1: resolved "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz#9338802a30d3b6605fbe0613e094008ca8c05a13" integrity sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ== -json-logic-js@^2.0.2: - version "2.0.2" - resolved "https://registry.npmjs.org/json-logic-js/-/json-logic-js-2.0.2.tgz#b613e095f5e598cb78f7b9a2bbf638e74cf98158" - integrity sha512-ZBtBdMJieqQcH7IX/LaBsr5pX+Y5JIW+EhejtM3Ffg2jdN9Iwf+Ht6TbHnvAZ/YtwyuhPaCBlnvzrwVeWdvGDQ== - json-logic-js@^2.0.5: version "2.0.5" resolved "https://registry.yarnpkg.com/json-logic-js/-/json-logic-js-2.0.5.tgz#55f0c687dd6f56b02ccdcfdd64171ed998ab5499" From 13e21b9865d92a5a9b307e95801c17c8f1b9ba9f Mon Sep 17 00:00:00 2001 From: Maria-Golomb Date: Fri, 23 Aug 2024 02:37:17 +0300 Subject: [PATCH 5/8] Revert "FIO-8798: add yarn.lock" This reverts commit 80c51277445abc1620aa3f664c2dd2781b428fcd. --- yarn.lock | 43 +++++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/yarn.lock b/yarn.lock index 73da879440..99d376e067 100644 --- a/yarn.lock +++ b/yarn.lock @@ -275,21 +275,21 @@ fuse.js "^6.6.2" redux "^4.2.0" -"@formio/core@2.1.0-dev.140.129711f": - version "2.1.0-dev.140.129711f" - resolved "https://registry.yarnpkg.com/@formio/core/-/core-2.1.0-dev.140.129711f.tgz#c6203a781301671447610355f544ed2af145a22b" - integrity sha512-9WU/5Tv7pY+8vxT1Hj5kAiAVDHggAlRGS9kVW5ok+Ht7kOCfSdCSaDI+oaaxfQqdzNd4jbicJdpA5ELCTiAvEQ== +"@formio/core@2.1.0-dev.105.1bff2e6": + version "2.1.0-dev.105.1bff2e6" + resolved "https://registry.yarnpkg.com/@formio/core/-/core-2.1.0-dev.105.1bff2e6.tgz#068bf67444641692f3f8037b16ec4c69c033c91e" + integrity sha512-bIbWLn2/Lg6nYKqUYlNDcuF7EH7pIUNUzQBR1XDQ7P0LucK8ukG5Y8A3WOmVtR8S++VShSw8pzapnCytutDA7g== dependencies: "@types/json-logic-js" "^2.0.7" browser-cookies "^1.2.0" core-js "^3.37.1" - dayjs "^1.11.12" - dompurify "^3.1.6" + dayjs "^1.11.11" + dompurify "^3.1.4" eventemitter3 "^5.0.0" fast-json-patch "^3.1.1" fetch-ponyfill "^7.1.0" - inputmask "5.0.9" - json-logic-js "^2.0.5" + inputmask "5.0.8" + json-logic-js "^2.0.2" lodash "^4.17.21" moment "^2.29.4" @@ -2048,10 +2048,10 @@ date-format@^4.0.14: resolved "https://registry.npmjs.org/date-format/-/date-format-4.0.14.tgz#7a8e584434fb169a521c8b7aa481f355810d9400" integrity sha512-39BOQLs9ZjKh0/patS9nrT8wc3ioX3/eA/zgbKNopnF2wCqJEoxywwwElATYvRsXdnOxA/OQeQoFZ3rFjVajhg== -dayjs@^1.11.12: - version "1.11.13" - resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.11.13.tgz#92430b0139055c3ebb60150aa13e860a4b5a366c" - integrity sha512-oaMBel6gjolK862uaPQOVTA7q3TZhuSvuMQAAglQDOWYO9A91IrAOUJEyKVlqJlHE0vq5p5UXxzdPfMH/x6xNg== +dayjs@^1.11.11: + version "1.11.11" + resolved "https://registry.npmjs.org/dayjs/-/dayjs-1.11.11.tgz#dfe0e9d54c5f8b68ccf8ca5f72ac603e7e5ed59e" + integrity sha512-okzr3f11N6WuqYtZSvm+F776mB41wRZMhKP+hc34YdW+KmtYYK9iqvHSwo2k9FEH3fhGXvOPV6yz2IcSrfRUDg== debounce@^1.2.1: version "1.2.1" @@ -2294,6 +2294,11 @@ domexception@^4.0.0: dependencies: webidl-conversions "^7.0.0" +dompurify@^3.1.4: + version "3.1.5" + resolved "https://registry.npmjs.org/dompurify/-/dompurify-3.1.5.tgz#2c6a113fc728682a0f55684b1388c58ddb79dc38" + integrity sha512-lwG+n5h8QNpxtyrJW/gJWckL+1/DQiYMX8f7t8Z2AZTPw1esVrqjI63i7Zc2Gz0aKzLVMYC1V1PL/ky+aY/NgA== + dompurify@^3.1.6: version "3.1.6" resolved "https://registry.yarnpkg.com/dompurify/-/dompurify-3.1.6.tgz#43c714a94c6a7b8801850f82e756685300a027e2" @@ -3969,9 +3974,14 @@ ini@^1.3.4: resolved "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz#a29da425b48806f34767a4efce397269af28432c" integrity sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew== -inputmask@5.0.9, inputmask@^5.0.8: +inputmask@5.0.8: + version "5.0.8" + resolved "https://registry.npmjs.org/inputmask/-/inputmask-5.0.8.tgz#cd0f70b058c3291a0d4f27de25dbfc179c998bb4" + integrity sha512-1WcbyudPTXP1B28ozWWyFa6QRIUG4KiLoyR6LFHlpT4OfTzRqFfWgHFadNvRuMN1S9XNVz9CdNvCGjJi+uAMqQ== + +inputmask@^5.0.8: version "5.0.9" - resolved "https://registry.yarnpkg.com/inputmask/-/inputmask-5.0.9.tgz#7bf4e83f5e199c88c0edf28545dc23fa208ef4be" + resolved "https://registry.npmjs.org/inputmask/-/inputmask-5.0.9.tgz#7bf4e83f5e199c88c0edf28545dc23fa208ef4be" integrity sha512-s0lUfqcEbel+EQXtehXqwCJGShutgieOaIImFKC/r4reYNvX3foyrChl6LOEvaEgxEbesePIrw1Zi2jhZaDZbQ== internal-slot@^1.0.7: @@ -4543,6 +4553,11 @@ json-buffer@3.0.1: resolved "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz#9338802a30d3b6605fbe0613e094008ca8c05a13" integrity sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ== +json-logic-js@^2.0.2: + version "2.0.2" + resolved "https://registry.npmjs.org/json-logic-js/-/json-logic-js-2.0.2.tgz#b613e095f5e598cb78f7b9a2bbf638e74cf98158" + integrity sha512-ZBtBdMJieqQcH7IX/LaBsr5pX+Y5JIW+EhejtM3Ffg2jdN9Iwf+Ht6TbHnvAZ/YtwyuhPaCBlnvzrwVeWdvGDQ== + json-logic-js@^2.0.5: version "2.0.5" resolved "https://registry.yarnpkg.com/json-logic-js/-/json-logic-js-2.0.5.tgz#55f0c687dd6f56b02ccdcfdd64171ed998ab5499" From bdc64e2f07ecd9d0a9baec204e179f11f2adff3b Mon Sep 17 00:00:00 2001 From: Maria-Golomb Date: Fri, 23 Aug 2024 02:37:41 +0300 Subject: [PATCH 6/8] Revert "FIO-8798: update core version" This reverts commit 12a30c3e5abb2b29274f6481f0786cd261f32e8d. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6c4307affd..af40333360 100644 --- a/package.json +++ b/package.json @@ -81,7 +81,7 @@ "dependencies": { "@formio/bootstrap": "3.0.0-dev.98.17ba6ea", "@formio/choices.js": "^10.2.1", - "@formio/core": "2.1.0-dev.140.129711f", + "@formio/core": "2.1.0-dev.105.1bff2e6", "@formio/text-mask-addons": "^3.8.0-formio.2", "@formio/vanilla-text-mask": "^5.1.1-formio.1", "abortcontroller-polyfill": "^1.7.5", From 9e85e8c37db8830fb439689da19718cf918f5c90 Mon Sep 17 00:00:00 2001 From: Maria-Golomb Date: Sat, 24 Aug 2024 14:15:24 +0300 Subject: [PATCH 7/8] FIO-8798: update validation format --- src/components/day/Day.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/components/day/Day.js b/src/components/day/Day.js index 5378c59e51..12c8961c0d 100644 --- a/src/components/day/Day.js +++ b/src/components/day/Day.js @@ -647,6 +647,16 @@ export default class DayComponent extends Field { } getValidationFormat() { - return this.dayFirst ? 'DD-MM-YYYY' : 'MM-DD-YYYY'; + let validationFormat = this.dayFirst ? 'DD-MM-YYYY' : 'MM-DD-YYYY'; + if (this.fields?.day?.hide) { + validationFormat = validationFormat.replace('DD-', ''); + } + if (this.fields?.month?.hide) { + validationFormat = validationFormat.replace('MM-', ''); + } + if ( this.fields?.year?.hide ) { + validationFormat = validationFormat.replace('-YYYY', ''); + } + return validationFormat; } } From f9aca2edd752d8f1869ae7f3aead80e0eb21a565 Mon Sep 17 00:00:00 2001 From: Maria-Golomb Date: Sun, 25 Aug 2024 00:40:46 +0300 Subject: [PATCH 8/8] FIO-8798: update partial day check --- src/components/day/Day.js | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/components/day/Day.js b/src/components/day/Day.js index 12c8961c0d..5ac35d0e3a 100644 --- a/src/components/day/Day.js +++ b/src/components/day/Day.js @@ -634,16 +634,10 @@ export default class DayComponent extends Field { } const [DAY, MONTH, YEAR] = this.component.dayFirst ? [0, 1, 2] : [1, 0, 2]; const values = value.split('/'); - // return (values[DAY] === '00' || values[MONTH] === '00' || values[YEAR] === '0000'); - - - - return (values[DAY] === '00' || - values[MONTH] === '00' || - values[YEAR] === '0000' || - values[DAY] === '' || - values[MONTH] === '' || - values[YEAR] === ''); + if(values.length < 3){ + return true; + } + return (values[DAY] === '00' || values[MONTH] === '00' || values[YEAR] === '0000'); } getValidationFormat() {