From c21bb53a98f8eb397f5acbc0865707bc641741b5 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Mon, 5 Mar 2012 08:45:33 +0000 Subject: [PATCH] autocomplete in browse is now from the current groupId git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1296966 13f79535-47bb-0310-9956-ffa450edef68 --- .../archiva-web/archiva-webapp-js/pom.xml | 4 +- .../src/main/webapp/js/archiva/search.js | 59 ++++++++++++------- .../webapp/js/archiva/templates/search.html | 8 ++- 3 files changed, 49 insertions(+), 22 deletions(-) diff --git a/archiva-modules/archiva-web/archiva-webapp-js/pom.xml b/archiva-modules/archiva-web/archiva-webapp-js/pom.xml index 8d0f2ec06..6a187e35e 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/pom.xml +++ b/archiva-modules/archiva-web/archiva-webapp-js/pom.xml @@ -767,7 +767,9 @@ + todir="${project.build.directory}/target/"/> + 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 130b05ffb..17e7057a7 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 @@ -100,6 +100,7 @@ $(function() { var browseViewModel = new BrowseViewModel(browseResultEntries,parentBrowseViewModel,groupId); ko.applyBindings(browseViewModel,browseBreadCrumb.get(0)); ko.applyBindings(browseViewModel,browseResult.get(0)); + enableAutocompleBrowse(groupId); } }); } @@ -178,26 +179,40 @@ $(function() { var browseViewModel = new BrowseViewModel(browseResultEntries,null,null); ko.applyBindings(browseViewModel,mainContent.find("#browse_breadcrumb").get(0)); ko.applyBindings(browseViewModel,mainContent.find("#browse_result").get(0)); + enableAutocompleBrowse(); } }); - enableAutocompleBrowse(); + } - enableAutocompleBrowse=function(){ + enableAutocompleBrowse=function(groupId){ // browse-autocomplete + var url="restServices/archivaServices/browseService/rootGroups"; + if (groupId){ + url="restServices/archivaServices/browseService/browseGroupId/"+encodeURIComponent(groupId); + } $( "#main-content #browse-autocomplete" ).autocomplete({ - minLength: 3, + minLength: 2, source: function(request, response){ var query = ""; - if (request.term.indexOf('.')<0){ + if (request.term.indexOf('.')<0&&!groupId){ // try with rootGroups then filtered - $.get("restServices/archivaServices/browseService/rootGroups", + $.get(url, function(data) { var browseResultEntries = mapbrowseResultEntries(data); + var filetered = []; for(var i=0;i=0){ - if (dotEnd){ - query= request.term.substring(0, request.term.length-1); + if (request.term.indexOf(".")>=0){ + if (dotEnd){ + query= groupId?groupId+'.'+request.term.substring(0, request.term.length-1):request.term.substring(0, request.term.length-1); + } else { + // substring before last + query=groupId?groupId+'.'+request.term.substringBeforeLast("."):request.term.substringBeforeLast("."); + } } else { - // substring before last - query=request.term.substringBeforeLast("."); + query=groupId?groupId:request.term; } - } else { - query=request.term; - } $.get("restServices/archivaServices/browseService/browseGroupId/"+encodeURIComponent(query), function(data) { var browseResultEntries = mapbrowseResultEntries(data); @@ -227,8 +242,14 @@ $(function() { } else { var filetered = []; for(var i=0;i" ) .data( "item.autocomplete", item ) - .append( "" + item.name + "" ) + .append( groupId ? "" + item.name.substring(groupId.length+1, item.name.length) + "": "" + item.name + "" ) .appendTo( ul ); }; } /** - * called if browser url contains queryParam browse=groupId + * * @param groupId */ displayBrowseGroupIdFromAutoComplete=function(groupId){ @@ -274,7 +295,6 @@ $(function() { mainContent.find("#browse_result").html(mediumSpinnerImg()); var parentBrowseViewModel=new BrowseViewModel(null,null,null); displayGroupDetail(groupId,parentBrowseViewModel,null); - enableAutocompleBrowse(); } /** @@ -289,7 +309,6 @@ $(function() { mainContent.find("#browse_result").html(mediumSpinnerImg()); var parentBrowseViewModel=new BrowseViewModel(null,null,null); displayGroupDetail(groupId,parentBrowseViewModel,null); - enableAutocompleBrowse(); } diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/search.html b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/search.html index c55651366..3ca8e4711 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/search.html +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/search.html @@ -24,7 +24,6 @@
-
@@ -82,7 +81,14 @@ {{/if}} {{/each}} +
  • + {{if number>0}} + / + {{/if}} + +
  • +