From 50f63a49ab394c7069466e41dd8cbd3f9d7b6a9d Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Thu, 23 Aug 2012 16:11:42 +0000 Subject: [PATCH] make advanced search navigable git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1376569 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/main/webapp/js/archiva/main.js | 12 ++--- .../src/main/webapp/js/archiva/search.js | 53 +++++++++++++++++-- 2 files changed, 55 insertions(+), 10 deletions(-) diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js index 51a3bdc2a..3baa67acf 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js @@ -178,7 +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; @@ -267,20 +267,20 @@ function($,sammy,tmpl,ui) { searchRequest.classifier(classifier); searchRequest.packaging(packaging); searchRequest.className(className); - - searchRequest.selectedRepoIds=repositoryIds; + //searchRequest.repositories=repos; + //searchRequest.selectedRepoIds=repos; searchViewModel.searchRequest(searchRequest); displaySearch(function(){ - searchViewModel.search("restServices/archivaServices/searchService/searchArtifacts",repositoryIds); + searchViewModel.search("restServices/archivaServices/searchService/searchArtifacts",repos);//,repositoryIds); },searchViewModel); } - self.get("#advancedsearch/:queryterms",function(){ + this.get("#advancedsearch/:queryterms",function(){ advancedSearchRoute(this.params); }); - self.get("#advancedsearch~:repositoryIds/:queryterms",function(){ + this.get("#advancedsearch~:repositoryIds/:queryterms",function(){ advancedSearchRoute(this.params); }); 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 1061b1929..ec69ac2a4 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 @@ -1567,14 +1567,11 @@ define("archiva.search",["jquery","i18n","jquery.tmpl","choosen","knockout","kno }); } location+="/"+queryTerm; - $.log("basicsearch location:"+location); window.sammyArchivaApplication.setLocation(location); - //self.search("restServices/archivaServices/searchService/quickSearchWithRepositories"); } this.externalBasicSearch=function(){ var queryTerm=this.searchRequest().queryTerms(); - $.log("externalBasicSearch#queryTerm:"+queryTerm); self.search("restServices/archivaServices/searchService/quickSearchWithRepositories",this.searchRequest().repositories); } @@ -1585,7 +1582,55 @@ define("archiva.search",["jquery","i18n","jquery.tmpl","choosen","knockout","kno this.search("restServices/archivaServices/searchService/searchArtifacts"); } advancedSearch=function(){ - self.search("restServices/archivaServices/searchService/searchArtifacts"); + var location="#advancedsearch"; + + 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+="/"; + if(self.searchRequest().groupId()){ + location+=self.searchRequest().groupId(); + }/*else{ + location+='~'; + }*/ + if(self.searchRequest().artifactId()){ + location+='~'+self.searchRequest().artifactId(); + }else{ + location+='~'; + } + if(self.searchRequest().version()){ + location+='~'+self.searchRequest().version(); + }else{ + location+='~'; + } + if(self.searchRequest().classifier()){ + location+='~'+self.searchRequest().classifier(); + }else{ + location+='~'; + } + if(self.searchRequest().packaging()){ + location+='~'+self.searchRequest().packaging(); + }else{ + location+='~'; + } + if(self.searchRequest().className()){ + location+='~'+self.searchRequest().className(); + }else{ + location+='~'; + } + + $.log("location:"+location); + window.sammyArchivaApplication.setLocation(location); } removeFilter=function(){ $.log("removeFilter:"+self.resultViewModel.originalArtifacts.length);