handle navigation for #basicsearch

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1370568 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2012-08-07 22:11:55 +00:00
parent 8be9f7b746
commit 8b1587ea4e
2 changed files with 48 additions and 9 deletions

View File

@ -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();

View File

@ -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,
{