[BUGFIX] Prevent error for tree in flexform 75/50275/4
authorFrank Naegler <frank.naegler@typo3.org>
Wed, 19 Oct 2016 15:08:02 +0000 (17:08 +0200)
committerWouter Wolters <typo3@wouterwolters.nl>
Thu, 20 Oct 2016 20:11:36 +0000 (22:11 +0200)
This patch prevent JS errors in case a tree is rendered in a FlexForm,
before the record was saved for the first time. In this case the data
can’t be loaded and we display a message.

This is a bit hacky but at the moment the best way to fix the issue.

Resolves: #78350
Releases: master
Change-Id: Ic11ae6e5c22711fe9a10fe3287b015ea1d87a30f
Reviewed-on: https://review.typo3.org/50275
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
typo3/sysext/backend/Resources/Public/JavaScript/FormEngine/Element/SvgTree.js
typo3/sysext/lang/locallang_csh_corebe.xlf

index 804223e..f4bd5ac 100644 (file)
@@ -187,6 +187,12 @@ define(['jquery', 'd3'], function ($, d3) {
             var me = this;
             d3.json(this.settings.dataUrl, function (error, json) {
                 if (error) throw error;
+                if (json === null) {
+                    var $container = $(me.wrapper).closest('.t3js-formengine-field-item');
+                    $container.hide();
+                    $container.parent().append('<p class="text-danger">' + TYPO3.lang['tcatree.msg_save_first'] + '</p>');
+                    return;
+                }
                 if (Array.isArray(json)) {
                     //little hack, so we can use json structure prepared by ExtJsJsonTreeRenderer
                     json = json[0];
index 1d39238..a1c0cb8 100644 (file)
@@ -162,6 +162,9 @@ If you click the folder title in the Folder Tree you will see the sub-module loa
                        <trans-unit id="tcatree.findItem">
                                <source>Find Item</source>
                        </trans-unit>
+                       <trans-unit id="tcatree.msg_save_first">
+                               <source>Please save the content element before selecting a category.</source>
+                       </trans-unit>
                        <trans-unit id="list_module.alttitle">
                                <source>The Web&gt;List module</source>
                        </trans-unit>