From 8b1587ea4ec34f927934d2a39f6c667ae063e98b Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Tue, 7 Aug 2012 22:11:55 +0000 Subject: [PATCH] handle navigation for #basicsearch git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1370568 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/main/webapp/js/archiva/main.js | 31 +++++++++++++++++++ .../src/main/webapp/js/archiva/search.js | 26 ++++++++++------ 2 files changed, 48 insertions(+), 9 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 2fd7a2adc..1cfb929a1 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 @@ -179,6 +179,7 @@ function() { window.sammyArchivaApplication = Sammy(function () { this.get('#quicksearch~:artifactId',function(){ + $("#main-content" ).html(mediumSpinnerImg()); var artifactId= this.params.artifactId; // user can be in a non search view so init the search view first var searchViewModel = new SearchViewModel(); @@ -189,6 +190,36 @@ function() { searchViewModel.externalAdvancedSearch(); },searchViewModel); }); + + this.get('#basicsearch/: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('#basicsearch~:repositoryIds/:queryterms',function(){ + var queryterms= this.params.queryterms; + var repositoryIds = this.params.repositoryIds; + var repos = repositoryIds.split("~"); + $.log("queryterms:"+queryterms+',repositoryIds:'+repositoryIds+",repos:"+repos.length); + var queryterms= this.params.queryterms; + $.log("queryterms:"+queryterms); + var searchViewModel = new SearchViewModel(); + var searchRequest = new SearchRequest(); + searchRequest.queryTerms(queryterms); + searchRequest.repositories=repos; + searchViewModel.searchRequest(searchRequest); + displaySearch(function(){ + searchViewModel.externalBasicSearch(); + },searchViewModel); + }); + this.get('#open-admin-create-box',function(){ $.log("#open-admin-create-box"); adminCreateBox(); 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 5db3a09b4..2ef0f3e53 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 @@ -1489,6 +1489,12 @@ define("archiva.search",["jquery","i18n","jquery.tmpl","choosen","knockout","kno 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); + } + /** * use from autocomplete search */ @@ -1502,7 +1508,7 @@ define("archiva.search",["jquery","i18n","jquery.tmpl","choosen","knockout","kno $.log("removeFilter:"+self.resultViewModel.originalArtifacts.length); self.resultViewModel.artifacts(self.resultViewModel.originalArtifacts); } - this.search=function(url){ + this.search=function(url,repositoriesIds){ var mainContent=$("#main-content"); @@ -1510,14 +1516,16 @@ define("archiva.search",["jquery","i18n","jquery.tmpl","choosen","knockout","kno mainContent.find("#btn-basic-search" ).button("loading"); mainContent.find("#btn-advanced-search" ).button("loading"); $("#user-messages").html(mediumSpinnerImg()); - - self.selectedRepoIds=[]; - mainContent.find("#search-basic-repositories" ) - .find(".chzn-choices li span").each(function(i,span){ - self.selectedRepoIds.push($(span).html()); - } - ); - + if (repositoriesIds){ + self.selectedRepoIds=repositoriesIds; + } else { + self.selectedRepoIds=[]; + mainContent.find("#search-basic-repositories" ) + .find(".chzn-choices li span").each(function(i,span){ + self.selectedRepoIds.push($(span).html()); + } + ); + } this.searchRequest().repositories=this.selectedRepoIds; $.ajax(url, { -- 2.39.5