-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from jmkoni/average-ratings
Add averages to courses index
- Loading branch information
Showing
21 changed files
with
389 additions
and
199 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,49 @@ | ||
<% if courses.load.empty? %> | ||
No courses at this time! | ||
<% else %> | ||
<div id="filterrific_results"> | ||
<div class="card card-body bg-light d-block p-3 my-3"> | ||
<div class="row"> | ||
<div class="col-md-10"> | ||
<%= page_entries_info courses, model: 'course', class: 'align-middle' %> | ||
</div> | ||
<div class="col-md-2"> | ||
<%= link_to "Reset filters", reset_filterrific_url, class: 'btn btn-secondary align-middle' %> | ||
</div> | ||
<div id="filterrific_results"> | ||
<div class="card card-body bg-light d-block p-3 my-3"> | ||
<div class="row"> | ||
<div class="col-md-10"> | ||
<% if courses.load.empty? %> | ||
No courses at this time! | ||
<% else %> | ||
Displaying <strong><%= pluralize(courses.size, 'course') %></strong> | ||
<% end %> | ||
</div> | ||
<div class="col-md-2"> | ||
<%= link_to "Reset filters", reset_filterrific_url, class: 'btn btn-secondary align-middle' %> | ||
</div> | ||
<%= render_filterrific_spinner %> | ||
</div> | ||
<table class="table table-hover table-sm table-responsive"> | ||
<thead class="thead-light"> | ||
<%= render_filterrific_spinner %> | ||
</div> | ||
<table class="table table-hover table-sm table-responsive"> | ||
<thead class="thead-light"> | ||
<tr> | ||
<th scope="col"><%= filterrific_sorting_link(@filterrific, :name) %></th> | ||
<th scope="col"><%= filterrific_sorting_link(@filterrific, :number) %></th> | ||
<th scope="col"><%= filterrific_sorting_link(@filterrific, :department) %></th> | ||
<th scope="col"><%= filterrific_sorting_link(@filterrific, :school) %></th> | ||
<th scope="col"><%= filterrific_sorting_link(@filterrific, :avg_rating) %></th> | ||
<th scope="col"><%= filterrific_sorting_link(@filterrific, :avg_difficulty) %></th> | ||
<th scope="col"><%= filterrific_sorting_link(@filterrific, :avg_work) %></th> | ||
<th scope="col" colspan="3"></th> | ||
</tr> | ||
</thead> | ||
|
||
<tbody> | ||
<% courses.each do |course| %> | ||
<tr> | ||
<th scope="col"><%= filterrific_sorting_link(@filterrific, :name) %></th> | ||
<th scope="col"><%= filterrific_sorting_link(@filterrific, :number) %></th> | ||
<th scope="col"><%= filterrific_sorting_link(@filterrific, :department) %></th> | ||
<th scope="col"><%= filterrific_sorting_link(@filterrific, :school) %></th> | ||
<th scope="col" colspan="3"></th> | ||
<td><%= link_to course.name, school_course_path(id: course.id, school_id: course.school.id) %></td> | ||
<td><%= course.number %></td> | ||
<td><%= course.department %></td> | ||
<td><%= link_to course.school.name, school_path(id: course.school) %></td> | ||
<td><%= course.avg_rating.round(1) %></td> | ||
<td><%= course.avg_difficulty.round(1) %></td> | ||
<td><%= course.avg_work.round(1) %></td> | ||
<% if can? :edit, course %> | ||
<td><%= link_to 'Edit', edit_school_course_path(id: course.id, school_id: course.school.id) %></td> | ||
<td><%= link_to 'Destroy', school_course_path(id: course.id, school_id: course.school.id), method: :delete, data: { confirm: 'Are you sure?' } %></td> | ||
<% end %> | ||
</tr> | ||
</thead> | ||
|
||
<tbody> | ||
<% courses.each do |course| %> | ||
<tr> | ||
<td><%= link_to course.name, school_course_path(id: course.id, school_id: course.school.id) %></td> | ||
<td><%= course.number %></td> | ||
<td><%= course.department %></td> | ||
<td><%= link_to course.school.name, school_path(id: course.school) %><td> | ||
<% if can? :edit, course %> | ||
<td><%= link_to 'Edit', edit_school_course_path(id: course.id, school_id: course.school.id) %></td> | ||
<td><%= link_to 'Destroy', school_course_path(id: course.id, school_id: course.school.id), method: :delete, data: { confirm: 'Are you sure?' } %></td> | ||
<% end %> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> | ||
</div> | ||
<%= will_paginate courses, renderer: WillPaginate::ActionView::BootstrapLinkRenderer %> | ||
<% end %> | ||
<% end %> | ||
</tbody> | ||
</table> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<li class="page-item"> | ||
<%= link_to_unless current_page.first?, raw(t 'views.pagination.first'), url, remote: remote, class: 'page-link' %> | ||
</li> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<li class='page-item disabled'> | ||
<%= link_to raw(t 'views.pagination.truncate'), '#', class: 'page-link' %> | ||
</li> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<li class="page-item"> | ||
<%= link_to_unless current_page.last?, raw(t 'views.pagination.last'), url, remote: remote, class: 'page-link' %> | ||
</li> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<li class="page-item"> | ||
<%= link_to_unless current_page.last?, raw(t 'views.pagination.next'), url, rel: 'next', remote: remote, class: 'page-link' %> | ||
</li> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<% if page.current? %> | ||
<li class="page-item active"> | ||
<%= content_tag :a, page, data: { remote: remote }, rel: page.rel, class: 'page-link' %> | ||
</li> | ||
<% else %> | ||
<li class="page-item"> | ||
<%= link_to page, url, remote: remote, rel: page.rel, class: 'page-link' %> | ||
</li> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<%= paginator.render do %> | ||
<nav> | ||
<ul class="pagination"> | ||
<%= first_page_tag unless current_page.first? %> | ||
<%= prev_page_tag unless current_page.first? %> | ||
<% each_page do |page| %> | ||
<% if page.left_outer? || page.right_outer? || page.inside_window? %> | ||
<%= page_tag page %> | ||
<% elsif !page.was_truncated? -%> | ||
<%= gap_tag %> | ||
<% end %> | ||
<% end %> | ||
<%= next_page_tag unless current_page.last? %> | ||
<%= last_page_tag unless current_page.last? %> | ||
</ul> | ||
</nav> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<li class="page-item"> | ||
<%= link_to_unless current_page.first?, raw(t 'views.pagination.previous'), url, rel: 'prev', remote: remote, class: 'page-link' %> | ||
</li> |
Oops, something went wrong.