]> source.dussan.org Git - archiva.git/commitdiff
display search result when coming from the auto complete quick search box
authorOlivier Lamy <olamy@apache.org>
Mon, 5 Mar 2012 13:55:44 +0000 (13:55 +0000)
committerOlivier Lamy <olamy@apache.org>
Mon, 5 Mar 2012 13:55:44 +0000 (13:55 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1297059 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js

index 6dbf053461952640c1339267e0f602043f8b1070..dde707ba187befefe24fce36bba2605b97302bf3 100644 (file)
@@ -213,21 +213,35 @@ $(function() {
                        source: function(request, response){
         $.get("restServices/archivaServices/searchService/quickSearch?queryString="+encodeURIComponent(request.term),
            function(data) {
-             var res = $.map(data,function(item){
-               return item.artifactId;
-             });
+             var res = mapArtifacts(data);
              var uniqId = [];
+             var uniqArtifactIds=[];
              for (var i= 0;i<res.length;i++){
-               if ( $.inArray(res[i],uniqId)<0){
-                 uniqId.push(res[i]);
+               if ( $.inArray(res[i].artifactId,uniqId)<0){
+                 uniqId.push(res[i].artifactId);
+                 uniqArtifactIds.push(res[i]);
                }
              }
-             response(uniqId);
+             response(uniqArtifactIds);
            }
         );
-
+      },
+      select: function( event, ui ) {
+        $.log("select artifactId:"+ui.item.artifactId);
+        displaySearch(function(){
+          var searchViewModel = new SearchViewModel();
+          var searchRequest = new SearchRequest();
+          searchRequest.artifactId(ui.item.artifactId);
+          searchViewModel.searchRequest(searchRequest);
+          searchViewModel.externalAdvancedSearch();
+        });
       }
-               });
+               }).data( "autocomplete" )._renderItem = function( ul, item ) {
+                                                       return $( "<li></li>" )
+                                                               .data( "item.autocomplete", item )
+                                                               .append( "<a>" + item.artifactId + "</a>" )
+                                                               .appendTo( ul );
+                                               };;
   }
 
 
index 28b210ed6c16797ad6faf9db561eb8d3d6a933a8..19b07c23f23dd40edff30ef474f0b62fbab6a23d 100644 (file)
@@ -747,10 +747,14 @@ $(function() {
         customShowError("#main-content #search-basic-form", null, null, []);
       }
       self.search("restServices/archivaServices/searchService/quickSearchWithRepositories");
-
-
     }
 
+    /**
+     * use from autocomplete search
+     */
+    this.externalAdvancedSearch=function(){
+      this.search("restServices/archivaServices/searchService/searchArtifacts");
+    }
     advancedSearch=function(){
       self.search("restServices/archivaServices/searchService/searchArtifacts");
     }
@@ -828,7 +832,7 @@ $(function() {
 
   }
 
-  displaySearch=function(){
+  displaySearch=function(successCallbackFn){
     clearUserMessages();
     var mainContent=$("#main-content");
     mainContent.html(mediumSpinnerImg());
@@ -843,6 +847,7 @@ $(function() {
           searchViewModel.observableRepoIds(repos);
           ko.applyBindings(searchViewModel,mainContent.find("#search-artifacts-div").get(0));
           mainContent.find("#search-basic-repostories-select" ).chosen();
+          if (successCallbackFn) successCallbackFn();
         }
     });