Skip to content

Commit

Permalink
Merge pull request #113 from jmkoni/hide-columns-in-reviews
Browse files Browse the repository at this point in the history
add script to hide columns in reviews list
  • Loading branch information
jmkoni authored Jul 26, 2019
2 parents 6d3d5fd + f1a4134 commit 85f5e17
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 22 deletions.
6 changes: 3 additions & 3 deletions app/views/courses/_list.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
<th scope="col"><%= filterrific_sorting_link(@filterrific, :school) %></th>
<th scope="col">
<%= filterrific_sorting_link(@filterrific, :avg_rating) %>
<i title="1 - bad, 10 - great, relevant to each individual students' experience" class="fal fa-question-circle"></i>
<small><i title="1 - bad, 10 - great, based on individual students' experience" class="fal fa-question-circle"></i></small>
</th>
<th scope="col">
<%= filterrific_sorting_link(@filterrific, :avg_difficulty) %>
<i title="1 - easy, 10 - difficult, based on individual students' perceptions" class="fal fa-question-circle"></i>
<small><i title="1 - easy, 10 - difficult, based on individual students' perceptions" class="fal fa-question-circle"></i></small>
</th>
<th scope="col">
<%= filterrific_sorting_link(@filterrific, :avg_work) %>
<i title="in hours/week" class="fal fa-question-circle"></i>
<small><i title="in hours/week" class="fal fa-question-circle"></i></small>
</th>
<th scope="col"><%= filterrific_sorting_link(@filterrific, :avg_grade) %></th>
<th scope="col" colspan="3"></th>
Expand Down
6 changes: 3 additions & 3 deletions app/views/departments/_list.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
<th scope="col"><%= filterrific_sorting_link(@filterrific, :school) %></th>
<th scope="col">
<%= filterrific_sorting_link(@filterrific, :avg_rating) %>
<i title="1 - bad, 10 - great, relevant to each individual students' experience" class="fal fa-question-circle"></i>
<small><i title="1 - bad, 10 - great, based on individual students' experience" class="fal fa-question-circle"></i></small>
</th>
<th scope="col">
<%= filterrific_sorting_link(@filterrific, :avg_difficulty) %>
<i title="1 - easy, 10 - difficult, based on individual students' perceptions" class="fal fa-question-circle"></i>
<small><i title="1 - easy, 10 - difficult, based on individual students' perceptions" class="fal fa-question-circle"></i></small>
</th>
<th scope="col">
<%= filterrific_sorting_link(@filterrific, :avg_work) %>
<i title="in hours/week" class="fal fa-question-circle"></i>
<small><i title="in hours/week" class="fal fa-question-circle"></i></small>
</th>
<th scope="col"><%= filterrific_sorting_link(@filterrific, :avg_grade) %></th>
<th scope="col" colspan="3"></th>
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@
</div>
</div>
</body>
</html>
</html>
76 changes: 64 additions & 12 deletions app/views/reviews/_list.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,51 @@
<table id="reviews_index" class="reviews table table-hover table-sm table-responsive">
<thead class="thead-light">
<tr>
<th scope="col"><%= filterrific_sorting_link(@filterrific, :school) %></th>
<th scope="col"><%= filterrific_sorting_link(@filterrific, :department) %></th>
<th scope="col"><%= filterrific_sorting_link(@filterrific, :course) %></th>
<th scope="col"><%= filterrific_sorting_link(@filterrific, :user) %></th>
<th scope="col">Notes</th>
<th scope="col"><%= filterrific_sorting_link(@filterrific, :school) %><button class="pull-right btn btn-default btn-condensed hide-column" data-toggle="tooltip" data-placement="bottom" title="Hide Column">
<small><i class="fal fa-eye-slash"></i></small>
</button></th>
<th scope="col"><%= filterrific_sorting_link(@filterrific, :department) %><button class="pull-right btn btn-default btn-condensed hide-column" data-toggle="tooltip" data-placement="bottom" title="Hide Column">
<small><i class="fal fa-eye-slash"></i></small>
</button></th>
<th scope="col"><%= filterrific_sorting_link(@filterrific, :course) %><button class="pull-right btn btn-default btn-condensed hide-column" data-toggle="tooltip" data-placement="bottom" title="Hide Column">
<small><i class="fal fa-eye-slash"></i></small>
</button></th>
<th scope="col"><%= filterrific_sorting_link(@filterrific, :user) %><button class="pull-right btn btn-default btn-condensed hide-column" data-toggle="tooltip" data-placement="bottom" title="Hide Column">
<small><i class="fal fa-eye-slash"></i></small>
</button></th>
<th scope="col">Notes<button class="pull-right btn btn-default btn-condensed hide-column" data-toggle="tooltip" data-placement="bottom" title="Hide Column">
<small><i class="fal fa-eye-slash"></i></small>
</button></th>
<th scope="col">
<%= filterrific_sorting_link(@filterrific, :rating) %>
<i title="1 - bad, 10 - great, relevant to each individual students' experience" class="fal fa-question-circle"></i>
<small><i title="1 - bad, 10 - great, based on individual students' experience" class="fal fa-question-circle"></i></small><button class="pull-right btn btn-default btn-condensed hide-column" data-toggle="tooltip" data-placement="bottom" title="Hide Column">
<small><i class="fal fa-eye-slash"></i></small>
</button>
</th>
<th scope="col">
<%= filterrific_sorting_link(@filterrific, :difficulty) %>
<i title="1 - easy, 10 - difficult, based on individual students' perceptions" class="fal fa-question-circle"></i>
<small><i title="1 - easy, 10 - difficult, based on individual students' perceptions" class="fal fa-question-circle"></i></small><button class="pull-right btn btn-default btn-condensed hide-column" data-toggle="tooltip" data-placement="bottom" title="Hide Column">
<small><i class="fal fa-eye-slash"></i></small>
</button>
</th>
<th scope="col">
<%= filterrific_sorting_link(@filterrific, :work_required) %>
<i title="in hours/week" class="fal fa-question-circle"></i>
<small><i title="in hours/week" class="fal fa-question-circle"></i></small><button class="pull-right btn btn-default btn-condensed hide-column" data-toggle="tooltip" data-placement="bottom" title="Hide Column">
<small><i class="fal fa-eye-slash"></i></small>
</button>
</th>
<th scope="col"><%= filterrific_sorting_link(@filterrific, :experience_with_topic) %></th>
<th scope="col"><%= filterrific_sorting_link(@filterrific, :grade) %></th>
<th scope="col">Year</th>
<th scope="col">Term</th>
<th scope="col"><%= filterrific_sorting_link(@filterrific, :experience_with_topic) %><button class="pull-right btn btn-default btn-condensed hide-column" data-toggle="tooltip" data-placement="bottom" title="Hide Column">
<small><i class="fal fa-eye-slash"></i></small>
</button></th>
<th scope="col"><%= filterrific_sorting_link(@filterrific, :grade) %><button class="pull-right btn btn-default btn-condensed hide-column" data-toggle="tooltip" data-placement="bottom" title="Hide Column">
<small><i class="fal fa-eye-slash"></i></small>
</button></th>
<th scope="col">Year<button class="pull-right btn btn-default btn-condensed hide-column" data-toggle="tooltip" data-placement="bottom" title="Hide Column">
<small><i class="fal fa-eye-slash"></i></small>
</button></th>
<th scope="col">Term<button class="pull-right btn btn-default btn-condensed hide-column" data-toggle="tooltip" data-placement="bottom" title="Hide Column">
<small><i class="fal fa-eye-slash"></i></small>
</button></th>
<th scope="col" colspan="2"></th>
</tr>
</thead>
Expand All @@ -65,7 +89,35 @@
</tr>
<% end %>
</tbody>
<tfoot class="show-column-footer">
<tr>
<th colspan="4"><a class="show-column" href="#">Some columns hidden - click to show all</a></th>
</tr>
</tfoot>
</table>
<%= paginate reviews %>
<% end %>
</div>

