]> source.dussan.org Git - archiva.git/commitdiff
make basic search navigable
authorOlivier Lamy <olamy@apache.org>
Thu, 23 Aug 2012 08:49:20 +0000 (08:49 +0000)
committerOlivier Lamy <olamy@apache.org>
Thu, 23 Aug 2012 08:49:20 +0000 (08:49 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1376407 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
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/search.html

index 240acdfe1d513fec99cfa43afc447938bf67b303..f4f1966af27f2daabe474e2f8014195dfb9d51c0 100644 (file)
@@ -208,8 +208,21 @@ function() {
           var repositoryIds = this.params.repositoryIds;
           var repos = repositoryIds.split("~");
           $.log("queryterms:"+queryterms+',repositoryIds:'+repositoryIds+",repos:"+repos.length);
+          var searchViewModel = new SearchViewModel();
+          var searchRequest = new SearchRequest();
+          searchRequest.queryTerms(queryterms);
+          searchRequest.repositories=repos;
+          searchViewModel.searchRequest(searchRequest);
+          displaySearch(function(){
+            searchViewModel.externalBasicSearch();
+          },searchViewModel);
+        });
+
+        this.get('#searchresult~:repositoryIds/:queryterms',function(){
           var queryterms= this.params.queryterms;
-          $.log("queryterms:"+queryterms);
+          var repositoryIds = this.params.repositoryIds;
+          var repos = repositoryIds.split("~");
+          $.log("queryterms:"+queryterms+',repositoryIds:'+repositoryIds+",repos:"+repos.length);
           var searchViewModel = new SearchViewModel();
           var searchRequest = new SearchRequest();
           searchRequest.queryTerms(queryterms);
@@ -220,6 +233,18 @@ function() {
           },searchViewModel);
         });
 
+        this.get('#searchresult/:queryterms',function(){
+          var queryterms= this.params.queryterms;
+          $.log("queryterms:"+queryterms);
+          var searchViewModel = new SearchViewModel();
+          var searchRequest = new SearchRequest();
+          searchRequest.queryTerms(queryterms);
+          searchViewModel.searchRequest(searchRequest);
+          displaySearch(function(){
+            searchViewModel.externalBasicSearch();
+          },searchViewModel);
+        });
+
         this.get('#open-admin-create-box',function(){
           $.log("#open-admin-create-box");
           adminCreateBox();
index 898e37fe86b72adf2457a528cec605992dbe6dd2..644e266d8882ce5da0b241082fdc0f3742fc25e3 100644 (file)
@@ -1533,6 +1533,7 @@ define("archiva.search",["jquery","i18n","jquery.tmpl","choosen","knockout","kno
    */
   SearchViewModel=function(){
     var self=this;
+    var mainContent=$("#main-content");
     this.searchRequest=ko.observable(new SearchRequest());
     this.observableRepoIds=ko.observableArray([]);
     this.selectedRepoIds=[];
@@ -1550,7 +1551,25 @@ define("archiva.search",["jquery","i18n","jquery.tmpl","choosen","knockout","kno
         // cleanup previours error message
         customShowError("#main-content #search-basic-form", null, null, []);
       }
-      self.search("restServices/archivaServices/searchService/quickSearchWithRepositories");
+      var location="#searchresult";
+
+      self.selectedRepoIds=[];
+      mainContent.find("#search-basic-repositories" )
+          .find(".chzn-choices li span").each(function(i,span){
+                      self.selectedRepoIds.push($(span).html());
+                      }
+                    );
+
+      if (self.selectedRepoIds.length>0){
+        $.log("selectedRepoIds:"+self.selectedRepoIds.length);
+        $(self.selectedRepoIds).each(function(index, Element){
+          location+="~"+self.selectedRepoIds[index];
+        });
+      }
+      location+="/"+queryTerm;
+      $.log("basicsearch location:"+location);
+      window.sammyArchivaApplication.setLocation(location);
+      //self.search("restServices/archivaServices/searchService/quickSearchWithRepositories");
     }
 
     this.externalBasicSearch=function(){
@@ -1574,8 +1593,6 @@ define("archiva.search",["jquery","i18n","jquery.tmpl","choosen","knockout","kno
     }
     this.search=function(url,repositoriesIds){
 
-      var mainContent=$("#main-content");
-
       var searchResultsGrid=mainContent.find("#search-results #search-results-grid" );
       mainContent.find("#btn-basic-search" ).button("loading");
       mainContent.find("#btn-advanced-search" ).button("loading");
@@ -1673,7 +1690,7 @@ define("archiva.search",["jquery","i18n","jquery.tmpl","choosen","knockout","kno
           $.log("repos:"+repos);
           searchViewModel.observableRepoIds(repos);
           ko.applyBindings(searchViewModel,mainContent.find("#search-artifacts-div").get(0));
-          mainContent.find("#search-basic-repostories-select" ).chosen();
+          mainContent.find("#search-basic-repositories-select" ).chosen();
           if (successCallbackFn && $.isFunction(successCallbackFn)) successCallbackFn();
         }
     });
index 7f2addecd33324538648196c877c49791163308a..5761389b444d98c6b2f787c92d9e5e4586171a5c 100644 (file)
                 <fieldset>
                   <div class="control-group" id="search-basic-repositories">
                     <select data-placeholder="${$.i18n.prop('search.artifact.search.form.query.repositories')}"
-                            id="search-basic-repostories-select" class="chzn-select defaults"
+                            id="search-basic-repositories-select" class="chzn-select defaults"
                             multiple style="width:350px;" tabindex="4">
                       <option value="all">${$.i18n.prop('search.artifact.search.form.repositories.all')}</option>
                       {{each(i,repoId) observableRepoIds}}