mirror of https://github.com/apache/archiva.git
display search result when coming from the auto complete quick search box
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1297059 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
60638fb8bb
commit
3e691d1682
|
@ -213,22 +213,36 @@ $(function() {
|
||||||
source: function(request, response){
|
source: function(request, response){
|
||||||
$.get("restServices/archivaServices/searchService/quickSearch?queryString="+encodeURIComponent(request.term),
|
$.get("restServices/archivaServices/searchService/quickSearch?queryString="+encodeURIComponent(request.term),
|
||||||
function(data) {
|
function(data) {
|
||||||
var res = $.map(data,function(item){
|
var res = mapArtifacts(data);
|
||||||
return item.artifactId;
|
|
||||||
});
|
|
||||||
var uniqId = [];
|
var uniqId = [];
|
||||||
|
var uniqArtifactIds=[];
|
||||||
for (var i= 0;i<res.length;i++){
|
for (var i= 0;i<res.length;i++){
|
||||||
if ( $.inArray(res[i],uniqId)<0){
|
if ( $.inArray(res[i].artifactId,uniqId)<0){
|
||||||
uniqId.push(res[i]);
|
uniqId.push(res[i].artifactId);
|
||||||
|
uniqArtifactIds.push(res[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
response(uniqId);
|
response(uniqArtifactIds);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
},
|
||||||
}
|
select: function( event, ui ) {
|
||||||
|
$.log("select artifactId:"+ui.item.artifactId);
|
||||||
|
displaySearch(function(){
|
||||||
|
var searchViewModel = new SearchViewModel();
|
||||||
|
var searchRequest = new SearchRequest();
|
||||||
|
searchRequest.artifactId(ui.item.artifactId);
|
||||||
|
searchViewModel.searchRequest(searchRequest);
|
||||||
|
searchViewModel.externalAdvancedSearch();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}).data( "autocomplete" )._renderItem = function( ul, item ) {
|
||||||
|
return $( "<li></li>" )
|
||||||
|
.data( "item.autocomplete", item )
|
||||||
|
.append( "<a>" + item.artifactId + "</a>" )
|
||||||
|
.appendTo( ul );
|
||||||
|
};;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -747,10 +747,14 @@ $(function() {
|
||||||
customShowError("#main-content #search-basic-form", null, null, []);
|
customShowError("#main-content #search-basic-form", null, null, []);
|
||||||
}
|
}
|
||||||
self.search("restServices/archivaServices/searchService/quickSearchWithRepositories");
|
self.search("restServices/archivaServices/searchService/quickSearchWithRepositories");
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* use from autocomplete search
|
||||||
|
*/
|
||||||
|
this.externalAdvancedSearch=function(){
|
||||||
|
this.search("restServices/archivaServices/searchService/searchArtifacts");
|
||||||
|
}
|
||||||
advancedSearch=function(){
|
advancedSearch=function(){
|
||||||
self.search("restServices/archivaServices/searchService/searchArtifacts");
|
self.search("restServices/archivaServices/searchService/searchArtifacts");
|
||||||
}
|
}
|
||||||
|
@ -828,7 +832,7 @@ $(function() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
displaySearch=function(){
|
displaySearch=function(successCallbackFn){
|
||||||
clearUserMessages();
|
clearUserMessages();
|
||||||
var mainContent=$("#main-content");
|
var mainContent=$("#main-content");
|
||||||
mainContent.html(mediumSpinnerImg());
|
mainContent.html(mediumSpinnerImg());
|
||||||
|
@ -843,6 +847,7 @@ $(function() {
|
||||||
searchViewModel.observableRepoIds(repos);
|
searchViewModel.observableRepoIds(repos);
|
||||||
ko.applyBindings(searchViewModel,mainContent.find("#search-artifacts-div").get(0));
|
ko.applyBindings(searchViewModel,mainContent.find("#search-artifacts-div").get(0));
|
||||||
mainContent.find("#search-basic-repostories-select" ).chosen();
|
mainContent.find("#search-basic-repostories-select" ).chosen();
|
||||||
|
if (successCallbackFn) successCallbackFn();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue