starting filtering on search results

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1295114 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2012-02-29 14:05:12 +00:00
parent 9fd6d23558
commit cc812c4665
3 changed files with 33 additions and 7 deletions

View File

@ -223,3 +223,5 @@ search.artifact.results.groupId=Group ID
search.artifact.results.artifactId=Artifact ID
search.artifact.results.version=Version
search.artifact.searching=Searching .....
search.artifact.search.form.btn.search=Search
search.artifact.search.form.btn.search.filter=Filter Results

View File

@ -647,15 +647,18 @@ $(function() {
columns: [
{
headerText: $.i18n.prop('search.artifact.results.groupId'),
rowText: "groupId"
rowText: "groupId",
id: "groupId"
},
{
headerText: $.i18n.prop('search.artifact.results.artifactId'),
rowText: "artifactId"
rowText: "artifactId",
id: "artifactId"
},
{
headerText: $.i18n.prop('search.artifact.results.version'),
rowText: "version"
rowText: "version",
id: "version"
}
],
pageSize: 10,
@ -674,8 +677,7 @@ $(function() {
this.resultViewModel=new ResultViewModel([]);
basicSearch=function(){
var queryTerm=this.searchRequest().queryTerms();
if (!queryTerm || $.trim(queryTerm).length<1){
$.log("empty");
if ($.trim(queryTerm).length<1){
var errorList=[{
message: $.i18n.prop("search.artifact.search.form.terms.empty"),
element: $("#main-content #search-basic-form #search-terms" ).get(0)
@ -732,6 +734,7 @@ $(function() {
ko.applyBindings(self.resultViewModel,searchResultsGrid.get(0));
}
activateSearchResultsTab();
mainContent.find("#btn-advanced-search-filter" ).show();
}
},
error: function(data) {
@ -745,6 +748,16 @@ $(function() {
}
);
}
filterResults=function(){
var filtered=[];
for (var i=0;i<self.resultViewModel.artifacts().length;i++){
if (self.resultViewModel.artifacts()[i].groupId==this.searchRequest().groupId()){
filtered.push(self.resultViewModel.artifacts()[i]);
}
}
self.resultViewModel.artifacts(filtered);
}
}
activateSearchResultsTab=function(){

View File

@ -209,7 +209,8 @@
data-bind="value: searchRequest().queryTerms" placeholder="${$.i18n.prop('search.artifact.search.form.query.terms')}"/>
</div>
</div>
<button type="submit" id="btn-basic-search" class="btn btn-primary" data-loading-text="${$.i18n.prop('search.artifact.searching')}" data-bind="click: basicSearch">Search</button>
<button type="submit" id="btn-basic-search" class="btn btn-primary"
data-loading-text="${$.i18n.prop('search.artifact.searching')}" data-bind="click: basicSearch">${$.i18n.prop('search.artifact.search.form.btn.search')}</button>
</fieldset>
</form>
</div>
@ -252,7 +253,12 @@
</div>
</div>
</fieldset>
<button type="submit" id="btn-advanced-search" class="btn btn-primary" class="btn" data-bind="click: advancedSearch">Search</button>
<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">
@ -282,6 +288,11 @@
<th title="${ columnDefinition.title }">${ columnDefinition.headerText }</th>
{{/each}}
</tr>
<tr>
{{each(i, columnDefinition) columns}}
<th title="${ columnDefinition.title }" id="search-filter-auto-${ columnDefinition.id }"><input type="text" place-holder="filter"/></th>
{{/each}}
</tr>
</thead>
<tbody>
{{each(i, row) itemsOnCurrentPage()}}