<script>
$('.hide-column').click(function(e){
var $btn = $(this);
var $cell = $btn.closest('th,td')
var $table = $btn.closest('table')

// get cell location - https://stackoverflow.com/a/4999018/1366033
var cellIndex = $cell[0].cellIndex + 1;

$table.find(".show-column-footer").show()
$table.find("tbody tr, thead tr")
.children(":nth-child("+cellIndex+")")
.hide()
})

$(".show-column-footer").click(function(e) {
var $table = $(this).closest('table')
$table.find(".show-column-footer").hide()
$table.find("th, td").show()

})
</script>
6 changes: 3 additions & 3 deletions app/views/schools/_list.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
<th scope="col"><%= filterrific_sorting_link(@filterrific, :short_name) %></th>
<th scope="col">
<%= filterrific_sorting_link(@filterrific, :avg_rating) %>
<i title="1 - bad, 10 - great, relevant to each individual students' experience" class="fal fa-question-circle"></i>
<small><i title="1 - bad, 10 - great, based on individual students' experience" class="fal fa-question-circle"></i></small>
</th>
<th scope="col">
<%= filterrific_sorting_link(@filterrific, :avg_difficulty) %>
<i title="1 - easy, 10 - difficult, based on individual students' perceptions" class="fal fa-question-circle"></i>
<small><i title="1 - easy, 10 - difficult, based on individual students' perceptions" class="fal fa-question-circle"></i></small>
</th>
<th scope="col">
<%= filterrific_sorting_link(@filterrific, :avg_work) %>
<i title="in hours/week" class="fal fa-question-circle"></i>
<small><i title="in hours/week" class="fal fa-question-circle"></i></small>
</th>
<th scope="col"><%= filterrific_sorting_link(@filterrific, :avg_grade) %></th>
<th scope="col" colspan="2"></th>
Expand Down

0 comments on commit 85f5e17

Please sign in to comment.