From e99c9c92fea6e9dc21c4d82a3b45ad1a8358ad8c Mon Sep 17 00:00:00 2001 From: ZenMasterJacob20011 Date: Wed, 10 Jul 2024 09:48:45 -0500 Subject: [PATCH 1/6] added requiredDayField key to en.js translation file --- src/translations/en.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/translations/en.js b/src/translations/en.js index 1b89a8384e..23710ff1d1 100644 --- a/src/translations/en.js +++ b/src/translations/en.js @@ -73,5 +73,6 @@ export default { reCaptchaTokenNotSpecifiedError: 'ReCAPTCHA: Token is not specified in submission', apiKey: 'API Key is not unique: {{key}}', typeRemaining: '{{ remaining }} {{ type }} remaining.', - typeCount: '{{ count }} {{ type }}' + typeCount: '{{ count }} {{ type }}', + requiredDayField: '{{field}} is required' }; From 5e11157c93568ba440b6c1aae38ea847842b5b9c Mon Sep 17 00:00:00 2001 From: ZenMasterJacob20011 Date: Wed, 10 Jul 2024 10:14:02 -0500 Subject: [PATCH 2/6] added test --- src/components/day/Day.unit.js | 16 +++++++++++- src/components/day/fixtures/comp8.js | 38 ++++++++++++++++++++++++++++ src/components/day/fixtures/index.js | 3 ++- src/translations/en.js | 2 +- 4 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 src/components/day/fixtures/comp8.js diff --git a/src/components/day/Day.unit.js b/src/components/day/Day.unit.js index 313a82f212..56d404c671 100644 --- a/src/components/day/Day.unit.js +++ b/src/components/day/Day.unit.js @@ -11,7 +11,8 @@ import { comp4, comp5, comp6, - comp7 + comp7, + comp8 } from './fixtures'; import PanelComponent from '../panel/Panel'; @@ -265,6 +266,7 @@ describe('Day Component', () => { }, 500); }).catch(done); }); + it('Should translate placeholder text', () => { const element = document.createElement('div'); return Formio.createForm(element, comp7, { @@ -283,4 +285,16 @@ describe('Day Component', () => { assert.equal(dayComponent.refs.year.placeholder, 'Year3'); }) }); + + it('Should translate requiredDayField to {{ field }} is required', (done) => { + Formio.createForm(document.createElement('div'), comp8, {}).then((form) => { + const dayComponent = form.getComponent('dayTable'); + const buttonComponent = form.getComponent('submit'); + buttonComponent.refs.button.click(); + setTimeout(()=>{ + assert.equal(dayComponent.errors[0].message, 'Day - Table is required'); + done(); + },200); + }); + }); }); diff --git a/src/components/day/fixtures/comp8.js b/src/components/day/fixtures/comp8.js new file mode 100644 index 0000000000..e8a9287858 --- /dev/null +++ b/src/components/day/fixtures/comp8.js @@ -0,0 +1,38 @@ +export default { + "components": [ + { + "label": "Day - Table", + "hideInputLabels": false, + "inputsLabelPosition": "top", + "useLocaleSettings": false, + "alwaysEnabled": false, + "tableView": false, + "fields": { + "day": { + "hide": false, + "required": true + }, + "month": { + "hide": false, + "required": true + }, + "year": { + "hide": false, + "required": true + } + }, + "key": "dayTable", + "type": "day", + "input": true + }, + { + "label": "Submit", + "showValidations": false, + "alwaysEnabled": false, + "tableView": false, + "key": "submit", + "type": "button", + "input": true + } + ] +} diff --git a/src/components/day/fixtures/index.js b/src/components/day/fixtures/index.js index a94dca0b41..9b740a1c92 100644 --- a/src/components/day/fixtures/index.js +++ b/src/components/day/fixtures/index.js @@ -5,4 +5,5 @@ import comp4 from './comp4'; import comp5 from './comp5'; import comp6 from './comp6'; import comp7 from './comp7'; -export { comp1, comp2, comp3, comp4, comp5, comp6, comp7 }; +import comp8 from './comp8'; +export { comp1, comp2, comp3, comp4, comp5, comp6, comp7, comp8 }; diff --git a/src/translations/en.js b/src/translations/en.js index 23710ff1d1..ebf893f203 100644 --- a/src/translations/en.js +++ b/src/translations/en.js @@ -74,5 +74,5 @@ export default { apiKey: 'API Key is not unique: {{key}}', typeRemaining: '{{ remaining }} {{ type }} remaining.', typeCount: '{{ count }} {{ type }}', - requiredDayField: '{{field}} is required' + requiredDayField: '{{ field }} is required' }; From fbf1b3d636d1ed514c6ea503a7695305a7464ae0 Mon Sep 17 00:00:00 2001 From: ZenMasterJacob20011 Date: Wed, 10 Jul 2024 11:03:33 -0500 Subject: [PATCH 3/6] test should show proper error message --- src/components/day/Day.unit.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/day/Day.unit.js b/src/components/day/Day.unit.js index 56d404c671..c21f57a624 100644 --- a/src/components/day/Day.unit.js +++ b/src/components/day/Day.unit.js @@ -233,11 +233,11 @@ describe('Day Component', () => { dayComponent.refs.day.dispatchEvent(new Event('input')); setTimeout(() => { - assert(dayComponent._errors.length && dayComponent._errors[0].message === 'requiredDayField', 'Day should be valid while changing'); + assert(dayComponent._errors.length && dayComponent._errors[0].message === 'Day is required', 'Day should be valid while changing'); dayComponent.refs.day.dispatchEvent(new Event('blur')); setTimeout(() => { - assert(dayComponent._errors.length && dayComponent._errors[0].message === 'requiredDayField', 'Should set error after Day component was blurred'); + assert(dayComponent._errors.length && dayComponent._errors[0].message === 'Day is required', 'Should set error after Day component was blurred'); done(); }, 200); }, 200); From 07dacac4a851f90c8a8a5cfed89639fa4ef0ae53 Mon Sep 17 00:00:00 2001 From: ZenMasterJacob20011 Date: Thu, 11 Jul 2024 10:42:55 -0500 Subject: [PATCH 4/6] added translations for month and year fields --- src/translations/en.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/translations/en.js b/src/translations/en.js index ebf893f203..95dcbb2b10 100644 --- a/src/translations/en.js +++ b/src/translations/en.js @@ -74,5 +74,7 @@ export default { apiKey: 'API Key is not unique: {{key}}', typeRemaining: '{{ remaining }} {{ type }} remaining.', typeCount: '{{ count }} {{ type }}', - requiredDayField: '{{ field }} is required' + requiredDayField: '{{ field }} is required', + requiredMonthField: '{{ field }} is required', + requiredYearField: '{{ field }} is required' }; From 32837bca9aa93c0dd418341f666e1b385b5416de Mon Sep 17 00:00:00 2001 From: ZenMasterJacob20011 Date: Wed, 17 Jul 2024 08:56:40 -0500 Subject: [PATCH 5/6] removing translation from formiojs and putting it in core --- src/translations/en.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/translations/en.js b/src/translations/en.js index 95dcbb2b10..1b89a8384e 100644 --- a/src/translations/en.js +++ b/src/translations/en.js @@ -73,8 +73,5 @@ export default { reCaptchaTokenNotSpecifiedError: 'ReCAPTCHA: Token is not specified in submission', apiKey: 'API Key is not unique: {{key}}', typeRemaining: '{{ remaining }} {{ type }} remaining.', - typeCount: '{{ count }} {{ type }}', - requiredDayField: '{{ field }} is required', - requiredMonthField: '{{ field }} is required', - requiredYearField: '{{ field }} is required' + typeCount: '{{ count }} {{ type }}' }; From 925e5445eba8822cc4a41efb59e350d2f9f4d9df Mon Sep 17 00:00:00 2001 From: ZenMasterJacob20011 Date: Wed, 17 Jul 2024 10:43:18 -0500 Subject: [PATCH 6/6] whoops, need to add these translations back --- src/translations/en.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/translations/en.js b/src/translations/en.js index 1b89a8384e..95dcbb2b10 100644 --- a/src/translations/en.js +++ b/src/translations/en.js @@ -73,5 +73,8 @@ export default { reCaptchaTokenNotSpecifiedError: 'ReCAPTCHA: Token is not specified in submission', apiKey: 'API Key is not unique: {{key}}', typeRemaining: '{{ remaining }} {{ type }} remaining.', - typeCount: '{{ count }} {{ type }}' + typeCount: '{{ count }} {{ type }}', + requiredDayField: '{{ field }} is required', + requiredMonthField: '{{ field }} is required', + requiredYearField: '{{ field }} is required' };