mirror of https://github.com/apache/archiva.git
add autocomplete to apply filtering on search results
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1295209 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
4dcb5d3ebb
commit
a15504344b
|
@ -703,6 +703,7 @@ $(function() {
|
|||
|
||||
var searchResultsGrid=mainContent.find("#search-results #search-results-grid" );
|
||||
mainContent.find("#btn-basic-search" ).button("loading");
|
||||
mainContent.find("#btn-advanced-search" ).button("loading");
|
||||
$("#user-messages").html(mediumSpinnerImg());
|
||||
|
||||
|
||||
|
@ -733,8 +734,50 @@ $(function() {
|
|||
"simpleGrid: gridViewModel,simpleGridTemplate:'search-results-view-grid-tmpl',pageLinksId:'search-results-view-grid-pagination'");
|
||||
ko.applyBindings(self.resultViewModel,searchResultsGrid.get(0));
|
||||
}
|
||||
// FIXME something generic here !
|
||||
|
||||
$( "#main-content #search-filter-auto-groupId" ).autocomplete({
|
||||
minLength: 1,
|
||||
source: function(request, response){
|
||||
var groupIds=[];
|
||||
$(self.resultViewModel.artifacts()).each(function(idx,artifact){
|
||||
if(artifact.groupId.startsWith(request.term)){
|
||||
groupIds.push(artifact.groupId);
|
||||
}
|
||||
});
|
||||
response(unifyArray(groupIds,true));
|
||||
}
|
||||
});
|
||||
|
||||
$( "#main-content #search-filter-auto-artifactId" ).autocomplete({
|
||||
minLength: 1,
|
||||
source: function(request, response){
|
||||
var artifactIds=[];
|
||||
$(self.resultViewModel.artifacts()).each(function(idx,artifact){
|
||||
if(artifact.artifactId.startsWith(request.term)){
|
||||
artifactIds.push(artifact.artifactId);
|
||||
}
|
||||
});
|
||||
response(unifyArray(artifactIds,true));
|
||||
}
|
||||
});
|
||||
|
||||
$( "#main-content #search-filter-auto-version" ).autocomplete({
|
||||
minLength: 1,
|
||||
source: function(request, response){
|
||||
var versions=[];
|
||||
$(self.resultViewModel.artifacts()).each(function(idx,artifact){
|
||||
if(artifact.version.startsWith(request.term)){
|
||||
versions.push(artifact.version);
|
||||
}
|
||||
});
|
||||
response(unifyArray(versions,true));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
activateSearchResultsTab();
|
||||
mainContent.find("#btn-advanced-search-filter" ).show();
|
||||
}
|
||||
},
|
||||
error: function(data) {
|
||||
|
@ -742,13 +785,15 @@ $(function() {
|
|||
displayRestError(res);
|
||||
},
|
||||
complete:function() {
|
||||
$("#main-content #btn-basic-search" ).button("reset");
|
||||
mainContent.find("##btn-basic-search" ).button("reset");
|
||||
mainContent.find("#btn-advanced-search" ).button("reset");
|
||||
removeMediumSpinnerImg("#user-messages");
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// olamy not used as we cannot filter on className etc...
|
||||
filterResults=function(){
|
||||
var filtered=[];
|
||||
for (var i=0;i<self.resultViewModel.artifacts().length;i++){
|
||||
|
|
|
@ -256,9 +256,6 @@
|
|||
<button type="submit" id="btn-advanced-search" class="btn btn-primary"
|
||||
data-bind="click: advancedSearch">${$.i18n.prop('search.artifact.search.form.btn.search')}</button>
|
||||
|
||||
<button type="submit" id="btn-advanced-search-filter" class="btn btn-success hide"
|
||||
data-bind="click: filterResults">${$.i18n.prop('search.artifact.search.form.btn.search.filter')}</button>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
<div class="pill-pane" id="search-osgi-form-pane">
|
||||
|
@ -290,7 +287,9 @@
|
|||
</tr>
|
||||
<tr>
|
||||
{{each(i, columnDefinition) columns}}
|
||||
<th title="${ columnDefinition.title }" id="search-filter-auto-${ columnDefinition.id }"><input type="text" place-holder="filter"/></th>
|
||||
<th title="${ columnDefinition.title }">
|
||||
<input type="text" class="form-search" id="search-filter-auto-${ columnDefinition.id }" place-holder="filtering"/>
|
||||
</th>
|
||||
{{/each}}
|
||||
</tr>
|
||||
</thead>
|
||||
|
|
|
@ -329,6 +329,21 @@ mapStringList=function(data){
|
|||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* return an array with removing duplicate strings
|
||||
* @param strArray an array of string
|
||||
* @param sorted to sort or not
|
||||
*/
|
||||
unifyArray=function(strArray,sorted){
|
||||
var res = [];
|
||||
$(strArray).each(function(idx,str){
|
||||
if ( $.inArray(str,res)<0){
|
||||
res.push(str);
|
||||
}
|
||||
});
|
||||
return sorted?res.sort():res;
|
||||
}
|
||||
|
||||
// utils
|
||||
String.prototype.endsWith = function(str) {
|
||||
return (this.match(str+"$")==str)
|
||||
|
|
|
@ -133,4 +133,5 @@
|
|||
</modules>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
</project>
|
||||
|
|
Loading…
Reference in New Issue