86389[TASK] Slim down FormEngine validation module
Commit message
Review
-
Code review CR 0
-
Verified V 0
Issues 1
Files 36
- Build/Sources/TypeScript/backend/form-engine/container/files-control-container.ts+4 −6
- Build/Sources/TypeScript/backend/form-engine/container/flex-form-section-container.ts+0 −1
- Build/Sources/TypeScript/backend/form-engine/container/inline-control-container.ts+4 −6
- Build/Sources/TypeScript/backend/form-engine/container/site-language-container.ts+2 −4
- Build/Sources/TypeScript/backend/form-engine/element/abstract-sortable-select-items.ts+2 −2
- Build/Sources/TypeScript/backend/form-engine/element/color-element.ts+2 −1
- Build/Sources/TypeScript/backend/form-engine/element/datetime-element.ts+2 −1
- Build/Sources/TypeScript/backend/form-engine/evaluation/formatter.tsnew+51 −0
- Build/Sources/TypeScript/backend/form-engine/evaluation/processor.ts5new+186 −0
- Build/Sources/TypeScript/backend/form-engine/field-control/password-generator.ts+2 −1
- Build/Sources/TypeScript/backend/tests/backend/form-engine/evaluation/formatter-test.tsnew+167 −0
- Build/Sources/TypeScript/backend/tests/backend/form-engine/evaluation/processor-test.tsnew+144 −0
- Build/Sources/TypeScript/backend/tests/form-engine-validation-test.tsdeleted+0 −330
- Build/Sources/TypeScript/backend/tests/helper.ts2new+35 −0
- Build/Sources/TypeScript/backend/form-engine-suggest.ts+1 −1
- Build/Sources/TypeScript/backend/form-engine-validation.ts4+22 −306
- Build/Sources/TypeScript/backend/form-engine.ts4+86 −5
- Build/Sources/TypeScript/backend/image-manipulation.ts+2 −2
- Build/Sources/TypeScript/redirects/form-engine-evaluation.ts+2 −2
- Build/web-test-runner.config.mjs+1 −0
Show 16 more files
- typo3/sysext/backend/Resources/Public/JavaScript/form-engine/container/files-control-container.js+1 −1
- typo3/sysext/backend/Resources/Public/JavaScript/form-engine/container/flex-form-section-container.js+1 −1
- typo3/sysext/backend/Resources/Public/JavaScript/form-engine/container/inline-control-container.js+1 −1
- typo3/sysext/backend/Resources/Public/JavaScript/form-engine/container/site-language-container.js+1 −1
- typo3/sysext/backend/Resources/Public/JavaScript/form-engine/element/abstract-sortable-select-items.js+1 −1
- typo3/sysext/backend/Resources/Public/JavaScript/form-engine/element/color-element.js+1 −1
- typo3/sysext/backend/Resources/Public/JavaScript/form-engine/element/datetime-element.js+1 −1
- typo3/sysext/backend/Resources/Public/JavaScript/form-engine/evaluation/formatter.jsnew+13 −0
- typo3/sysext/backend/Resources/Public/JavaScript/form-engine/evaluation/processor.jsnew+13 −0
- typo3/sysext/backend/Resources/Public/JavaScript/form-engine/field-control/password-generator.js+1 −1
- typo3/sysext/backend/Resources/Public/JavaScript/form-engine-suggest.js+1 −1
- typo3/sysext/backend/Resources/Public/JavaScript/form-engine-validation.js+1 −1
- typo3/sysext/backend/Resources/Public/JavaScript/form-engine.js+1 −1
- typo3/sysext/backend/Resources/Public/JavaScript/image-manipulation.js+4 −4
- typo3/sysext/core/Documentation/Changelog/14.0/Deprecation-105184-MethodsInFormEngineValidationModuleExtracted.rstnew+72 −0
- typo3/sysext/redirects/Resources/Public/JavaScript/form-engine-evaluation.js+1 −1
Review log 5184
Show 3859 earlier messages
-
Andreas Kienast uploaded patch set 1 10/01/24, 07:54
-
Andreas Kienast uploaded patch set 2 10/01/24, 07:56
-
core-ci voted on patch set 2 V -1 10/01/24, 08:05 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/66880
-
core-ci voted on patch set 1 V -1 10/01/24, 08:05 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/66879
-
Andreas Kienast uploaded patch set 3
V -110/01/24, 12:54 -
core-ci voted on patch set 3 V -1 10/01/24, 13:01 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/66892
-
Andreas Kienast uploaded patch set 4
V -110/01/24, 13:05 -
core-ci voted on patch set 4 V -1 10/01/24, 13:10 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/66893
-
Andreas Kienast uploaded patch set 5
V -110/01/24, 13:44 -
core-ci voted on patch set 5 V -1 10/01/24, 13:49 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/66897
-
Andreas Kienast uploaded patch set 6
V -110/01/24, 15:13 -
core-ci voted on patch set 6 V -1 10/01/24, 15:18 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/66904
-
Andreas Kienast uploaded patch set 7
V -110/02/24, 07:10 -
core-ci voted on patch set 7 V -1 10/02/24, 07:15 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/66947
-
Andreas Kienast uploaded patch set 8
V -110/02/24, 09:21 -
core-ci voted on patch set 8 V -1 10/02/24, 09:29 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/66959
-
Andreas Kienast uploaded patch set 9
V -110/02/24, 09:45 -
core-ci voted on patch set 9 V +1 10/02/24, 09:53 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/66964
-
Andreas Kienast uploaded patch set 10
V +110/02/24, 10:30 -
Andreas Kienast uploaded patch set 11 10/02/24, 10:31
-
core-ci voted on patch set 10 V -1 10/02/24, 10:36 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/66969
-
core-ci voted on patch set 11 V -1 10/02/24, 10:38 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/66970
-
Andreas Kienast rebased onto patch set 12
V -110/02/24, 10:39 -
core-ci voted on patch set 12 V +1 10/02/24, 10:44 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/66971
-
Markus Klein updated the commit message in patch set 13
V +110/04/24, 11:04 -
Markus Klein commented on patch set 14 10/04/24, 11:10
Published edit on patch set 13. -
Markus Klein voted on patch set 14 CR +1 10/04/24, 11:11
-
core-ci voted on patch set 13 V +1 10/04/24, 11:20 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/67073
-
Andreas Kienast commented on patch set 14 10/04/24, 11:26
Deprecation-105184-MethodsInFormEngineValidationModuleExtracted.rst:21m( -
core-ci voted on patch set 14 V -1 10/04/24, 11:27 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/67074
-
core-ci voted on patch set 14 V +1 10/04/24, 11:42 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/67074
-
Andreas Kienast uploaded patch set 15
CR +1V +110/11/24, 15:01 -
core-ci voted on patch set 15 V +1 10/11/24, 15:08 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/67608
-
Andreas Kienast rebased onto patch set 16
V +110/15/24, 13:10 -
core-ci voted on patch set 16 V +1 10/15/24, 13:16 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/67839
-
Andreas Kienast uploaded patch set 17
V +110/17/24, 08:54 -
core-ci voted on patch set 17 V +1 10/17/24, 09:00 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/67912
-
Ayke Halder commented on patch set 17 10/21/24, 07:53
As the return type of "integer"-processing is changed here: Number-inputs don't give visual feedback of any conversion anymore. User can not be sure the number is stored as intended - especially in Firefox. See for details: * 86660: [BUGFIX] Respect already declared return type in `FormEngineValidation` | https://review.typo3.org/c/Packages/TYPO3.CMS/+/86660form-engine.ts:1381Breaking change here in combination witht the type-change for "integer"-processing.processor.ts:106This implements a change of return type! **Before `number`:** ```js returnValue = Processor.parseInt(value); ``` **Now `string`:** ```js `returnValue = String(Processor.parseInt(value)); ``` -
Andreas Kienast commented on patch set 17 10/21/24, 08:16
processor.ts:106ReplyI will happily remove this again if you can explain me how it could've worked before. `FormEngineValidation.processValue` was declared to return a string, but the `integer` case compiled with a `parseInt`. However, even for number fields, `.value` returns a string-based value, as opposed to `.valueAsNumber.` -
Ayke Halder commented on patch set 17 10/21/24, 08:36
processor.ts:106ReplyIt's all about TypeScript is not Javascript. So Typescript somehow did not recognize the type error. And Javascript does not evaluate any type-hints. You can actually make TypScript recognize this error by introducing types to `FormEngineValidation`. Just checkout the following change on top of the current `main`-branch and TypeScript will recognize the wrong use of `string`/`number` in `Build/Sources/TypeScript/backend/form-engine-validation.ts` (At least PhpStorm recognizes the error.) * 86663: [TASK] Introduce type FormEngineValidationType | https://review.typo3.org/c/Packages/TYPO3.CMS/+/86663 I assume Typescript does not recognize such errors as the use of `any` is really evil: ``` const FormEngineValidation: any = { ``` -
Ayke Halder commented on patch set 17 10/21/24, 08:50
processor.ts:106ReplyJust try this one: 86670: [POC] Introduce type FormEngineValidationType - error string/number | https://review.typo3.org/c/Packages/TYPO3.CMS/+/86670 And `./Build/Scripts/runTests.sh -s buildJavascript` fails with: ``` Sources/TypeScript/backend/form-engine-validation.ts:480:11 - error TS2322: Type 'number' is not assignable to type 'string'. 480 returnValue = FormEngineValidation.parseInt(value); ~~~~~~~~~~~ ``` -
Andreas Kienast uploaded patch set 18
V +110/28/24, 07:37 -
core-ci voted on patch set 18 V +1 10/28/24, 07:42 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/68709
-
Ayke Halder commented on patch set 18 V -1 10/28/24, 16:32
This one breaks the already implemented behaviour of "correctly formatting any number input for integer" in the visible field: See https://review.typo3.org/c/Packages/TYPO3.CMS/+/86660/comment/df4224b4_3d8225bd/ > An acceptance test might look like this: > > Use a form input-element format=integer (e.g. styleguide TCA demo -> elements basic -> tab: number -> field: number_2) > * Put in value 2, then unfocus. > * Check that the value in the visible field is 2. > * Put in value 2.5, then unfocus. > * Check that the value in the visible field is 2 again and not 2.5. > > The hidden input that goes to the database has always the value 2, for both the visible values 2 and 2.5. > > Current state of this change is, that the visible field is not updated, as the hidden value did not change. And thereby the visible value still shows 2.5 - whereas 2 from the hidden field is stored to the databse. -
Andreas Kienast commented on patch set 18 10/28/24, 16:58
Reply
Excuse me? You’re referring to a patch that isn‘t even merged. Claiming it breaks „correctly implemented behavior“ is therefore a false statement. I have the strobg feeling you‘re blocking my patches for the sake of getting yours in first. -
Ayke Halder commented on patch set 18 10/28/24, 17:09
I recommend to get `any` fixed. Not having any `any` in the code will really improve the insights for TypeScript code checks.form-engine-validation.ts:45As this is already a big refactoring: please remove the evil `any` here and add a nice type configuration. Just copy paste the lines from this change, which are still necessary after the refactoring here: https://review.typo3.org/c/Packages/TYPO3.CMS/+/86670form-engine-validation.ts:89Better do not use `any`. E.g. specify `rules` like this: ``` const rules: [{ type: 'required'|'range'|'select'|'category'|'group'|'folder'|'inline'|'min'|'null' minItems?: string|number|null, maxItems?: string|number|null, lower?: string|number|null, upper?: string|number|null }] = JSON.parse(field.dataset.formengineValidationRules); ``` And then make the calculations which do an automatic conversion use the "unary operator" `+`: ``` minItems = +rule.minItems; // instead off `rule.minItems * 1` ```form-engine.ts:49Just get `any`removed and add all the functions with their correct arguments here. These functions are added later on - e.g. `FormEngine.openPopupWindow = function(mode: string, params: string, entryPoint: string): ModalElement {` Therefore we can do a trick and declare them all as optional via question mark `?` - e.g.: `openPopupWindow?: (mode: string, params: string, entryPoint: string) => ModalElement,` This still makes TypeScript correctly check the code for wrongly used types.helper.ts:2Any reason for not activating the type? -
Ayke Halder commented on patch set 18 10/28/24, 17:16
Reply
Get TYPO3 main. Open Firefox and go to any `type=integer` field in the backend. 1. Insert `2` - then unfocus. 2. Insert `2.5` then unfocus. 3. See how it jumps back to showing `2`. With this change here, it does not jump back to `2` - but stays at `2.5`. That's what I mean by breaking „correctly implemented behavior“. ---- I'm always okay with decisions like: "We make this new anyway. We can merge the current state and then improve afterwards, as this is a brand new `main`-branch anyway." But we just have to keep in mind that something will be broken - which needs fixing in the future. -
Andreas Kienast commented on patch set 18 10/28/24, 17:25
Reply
The whole patch is just for extracting stuff. This is step 1. The whole validation will face more smaller refactoring patches, some things will not be there anymore at a later point.helper.ts:2Replyit is a plain extraction from the old code. -
Ayke Halder commented on patch set 18 10/28/24, 17:56
Reply
Then maybe don't change `"integer"`-handling, as this really introduces a change of the UI-behaviour. ** Before:** ``` case 'integer': if (value !== '') { returnValue = FormEngineValidation.parseInt(value); // returnValue is `number` } break; ``` **Introduced with this change:** ``` case 'integer': if (value !== '') { returnValue = String(Processor.parseInt(value)); // returnValue is `string` } break; ``` In combination with this it makes a difference: ``` State before checking: * hidden-field contains value "2" * human-readable-field contains value "2.5" dataHandlerField.value = "2" // `string` newValue = 2 // Before: `number` newValue = "2" // With this change: `string` if (dataHandlerField.value !== newValue) { * Before: this code here is executed. * With this change: this code is not executed. --> Update all the fields with the calculated value. } State after checking: * hidden-field contains value "2" * Before: human-readable-field contains value "2" * With this change: human-readable-field still contains value "2.5" ``` -
Andreas Kienast abandoned the change 10/28/24, 18:13
I give up… -
Ayke Halder commented on patch set 18 10/28/24, 18:35
This change should not be abandoned as the refactoring here really improves the code. I'm open for a talk on why this escalated. You can reach out on Slack. -
Garvin Hicking commented on patch set 18 10/28/24, 19:09
Reply
Really sorry to read this unfold here. I would love to chime in and try to relay (and relax) but I sadly don't understand half of the workings here. 🥴 I do think following up on this approach and getting the first step made would be very helpful, to get more people on board of this beast and be able to improve areas. -
Ayke Halder commented on patch set 18 10/29/24, 19:59
Reply
Outsourced to: 86822: [BUGFIX] Return string in FormEngine `integer` parsing | https://review.typo3.org/c/Packages/TYPO3.CMS/+/86822Comment section cleaned up from things that need theire own changes.Reply
Outsourced to: 86822: [BUGFIX] Return string in FormEngine `integer` parsing | https://review.typo3.org/c/Packages/TYPO3.CMS/+/86822Reply
`"integer"` outsourced to: 86822: [BUGFIX] Return string in FormEngine `integer` parsing | https://review.typo3.org/c/Packages/TYPO3.CMS/+/86822 `any`-fixing is some bigger job for the future.form-engine-validation.ts:45Reply`any`-fixing is some bigger job for the future.form-engine-validation.ts:89Reply`any`-fixing is some bigger job for the future.form-engine.ts:49Reply`any`-fixing is some bigger job for the future.form-engine.ts:1381ReplyOutsourced to: 86822: [BUGFIX] Return string in FormEngine `integer` parsing | https://review.typo3.org/c/Packages/TYPO3.CMS/+/86822processor.ts:106ReplyOutsourced to: 86822: [BUGFIX] Return string in FormEngine `integer` parsing | https://review.typo3.org/c/Packages/TYPO3.CMS/+/86822 -
Andreas Kienast restored the change 10/31/24, 11:58
-
Andreas Kienast uploaded patch set 19
V +110/31/24, 11:58 -
Andreas Kienast uploaded patch set 20 10/31/24, 12:00
-
core-ci voted on patch set 19 V +1 10/31/24, 12:05 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/68916
-
core-ci voted on patch set 20 V +1 10/31/24, 12:08 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/68917
-
Andreas Kienast uploaded patch set 21
V +110/31/24, 12:09
-
core-ci voted on patch set 21 V +1 10/31/24, 12:16 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/68919
-
Andreas Kienast uploaded patch set 22
V +111/20/24, 16:04 -
Andreas Kienast uploaded patch set 23 11/20/24, 16:06
-
core-ci voted on patch set 22 V +1 11/20/24, 16:11 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/69812
-
core-ci voted on patch set 23 V +1 11/20/24, 16:13 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/69813
-
Andreas Kienast uploaded patch set 24
V +111/21/24, 09:16 -
core-ci voted on patch set 24 V +1 11/21/24, 09:24 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/69903
-
Andreas Kienast uploaded patch set 25
V +112/10/24, 15:32 -
core-ci voted on patch set 25 V +1 12/10/24, 15:38 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/70867
-
Andreas Kienast uploaded patch set 26
V +112/11/24, 08:48 -
core-ci voted on patch set 26 V +1 12/11/24, 08:53 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/70897
-
Andreas Kienast uploaded patch set 27
V +112/16/24, 10:01 -
Andreas Kienast uploaded patch set 28 12/16/24, 10:04
-
core-ci voted on patch set 27 V +1 12/16/24, 10:09 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/71176
-
core-ci voted on patch set 28 V +1 12/16/24, 10:10 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/71177
-
Andreas Kienast uploaded patch set 29
V +112/20/24, 10:15 -
core-ci voted on patch set 29 V +1 12/20/24, 10:23 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/71503
-
Andreas Kienast uploaded patch set 30
V +101/15/25, 08:23 -
core-ci voted on patch set 30 V +1 01/15/25, 08:31 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/72507
-
Andreas Kienast uploaded patch set 31
V +101/16/25, 09:09 -
core-ci voted on patch set 31 V +1 01/16/25, 09:17 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/72552
-
Andreas Kienast uploaded patch set 32
V +102/20/25, 16:07 -
core-ci voted on patch set 32 V +1 02/20/25, 16:13 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/74472
-
Andreas Kienast wrote 02/20/25, 16:31
Topic set to FormEngine -
Andreas Kienast abandoned the change 04/01/25, 11:26
There seems to be no common interest.