[TASK] Do not cache results of LiveSearch 98/57398/2
authorAndreas Fernandez <a.fernandez@scripting-base.de>
Wed, 27 Jun 2018 16:50:13 +0000 (18:50 +0200)
committerAndreas Fernandez <a.fernandez@scripting-base.de>
Thu, 28 Jun 2018 06:39:31 +0000 (08:39 +0200)
Resolves: #85412
Releases: master, 8.7
Change-Id: I7cac1b53f9cc7c7fa3c6c9e1752b7b2513d39c5d
Reviewed-on: https://review.typo3.org/57398
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Josef Glatz <josef.glatz@typo3.org>
Reviewed-by: Josef Glatz <josef.glatz@typo3.org>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
typo3/sysext/backend/Resources/Private/TypeScript/LiveSearch.ts
typo3/sysext/backend/Resources/Public/JavaScript/LiveSearch.js

index e71b8b1..50ab371 100644 (file)
@@ -74,6 +74,7 @@ class LiveSearch {
       minChars: 2,
       width: '100%',
       groupBy: 'typeLabel',
+      noCache: true,
       containerClass: Identifiers.toolbarItem.substr(1, Identifiers.toolbarItem.length),
       appendTo: Identifiers.containerSelector + ' .dropdown-menu',
       forceFixPosition: false,
index 1b74d98..4219624 100644 (file)
@@ -10,4 +10,4 @@
  *
  * The TYPO3 project - inspiring people to share!
  */
-define(["require","exports","jquery","./Viewport","./Icons","jquery/autocomplete","TYPO3/CMS/Backend/jquery.clearable"],function(e,t,o,a,r){"use strict";var n,l;return(l=n||(n={})).containerSelector="#typo3-cms-backend-backend-toolbaritems-livesearchtoolbaritem",l.toolbarItem=".t3js-toolbar-item-search",l.dropdownToggle=".t3js-toolbar-search-dropdowntoggle",l.searchFieldSelector=".t3js-topbar-navigation-search-field",l.formSelector=".t3js-topbar-navigation-search",new(function(){function e(){var e=this;this.url=TYPO3.settings.ajaxUrls.livesearch,a.Topbar.Toolbar.registerEvent(function(){e.registerAutocomplete(),e.registerEvents(),o(n.toolbarItem).removeAttr("style"),o(n.searchFieldSelector).clearable({onClear:function(){o(n.toolbarItem).hasClass("open")&&o(n.dropdownToggle).dropdown("toggle")}})})}return e.prototype.registerAutocomplete=function(){o(n.searchFieldSelector).autocomplete({serviceUrl:this.url,paramName:"q",dataType:"json",minChars:2,width:"100%",groupBy:"typeLabel",containerClass:n.toolbarItem.substr(1,n.toolbarItem.length),appendTo:n.containerSelector+" .dropdown-menu",forceFixPosition:!1,preserveInput:!0,showNoSuggestionNotice:!0,triggerSelectOnValidInput:!1,preventBadQueries:!1,noSuggestionNotice:'<h3 class="dropdown-headline">'+TYPO3.lang.liveSearch_listEmptyText+"</h3><p>"+TYPO3.lang.liveSearch_helpTitle+"</p><hr><p>"+TYPO3.lang.liveSearch_helpDescription+"<br>"+TYPO3.lang.liveSearch_helpDescriptionPages+"</p>",transformResult:function(e){return{suggestions:o.map(e,function(e){return{value:e.title,data:e}})}},formatGroup:function(e,t,o){var a="";return o>0&&(a="<hr>"),a+'<h3 class="dropdown-headline">'+t+"</h3>"},formatResult:function(e){return'<div class="dropdown-table"><div class="dropdown-table-row"><div class="dropdown-table-column dropdown-table-icon">'+e.data.iconHTML+'</div><div class="dropdown-table-column dropdown-table-title"><a class="dropdown-table-title-ellipsis dropdown-list-link" href="#" data-pageid="'+e.data.pageId+'" data-target="'+e.data.editLink+'">'+e.data.title+"</a></div></div></div>"},onSearchStart:function(){var e=o(n.toolbarItem);e.hasClass("loading")||(e.addClass("loading"),r.getIcon("spinner-circle-light",r.sizes.small,"",r.states.default,r.markupIdentifiers.inline).done(function(t){e.find(".icon-apps-toolbar-menu-search").replaceWith(t)}))},onSearchComplete:function(){var e=o(n.toolbarItem),t=o(n.searchFieldSelector);!e.hasClass("open")&&t.val().length>1&&(o(n.dropdownToggle).dropdown("toggle"),t.focus()),e.hasClass("loading")&&(e.removeClass("loading"),r.getIcon("apps-toolbar-menu-search",r.sizes.small,"",r.states.default,r.markupIdentifiers.inline).done(function(t){e.find(".icon-spinner-circle-light").replaceWith(t)}))},beforeRender:function(e){e.append('<hr><div><a href="#" class="btn btn-primary pull-right t3js-live-search-show-all">'+TYPO3.lang.liveSearch_showAllResults+"</a></div>"),o(n.toolbarItem).hasClass("open")||(o(n.dropdownToggle).dropdown("toggle"),o(n.searchFieldSelector).focus())},onHide:function(){o(n.toolbarItem).hasClass("open")&&o(n.dropdownToggle).dropdown("toggle")}})},e.prototype.registerEvents=function(){var e=o(n.searchFieldSelector);(o(n.containerSelector).on("click",".t3js-live-search-show-all",function(t){t.preventDefault(),TYPO3.ModuleMenu.App.showModule("web_list","id=0&search_levels=-1&search_field="+encodeURIComponent(e.val())),e.val("").trigger("change")}),e.length)&&o("."+e.autocomplete().options.containerClass).on("click.autocomplete",".dropdown-list-link",function(t){t.preventDefault();var a=o(t.currentTarget);top.jump(a.data("target"),"web_list","web",a.data("pageid")),e.val("").trigger("change")});o(n.formSelector).on("submit",function(e){e.preventDefault()})},e}())});
\ No newline at end of file
+define(["require","exports","jquery","./Viewport","./Icons","jquery/autocomplete","TYPO3/CMS/Backend/jquery.clearable"],function(e,t,o,a,r){"use strict";var n,l;return(l=n||(n={})).containerSelector="#typo3-cms-backend-backend-toolbaritems-livesearchtoolbaritem",l.toolbarItem=".t3js-toolbar-item-search",l.dropdownToggle=".t3js-toolbar-search-dropdowntoggle",l.searchFieldSelector=".t3js-topbar-navigation-search-field",l.formSelector=".t3js-topbar-navigation-search",new(function(){function e(){var e=this;this.url=TYPO3.settings.ajaxUrls.livesearch,a.Topbar.Toolbar.registerEvent(function(){e.registerAutocomplete(),e.registerEvents(),o(n.toolbarItem).removeAttr("style"),o(n.searchFieldSelector).clearable({onClear:function(){o(n.toolbarItem).hasClass("open")&&o(n.dropdownToggle).dropdown("toggle")}})})}return e.prototype.registerAutocomplete=function(){o(n.searchFieldSelector).autocomplete({serviceUrl:this.url,paramName:"q",dataType:"json",minChars:2,width:"100%",groupBy:"typeLabel",noCache:!0,containerClass:n.toolbarItem.substr(1,n.toolbarItem.length),appendTo:n.containerSelector+" .dropdown-menu",forceFixPosition:!1,preserveInput:!0,showNoSuggestionNotice:!0,triggerSelectOnValidInput:!1,preventBadQueries:!1,noSuggestionNotice:'<h3 class="dropdown-headline">'+TYPO3.lang.liveSearch_listEmptyText+"</h3><p>"+TYPO3.lang.liveSearch_helpTitle+"</p><hr><p>"+TYPO3.lang.liveSearch_helpDescription+"<br>"+TYPO3.lang.liveSearch_helpDescriptionPages+"</p>",transformResult:function(e){return{suggestions:o.map(e,function(e){return{value:e.title,data:e}})}},formatGroup:function(e,t,o){var a="";return o>0&&(a="<hr>"),a+'<h3 class="dropdown-headline">'+t+"</h3>"},formatResult:function(e){return'<div class="dropdown-table"><div class="dropdown-table-row"><div class="dropdown-table-column dropdown-table-icon">'+e.data.iconHTML+'</div><div class="dropdown-table-column dropdown-table-title"><a class="dropdown-table-title-ellipsis dropdown-list-link" href="#" data-pageid="'+e.data.pageId+'" data-target="'+e.data.editLink+'">'+e.data.title+"</a></div></div></div>"},onSearchStart:function(){var e=o(n.toolbarItem);e.hasClass("loading")||(e.addClass("loading"),r.getIcon("spinner-circle-light",r.sizes.small,"",r.states.default,r.markupIdentifiers.inline).done(function(t){e.find(".icon-apps-toolbar-menu-search").replaceWith(t)}))},onSearchComplete:function(){var e=o(n.toolbarItem),t=o(n.searchFieldSelector);!e.hasClass("open")&&t.val().length>1&&(o(n.dropdownToggle).dropdown("toggle"),t.focus()),e.hasClass("loading")&&(e.removeClass("loading"),r.getIcon("apps-toolbar-menu-search",r.sizes.small,"",r.states.default,r.markupIdentifiers.inline).done(function(t){e.find(".icon-spinner-circle-light").replaceWith(t)}))},beforeRender:function(e){e.append('<hr><div><a href="#" class="btn btn-primary pull-right t3js-live-search-show-all">'+TYPO3.lang.liveSearch_showAllResults+"</a></div>"),o(n.toolbarItem).hasClass("open")||(o(n.dropdownToggle).dropdown("toggle"),o(n.searchFieldSelector).focus())},onHide:function(){o(n.toolbarItem).hasClass("open")&&o(n.dropdownToggle).dropdown("toggle")}})},e.prototype.registerEvents=function(){var e=o(n.searchFieldSelector);(o(n.containerSelector).on("click",".t3js-live-search-show-all",function(t){t.preventDefault(),TYPO3.ModuleMenu.App.showModule("web_list","id=0&search_levels=-1&search_field="+encodeURIComponent(e.val())),e.val("").trigger("change")}),e.length)&&o("."+e.autocomplete().options.containerClass).on("click.autocomplete",".dropdown-list-link",function(t){t.preventDefault();var a=o(t.currentTarget);top.jump(a.data("target"),"web_list","web",a.data("pageid")),e.val("").trigger("change")});o(n.formSelector).on("submit",function(e){e.preventDefault()})},e}())});
\ No newline at end of file