source: function(request, response){
$.get("restServices/archivaServices/searchService/quickSearch?queryString="+encodeURIComponent(request.term),
function(data) {
- var res = $.map(data,function(item){
- return item.artifactId;
- });
+ var res = mapArtifacts(data);
var uniqId = [];
+ var uniqArtifactIds=[];
for (var i= 0;i<res.length;i++){
- if ( $.inArray(res[i],uniqId)<0){
- uniqId.push(res[i]);
+ if ( $.inArray(res[i].artifactId,uniqId)<0){
+ 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 );
+ };;
}
customShowError("#main-content #search-basic-form", null, null, []);
}
self.search("restServices/archivaServices/searchService/quickSearchWithRepositories");
-
-
}
+ /**
+ * use from autocomplete search
+ */
+ this.externalAdvancedSearch=function(){
+ this.search("restServices/archivaServices/searchService/searchArtifacts");
+ }
advancedSearch=function(){
self.search("restServices/archivaServices/searchService/searchArtifacts");
}
}
- displaySearch=function(){
+ displaySearch=function(successCallbackFn){
clearUserMessages();
var mainContent=$("#main-content");
mainContent.html(mediumSpinnerImg());
searchViewModel.observableRepoIds(repos);
ko.applyBindings(searchViewModel,mainContent.find("#search-artifacts-div").get(0));
mainContent.find("#search-basic-repostories-select" ).chosen();
+ if (successCallbackFn) successCallbackFn();
}
});