From: Olivier Lamy Date: Wed, 29 Feb 2012 18:51:49 +0000 (+0000) Subject: apply filtering on result grid X-Git-Tag: archiva-1.4-M3~1174 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=3ec57c570aa80514ce7c14457a4abc82caea2259;p=archiva.git apply filtering on result grid git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1295212 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js index 16d10f082..bdf45ee41 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js @@ -638,6 +638,32 @@ $(function() { this.includePomArtifacts=ko.observable(false); } + applyAutocompleteOnHeader=function(property,resultViewModel){ + $( "#main-content #search-filter-auto-"+property ).autocomplete({ + minLength: 0, + source: function(request, response){ + var founds=[]; + $(resultViewModel.artifacts()).each(function(idx,artifact){ + if(artifact[property].startsWith(request.term)){ + founds.push(artifact[property]); + } + }); + response(unifyArray(founds,true)); + }, + select: function( event, ui ) { + $.log("property:"+property+','+ui.item.value); + var artifacts=[]; + $(resultViewModel.artifacts()).each(function(idx,artifact){ + if(artifact[property].startsWith(ui.item.value)){ + artifacts.push(artifact); + } + }); + resultViewModel.artifacts(artifacts); + return false; + } + }); + } + ResultViewModel=function(artifacts){ var self=this; this.originalArtifacts=artifacts; @@ -663,7 +689,9 @@ $(function() { ], pageSize: 10, gridUpdateCallBack: function(){ - + applyAutocompleteOnHeader('groupId',self); + applyAutocompleteOnHeader('artifactId',self); + applyAutocompleteOnHeader('version',self); } }); } @@ -734,9 +762,7 @@ $(function() { "simpleGrid: gridViewModel,simpleGridTemplate:'search-results-view-grid-tmpl',pageLinksId:'search-results-view-grid-pagination'"); ko.applyBindings(self.resultViewModel,searchResultsGrid.get(0)); } - applyAutocompleteOnHeader('groupId'); - applyAutocompleteOnHeader('artifactId'); - applyAutocompleteOnHeader('version'); + activateSearchResultsTab(); } }, @@ -753,31 +779,6 @@ $(function() { ); } - applyAutocompleteOnHeader=function(property){ - $( "#main-content #search-filter-auto-"+property ).autocomplete({ - minLength: 1, - source: function(request, response){ - var founds=[]; - $(self.resultViewModel.artifacts()).each(function(idx,artifact){ - if(artifact[property].startsWith(request.term)){ - founds.push(artifact[property]); - } - }); - response(unifyArray(founds,true)); - } - }); - } - - // olamy not used as we cannot filter on className etc... - filterResults=function(){ - var filtered=[]; - for (var i=0;i