Skip to content

Commit

Permalink
Fix coverage table sort and filter (#437)
Browse files Browse the repository at this point in the history
* fixes smells index table ID

* fixes coverage sort and filter

* remove extra decimal places on coverage

* Update CHANGELOG.md

* update changelog entry

* remove accidental empty whitespace in CHANGELOG

* fixes linting errors in CHANGELOG

* undo fix linting errors

* typo fixes

* add changelog entry

* undo last commit

* Update CHANGELOG.md

---------

Co-authored-by: Nuno Silva <[email protected]>
  • Loading branch information
kcamcam and nunosilva800 authored May 12, 2023
1 parent 088ebd7 commit 95e7105
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 16 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# main [(unreleased)](https://github.com/whitesmith/rubycritic/compare/v4.8.0...main)

* [BUGFIX] Fix sort and filters on the coverage page (by [@kcamcam][])

# v4.8.0 / 2023-05-12 [(commits)](https://github.com/whitesmith/rubycritic/compare/v4.7.0...v4.8.0)

* [CHORE] Fix syntax of contributor references in this file
Expand Down
10 changes: 8 additions & 2 deletions lib/rubycritic/generators/html/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,11 +239,16 @@ $("#codeTable")
sortList: [[0,1]]
});

$("#js-index-table")
$("#smellsTable")
.tablesorter({ // Sort the table
sortList: [[0,0]]
});

$("#coverageTable")
.tablesorter({ // Sort the table
sortList: [[0,1]]
});

$(".js-timeago").timeago();

$(function(){
Expand Down Expand Up @@ -277,5 +282,6 @@ $(document).ready(function(){

var initTableFilters = function() {
$("#codeTable").filterTable({ignoreColumns: [2], placeholder: 'Filter by Name'});
$("#js-index-table").filterTable({ignoreColumns: [2, 3, 4, 5], placeholder: 'Filter by Smell or Location', inputSelector: 'form-control'});
$("#smellsTable").filterTable({ignoreColumns: [2, 3, 4, 5], placeholder: 'Filter by Smell or Location', inputSelector: 'form-control'});
$("#coverageTable").filterTable({ignoreColumns: [0], placeholder: 'Filter by Smell or Location', inputSelector: 'form-control'});
}
29 changes: 16 additions & 13 deletions lib/rubycritic/generators/html/templates/simple_cov_index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</div>
<!--End Page Title -->
<div class="Content_Wrapper">
<table id="js-index-table" class="table coverage-index-table index-table sortable-table">
<table id="coverageTable" class="table index-table sortable-table tablesorter">
<thead>
<tr>
<% unless Config.suppress_ratings %>
Expand All @@ -20,20 +20,23 @@
</thead>
<% @analysed_modules.each do |analysed_module| %>
<tr>
<tr>
<% unless Config.suppress_ratings %>
<td>
<div class="rating <%= analysed_module.coverage_rating.to_s.downcase %>"><%= analysed_module.coverage_rating %></div>
</td>
<% end %>
<% unless Config.suppress_ratings %>
<td>
<ul class="nav nav-pills">
<li role="presentation" >
<a href="<%= file_path(analysed_module.pathname.sub_ext('.html')) %>"><%= analysed_module.name %></a>
</li>
</ul>
<div class="rating <%= analysed_module.coverage_rating.to_s.downcase %>">
<%= analysed_module.coverage_rating %>
</div>
</td>
<td><%= '%g' % analysed_module.coverage %>%</td>
<% end %>
<td>
<ul class="nav nav-pills">
<li role="presentation" >
<a href="<%= file_path(analysed_module.pathname.sub_ext('.html')) %>">
<%= analysed_module.name %>
</a>
</li>
</ul>
</td>
<td><%= '%.2f' % analysed_module.coverage %>%</td>
</tr>
<% end %>
</table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</div>
<!--End Page Title -->
<div class="Content_Wrapper">
<table id="js-index-table" class="table smells-index-table index-table sortable-table">
<table id="smellsTable" class="table smells-index-table index-table sortable-table">
<thead>
<tr>
<th width="30%" class="table-header">Smell<span class="sort-type"></span></th>
Expand Down

0 comments on commit 95e7105

Please sign in to comment.