]> source.dussan.org Git - archiva.git/commitdiff
add route for advanced search
authorOlivier Lamy <olamy@apache.org>
Thu, 23 Aug 2012 16:11:18 +0000 (16:11 +0000)
committerOlivier Lamy <olamy@apache.org>
Thu, 23 Aug 2012 16:11:18 +0000 (16:11 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1376567 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 5d45986b91e56b8bd8f8283bada127af78a0e123..5c0c8f0bb39c0fd0994c6d0ab400eaa1bc7cb583 100644 (file)
@@ -178,6 +178,7 @@ function($,sammy,tmpl,ui) {
       this.activeMenuId = ko.observable();
           
       window.sammyArchivaApplication = Sammy(function () {
+        var self = this;
         this.get('#quicksearch~:artifactId',function(){
           $("#main-content" ).html(mediumSpinnerImg());
           var artifactId= this.params.artifactId;
@@ -218,7 +219,7 @@ function($,sammy,tmpl,ui) {
           },searchViewModel);
         });
 
-        this.get('#searchresult~:repositoryIds/:queryterms',function(){
+        this.get('#basicsearch~:repositoryIds/:queryterms',function(){
           var queryterms= this.params.queryterms;
           var repositoryIds = this.params.repositoryIds;
           var repos = repositoryIds.split("~");
@@ -233,7 +234,7 @@ function($,sammy,tmpl,ui) {
           },searchViewModel);
         });
 
-        this.get('#searchresult/:queryterms',function(){
+        this.get('#basicsearch/:queryterms',function(){
           var queryterms= this.params.queryterms;
           $.log("queryterms:"+queryterms);
           var searchViewModel = new SearchViewModel();
@@ -245,6 +246,85 @@ function($,sammy,tmpl,ui) {
           },searchViewModel);
         });
 
+        var advancedSearchRoute=function(repositoryIds,groupId,artifactId,version,classifier,packaging,className){
+
+          $.log("groupId:artifactId:version:classifier:packaging:className="+groupId+':'+artifactId+':'+version+':'+classifier+':'+packaging+':'+className);
+          var searchViewModel = new SearchViewModel();
+          var searchRequest = new SearchRequest();
+          searchRequest.groupId(groupId);
+          searchRequest.artifactId(artifactId);
+          searchRequest.version(version);
+          searchRequest.classifier(classifier);
+          searchRequest.packaging(packaging);
+          searchRequest.className(className);
+
+          searchRequest.selectedRepoIds=repositoryIds;
+          searchViewModel.searchRequest(searchRequest);
+          displaySearch(function(){
+            //searchViewModel.externalAdvancedSearch();
+            searchViewModel.search("restServices/archivaServices/searchService/searchArtifacts",repositoryIds);
+          },searchViewModel);
+        }
+
+        /*var advancedSearchParams=['groupId','artifactId','version','classifier','packaging','className'];
+
+        var createAdvancedSearchRoutes=function(startLocation){
+          for(var idx=1;idx<advancedSearchParams.length+1;idx++){
+            var route = startLocation;
+            $(advancedSearchParams).each(function(index) {
+              if(index<idx){
+                route+="~:"+advancedSearchParams[index];
+              }
+            });
+            $.log("add route:"+route);
+            self.get(route,function(){
+              var repositoryIds = this.params.repositoryIds;
+              var repos = repositoryIds ? repositoryIds.split("~"):[];
+              $.log('repos:'+repos.length);
+              var groupId= this.params.groupId;
+              var artifactId= this.params.artifactId;
+              var version= this.params.version;
+              var classifier= this.params.classifier;
+              var packaging= this.params.packaging;
+              var className= this.params.className;
+              advancedSearchRoute(repos,groupId,artifactId,version,classifier,packaging,className);
+            });
+          }
+        }*/
+        //createAdvancedSearchRoutes("#advancedsearch/");
+        //createAdvancedSearchRoutes("#advancedsearch~:repositoryIds/");
+
+        self.get("#advancedsearch/:queryterms",function(){
+          var repositoryIds = this.params.repositoryIds;
+          var repos = repositoryIds ? repositoryIds.split("~"):[];
+          var queryTerms = this.params.queryterms;
+          var terms=queryTerms?queryTerms.split('~'):[];
+          $.log("queryTerms:"+queryTerms+",terms.length:"+terms.length);
+          var groupId= terms.length>0?terms[0]:"";
+          var artifactId= terms.length>1?terms[1]:"";
+          var version= terms.length>2?terms[2]:"";
+          var classifier= terms.length>3?terms[3]:"";
+          var packaging= terms.length>4?terms[4]:"";
+          var className= terms.length>5?terms[5]:"";
+          advancedSearchRoute(repos,groupId,artifactId,version,classifier,packaging,className);
+        });
+
+        self.get("#advancedsearch~:repositoryIds/:queryterms",function(){
+          var repositoryIds = this.params.repositoryIds;
+          var repos = repositoryIds ? repositoryIds.split("~"):[];
+          var queryTerms = this.params.queryterms;
+          var terms=queryTerms?queryTerms.split('~'):[];
+          $.log("queryTerms:"+queryTerms+",terms.length:"+terms.length);
+          var groupId= terms.length>0?terms[0]:"";
+          var artifactId= terms.length>1?terms[1]:"";
+          var version= terms.length>2?terms[2]:"";
+          var classifier= terms.length>3?terms[3]:"";
+          var packaging= terms.length>4?terms[4]:"";
+          var className= terms.length>5?terms[5]:"";
+          advancedSearchRoute(repos,groupId,artifactId,version,classifier,packaging,className);
+        });
+
+
         this.get('#open-admin-create-box',function(){
           $.log("#open-admin-create-box");
           adminCreateBox();
index 644e266d8882ce5da0b241082fdc0f3742fc25e3..1061b19295934f4697787c55e2d62fdaaf6c0233 100644 (file)
@@ -1551,7 +1551,7 @@ define("archiva.search",["jquery","i18n","jquery.tmpl","choosen","knockout","kno
         // cleanup previours error message
         customShowError("#main-content #search-basic-form", null, null, []);
       }
-      var location="#searchresult";
+      var location="#basicsearch";
 
       self.selectedRepoIds=[];
       mainContent.find("#search-basic-repositories" )