[BUGFIX] Import Selection with TYPO3 Element Browser 06/39906/2
authorFrank Nägler <typo3@naegler.net>
Tue, 26 May 2015 14:07:56 +0000 (16:07 +0200)
committerMarkus Klein <markus.klein@typo3.org>
Wed, 3 Jun 2015 21:29:50 +0000 (23:29 +0200)
This patch fixes the "Import Selection" link in the element browser.

Resolves: #47322
Releases: master, 6.2
Change-Id: Ic9b7ed37f0bd25d47e6b97036e1244b97b218f3b
Reviewed-on: http://review.typo3.org/39906
Reviewed-by: Frank Nägler <typo3@naegler.net>
Tested-by: Frank Nägler <typo3@naegler.net>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
typo3/js/browse_links.js
typo3/sysext/recordlist/Classes/Browser/ElementBrowser.php

index 7e1f0b8..9933efa 100644 (file)
@@ -49,12 +49,12 @@ BrowseLinks.File = {
        },
        insertElementMultiple: function(list) {
                var uidList = [];
-               list.each(function(index) {
-                       if (typeof BrowseLinks.elements[index] !== undefined) {
-                               var element = BrowseLinks.elements[index];
+               for (var i = 0, n = list.length; i < n; i++) {
+                       if (typeof BrowseLinks.elements[list[i]] !== undefined) {
+                               var element = BrowseLinks.elements[list[i]];
                                uidList.push(element.uid);
                        }
-               });
+               }
                insertMultiple('sys_file', uidList);
                return true;
        }
@@ -80,10 +80,17 @@ BrowseLinks.Selector = {
                                        selectedItems.push(item.name);
                                }
                        });
-                       if (selectedItems.length == 1) {
-                               BrowseLinks.File.insertElement(selectedItems[0]);
-                       } else {
-                               BrowseLinks.File.insertElementMultiple(selectedItems);
+                       if (selectedItems.length > 0) {
+                               // The variable _hasActionMultipleCode is set in ElementBrowser.php.
+                               // This is a workaround to get multiple selection working with
+                               // IRRE and groups fields.
+                               if (typeof _hasActionMultipleCode !== 'undefined' && _hasActionMultipleCode) {
+                                        BrowseLinks.File.insertElementMultiple(selectedItems);
+                               } else {
+                                       for (var i = 0; i < selectedItems.length; i++) {
+                                               BrowseLinks.File.insertElement(selectedItems[i]);
+                                       }
+                               }
                        }
                        BrowseLinks.focusOpenerAndClose(true);
                }
index 80c2352..b9742b4 100644 (file)
@@ -761,6 +761,7 @@ class ElementBrowser {
                                }
                                return false;
                        }
+                       var _hasActionMultipleCode = ' . (!empty($JScodeActionMultiple) ? 'true' : 'false') . ';
                        function insertMultiple(table, uid) {
                                var type = "";
                                                ' . $JScodeActionMultiple . '