[TASK] Add a reset search link to filelist searchfield 41/43541/6
authorWouter Wolters <typo3@wouterwolters.nl>
Thu, 24 Sep 2015 20:03:24 +0000 (22:03 +0200)
committerAndreas Fernandez <typo3@scripting-base.de>
Fri, 25 Sep 2015 07:10:57 +0000 (09:10 +0200)
Resolves: #70088
Releases: master
Change-Id: Ifcaa88838d1d87c8942021ca736a4f20bc798fa9
Reviewed-on: http://review.typo3.org/43541
Reviewed-by: Josef Glatz <jousch@gmail.com>
Tested-by: Josef Glatz <jousch@gmail.com>
Reviewed-by: Daniel Goerz <ervaude@gmail.com>
Tested-by: Daniel Goerz <ervaude@gmail.com>
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Tested-by: Andreas Fernandez <typo3@scripting-base.de>
typo3/sysext/filelist/Classes/Controller/FileListController.php
typo3/sysext/filelist/Resources/Public/JavaScript/FileSearch.js [new file with mode: 0644]

index 66c76f5..fe01fec 100644 (file)
@@ -308,7 +308,7 @@ class FileListController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControl
                // There there was access to this file path, continue, make the list
                if ($this->folderObject) {
 
-                       $requireJsModules = ['TYPO3/CMS/Filelist/FileListLocalisation'];
+                       $requireJsModules = ['TYPO3/CMS/Filelist/FileListLocalisation', 'TYPO3/CMS/Filelist/FileSearch'];
                        $addJsInlineLabels = [];
 
                        // Create filelisting object
@@ -441,7 +441,7 @@ class FileListController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControl
                        }
                }
 
-               $this->view->assign('requireJsModules', ['TYPO3/CMS/Filelist/FileList']);
+               $this->view->assign('requireJsModules', ['TYPO3/CMS/Filelist/FileList', 'TYPO3/CMS/Filelist/FileSearch']);
                $this->view->assign('searchWord', $searchWord);
                $this->view->assign('files', $fileFacades);
                $this->view->assign('settings', [
diff --git a/typo3/sysext/filelist/Resources/Public/JavaScript/FileSearch.js b/typo3/sysext/filelist/Resources/Public/JavaScript/FileSearch.js
new file mode 100644 (file)
index 0000000..fa153e5
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+/**
+ *  JavaScript for file search
+ */
+define('TYPO3/CMS/Filelist/FileSearch', ['jquery', 'TYPO3/CMS/Backend/jquery.clearable'], function($) {
+
+       var $searchFields = $('input[name="tx_filelist_file_filelistlist[searchWord]"]');
+       var searchResultShown = ('' !== $searchFields.first().val());
+
+       // make search field clearable
+       $searchFields.clearable({
+               onClear: function() {
+                       if (searchResultShown) {
+                               $(this).closest('form').submit();
+                       }
+               }
+       });
+
+});
\ No newline at end of file