Skip to content

Commit

Permalink
series: Add a Tests filter
Browse files Browse the repository at this point in the history
Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
  • Loading branch information
Damien Lespiau committed Feb 25, 2016
1 parent cfa59e0 commit f58900d
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 0 deletions.
57 changes: 57 additions & 0 deletions htdocs/js/series-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,63 @@ $(function () {
},
});

/* tests filter */
pw.create_filter({
table: series_table,
name: 'tests',
init: function() {
var _this = this;

this.success = $('#tests-success');
this.warning = $('#tests-warning');
this.failure = $('#tests-failure');

$('#tests-filter input:checkbox').change(function() {
_this.refresh_apply();
});
},
_collect_states: function() {
var filters = [];

if (this.success.prop('checked'))
filters.push('success');
if (this.warning.prop('checked'))
filters.push('warning');
if (this.failure.prop('checked'))
filters.push('failure');

return filters;
},
set_filter: function(table) {
var filters = this._collect_states();

table.set_filter('test_state', filters.join(','));
},
clear_filter: function(table) {
this.success.prop('checked', false);
this.warning.prop('checked', false);
this.failure.prop('checked', false);
table.set_filter('test_state', null);
},
can_submit: function() {
return this.success.prop('checked') ||
this.warning.prop('checked') ||
this.failure.prop('checked');
},
humanize: function() {
var filters = this._collect_states();

if (filters.length == 1)
return 'with test result "' + filters[0] + '"';
if (filters.length == 2)
return 'with test result "' + filters[0] + '" or "' +
filters[1] + '"';
if (filters.length == 3)
return 'with test result "' + filters[0] + '", "' +
filters[1] + '" or "' + filters[2] + '"';
},
});

/* reviewer action */
pw.create_action({
table: series_table,
Expand Down
37 changes: 37 additions & 0 deletions patchwork/templates/patchwork/series-list.html
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,43 @@ <h1>Series</h1>
</li>
</ul>
</li>
<li class="dropdown" id="tests-filter">
<a data-toggle="dropdown" href='#' id="tests-filter-dropdown">
<button id="clear-tests-filter" class="btn btn-default btn-xs"
title="Clear tests filter" style="display:none;">
<span class="glyphicon glyphicon-remove"></span>
</button>
Tests
<span class="caret"></span>
</a>
<ul role="menu" class="dropdown-menu table-toolbar">
<li><span>Show series with test results:</span></li>
<li>
<form id="tests-form">
<div class="checkbox">
<label>
<input id="tests-success" type="checkbox" value="success" name="tests-options">
Success
</label>
</div>
<div class="checkbox">
<label>
<input id="tests-warning" type="checkbox" value="warning" name="tests-options">
Warning
</label>
</div>
<div class="checkbox">
<label>
<input id="tests-failure" type="checkbox" value="failure" name="tests-options">
Failure
</label>
</div>
<button type="submit" class="btn btn-default apply-filter">Apply</button>
<button class="btn btn-link" style="display:none;">Clear Tests filter</button>
</form>
</li>
</ul>
</li>
</ul>
<div class="btn-group navbar-btn" id="serieslist-actions" style="display:none;">
<div class="btn-group" style="margin-left: 20px">
Expand Down

0 comments on commit f58900d

Please sign in to comment.