Review main Abandoned

49690[FEATURE] Allow TCA user elements to add JavaScript

Robert Vock CR 0 V 0 Easy +33 −2 updated 09/02/18, 22:44

Commit message

TCA UserElements can now add JavaScript like other TCA elements.
They can add RequireJsModules to the parameter resultArray.

Review

  • Code review CR 0
  • Verified V 0

Issues 1

Files 2

Review log 4049

Show 1924 earlier messages
  1. Robert Vock uploaded patch set 1 08/31/16, 15:35

  2. TYPO3com voted on patch set 1 V +1 08/31/16, 15:38 Completed build in 02m 38s on Wed, 31 Aug, 05:38 PM Test Summary: 18650 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-2539

  3. Mathias Brodala commented on patch set 1 09/01/16, 07:27

    UserElement.php:40

    How about allowing "userFunc" to alternatively return an array which would then be used as $resultArray? 3rd party code will need to be adapted in any case.
  4. Robert Vock commented on patch set 1 09/01/16, 08:42

    UserElement.php:40 Reply

    I think returning an array would also be okay. But then the code must ensure, that the array contains at least the fields generated by initializeResultArray. But a simple array_merge should suffice.
  5. Robert Vock uploaded patch set 2 09/01/16, 09:02

  6. TYPO3com voted on patch set 2 V +1 09/01/16, 09:06 Completed build in 03m 34s on Thu, 1 Sep, 11:06 AM Test Summary: 19100 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-2600

  7. Mathias Brodala commented on patch set 2 09/01/16, 09:46

    Since this now a FEATURE, could you tag it accordingly and add a RST describing the array return option?
  8. Andreas Kienast commented on patch set 2 09/01/16, 09:47

    Reply

    Why is this now a feature? I read BUGFIX.
  9. Mathias Brodala commented on patch set 2 09/01/16, 09:59

    Reply

    OK, one could argue that this was possible before the FormEngine rewrite and dropping that was a bug which is fixed with this. Still an important RST should be added to point to this new option.
  10. Robert Vock updated the commit message in patch set 3 09/01/16, 11:17

  11. TYPO3com voted on patch set 3 V +1 09/01/16, 11:20 Completed build in 02m 37s on Thu, 1 Sep, 01:20 PM Test Summary: 19102 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-2622

  12. Andreas Kienast commented on patch set 3 09/01/16, 11:33

    I'd stick to "Bugfix", as Features can't be backported to 7.6
  13. Philipp Gampe updated the commit message in patch set 4 09/01/16, 11:45

  14. Philipp Gampe commented on patch set 4 09/01/16, 11:46

    Still needs a rst documentation
  15. TYPO3com voted on patch set 4 V +1 09/01/16, 11:48 Completed build in 02m 45s on Thu, 1 Sep, 01:48 PM Test Summary: 19102 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-2626

  16. Robert Vock commented on patch set 4 09/01/16, 11:56

    Where should I post the documentation? Is it correct to add it via a PullRequest on github to TCA-documentation: https://github.com/TYPO3-Documentation/TYPO3CMS-Reference-TCA/blob/latest/Documentation/Reference/Columns/User/Index.rst Then I would create a pull request with the following text: The function should return either a string with the HTML for the user element or an array with an html-key. Using an array you can also add RequireJS-modules and stylesheets: <code>return [ 'html' => '[html code for custom element]', 'stylesheetFiles' => [ \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('example') . 'Resources/Public/Css/user-element.css' ], 'requireJsModules' => [ 'TYPO3/CMS/Example/UserElement' ], ];</code>
  17. Robert Vock uploaded patch set 5 09/01/16, 12:25

  18. TYPO3com voted on patch set 5 V +1 09/01/16, 12:27 Completed build in 02m 41s on Thu, 1 Sep, 02:27 PM Test Summary: 19102 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-2629

  19. Stefan Neufeind commented on patch set 5 CR -1 09/01/16, 15:29

    Can we make it backward-compatible by assigning it to "html" if a string is returned by the function and otherwise merge the array as you suggest here? An option would be to deprecate the non-array returnvalue of the function then if you like. As it is a feature it definitely won't go into 7.6 but only master.
  20. Mathias Brodala commented on patch set 5 09/02/16, 07:25

    > As it is a feature it definitely won't go into 7.6 but only master. Since TYPO3 does not follow semver (see https://forge.typo3.org/issues/77708), this feature may very well go into 7.6. The risk of breakage is basically non-existent.
  21. Andreas Kienast commented on patch set 5 09/02/16, 07:37

    No, we do NOT backport Features to already released branches, unless there is a really good reason for this. This has NOTHING to do with semver!
  22. Mathias Brodala commented on patch set 5 09/02/16, 07:38

    > No, we do NOT backport Features to already released branches, > unless there is a really good reason for this. This has NOTHING to > do with semver! There is a good reason: this is not only a feature (allowing "user" nodes to customize the full $resultArray) but also a bugfix: adding JavaScript was possible in 6.2 but was gone with 7.6.
  23. Philipp Gampe uploaded patch set 6 09/02/16, 23:57

  24. Philipp Gampe updated the commit message in patch set 7 09/02/16, 23:59

  1. TYPO3com voted on patch set 6 V +1 09/03/16, 00:01 Completed build in 03m 14s on Sat, 3 Sep, 02:01 AM Test Summary: 18506 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-2816

  2. Philipp Gampe commented on patch set 7 CR +1 V +1 09/03/16, 00:01

    Also approved by Lolli. Backport for 7 ist OK, however users are encouraged to use the new custom TCA element features instead.
  3. TYPO3com voted on patch set 7 V +1 09/03/16, 00:02 Completed build in 03m 24s on Sat, 3 Sep, 02:02 AM Test Summary: 18506 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-2817

  4. Robert Vock commented on patch set 7 09/05/16, 07:01

    @Philipp: What are custom TCA elements? I couldn't find anything about them in the TCA reference. I only see the user-element.
  5. Stefan Neufeind voted on patch set 7 CR +1 09/05/16, 07:27

  6. Philipp Gampe commented on patch set 7 09/05/16, 16:21

  7. Georg Ringer commented on patch set 7 09/05/16, 20:08

    Important-75652-AllowTCAUserElementsToAddJavaScript.rst:2

    I would make that feature instead and mark the previous as deprecated + rst. no need to support both variants in the long run
  8. Nicole Hummel commented on patch set 7 CR -2 09/08/16, 22:13

    IMHO the user element is not the way we want the FormEngine to be used. I would recommend to add an own type for that with the possibility to use the full range or resultArray. Please let Christian decide about this change.
  9. Nicole Hummel commented on patch set 7 CR -1 09/09/16, 18:03

    After spoken to Christian, I'll not block this patch. But by reading the issue in forge ticket and seeing the code changes in this patch, I still think this is the wrong way to go. The FormEngine was designed to be more flexible with own TCA types and render functions. IMHO the user type should have been deprecated with this change before but wasn't. Now adding even more functionality to that element and open another way to deal with own (kind of) TCA types seems totally wrong to me. We had same problems (different ways to archive the same solution) multiple times already in the core and noticed how hard it was/is to deprecated functionality. This patch enhance the API in a not needed way. You have to adjust the user function anyway, why not just using FormEngine API a right way then?
  10. Nicole Hummel commented on patch set 7 09/09/16, 18:03

    By the way, I think this isn't any bugfix and should not be backported to 7.6
  11. Helmut Hummel commented on patch set 7 09/09/16, 18:11

    This is marked as bugfix…
    …while linking to a ticket which is marked as feature
  12. Philipp Gampe commented on patch set 7 09/10/16, 12:30

    @Nicole This is a bugfix, because the functionality was there before the form engine refactoring. Nevertheless, we should deprecate this user element in favor of the new way (documented where?). Would you be so kind and push a independent deprecation patch?
  13. Philipp Gampe commented on patch set 7 09/10/16, 12:31

    Important-75652-AllowTCAUserElementsToAddJavaScript.rst:2 Reply

    I changed it from feature to important after talking to Lolli. The functionality was possible before and should go through proper deprecation. This is why this needs backporting to 7.6 too.
  14. Nicole Hummel commented on patch set 7 09/12/16, 18:14

    @Philipp: Have you ever noticed that due to the FormEngine changes the whole parameter array, passed to the user function, changed!? You can easily check that with debugging \TYPO3\CMS\Core\Resource\Hook\FileInfoHook::renderFileMetadataInfo. There wasn't any proper deprecation with the FormEngine patch before
  15. Benni Mack commented on patch set 7 CR -1 12/27/17, 14:56

    This is actually not a bugfix, but a breaking change (different return type!), so I suggest we should drop this patch (as Nicole suggested) and leave it up to the ext authors to develop their own custom element, that's the way people should use FormEngine nowadays.
  16. Stefan Neufeind commented on patch set 7 12/28/17, 11:54

    @Benni: Philipp mentioned that it was possible fore (didn't check yet) and that it would be re-enabling that possibility. It was a "feature" before
  17. Reiner Teubner uploaded patch set 8 02/07/18, 14:44

  18. Reiner Teubner commented on patch set 8 CR -1 02/07/18, 14:46

    Rebase merge conflict. Code-Review -1 Nicole Cordes -1 Benni Mack +1 Philipp Gampe +1 Stefan Neufeind Verified +1 Philipp Gampe Note: Since the last commit the render function change (https://review.typo3.org/51151). Last Commit diff of render() public function render() { $parameterArray = $this->data['parameterArray']; $parameterArray['table'] = $this->data['tableName']; $parameterArray['field'] = $this->data['fieldName']; $parameterArray['row'] = $this->data['databaseRow']; $parameterArray['parameters'] = isset($parameterArray['fieldConf']['config']['parameters']) ? $parameterArray['fieldConf']['config']['parameters'] : []; $resultArray = $this->initializeResultArray(); -- $resultArray['html'] = GeneralUtility::callUserFunction( ++ $result = GeneralUtility::callUserFunction( $parameterArray['fieldConf']['config']['userFunc'], $parameterArray, $this ); ++ if (is_array($result)) { ++ $resultArray = array_merge($resultArray, $result); ++ } else { ++ $resultArray['html'] = $result; ++ } return $resultArray; }
  19. TYPO3com voted on patch set 8 V -1 02/07/18, 14:52 Completed build in 08m 15s on Wed, 7 Feb, 03:52 PM Test Summary: 30458 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-19075

  20. Reiner Teubner uploaded patch set 9 02/07/18, 15:09

  21. Reiner Teubner voted on patch set 9 CR -1 02/07/18, 15:09

  22. TYPO3com voted on patch set 9 V +1 02/07/18, 15:18 Completed build in 08m 31s on Wed, 7 Feb, 04:18 PM Test Summary: 30458 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-19076

  23. Helmut Hummel wrote 07/23/18, 18:16

    Removed reviewer Helmut Hummel.
  24. Christian Kuhn commented on patch set 9 09/02/18, 22:44

    ok, i had a look at all three none/user/passthrough types again and already improved the tca ref docs of type=none a bit. in the end, it is much easier to just deprecate all properties from type=user (userFunc, parameters and noTableWrapping), and just document that people should use an own renderType if using type=user. this is much more flexible and better than the currently limited way of the userFunc stuff. i'll thus finally abandon this patch and will come up with a small series of patches dealing with none, user and passthrough details and improved documentation.
  25. Christian Kuhn abandoned the change 09/02/18, 22:44