Skip to content
This repository has been archived by the owner on Jul 24, 2020. It is now read-only.

[1378] Improve user profile history tables [v5.5] #1407

Merged
merged 1 commit into from
Jan 6, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ gem 'nilify_blanks', '~> 1.2.0'
# ui
gem 'jquery-rails', '~> 3.1.2'
gem 'jquery-ui-rails', '~> 5.0.3'
gem 'jquery-datatables-rails', '~> 3.1.1'
gem 'rails4-autocomplete', '~> 1.1.1'
gem 'select2-rails', '~> 3.5.9.3'
gem 'kaminari', '~> 0.16.3'
Expand Down
6 changes: 0 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,6 @@ GEM
activesupport (>= 4.1.9)
loofah (>= 2.0)
nokogiri (~> 1.6)
jquery-datatables-rails (3.1.1)
actionpack (>= 3.1)
jquery-rails
railties (>= 3.1)
sass-rails
jquery-rails (3.1.2)
railties (>= 3.0, < 5.0)
thor (>= 0.14, < 2.0)
Expand Down Expand Up @@ -438,7 +433,6 @@ DEPENDENCIES
guard-rspec (~> 4.5.0)
highline (~> 1.7.2)
inline_svg
jquery-datatables-rails (~> 3.1.1)
jquery-rails (~> 3.1.2)
jquery-ui-rails (~> 5.0.3)
kaminari (~> 0.16.3)
Expand Down
15 changes: 13 additions & 2 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//= require jquery
//= require jquery_ujs
//= require dataTables/jquery.dataTables
//= require dataTables/bootstrap/3/jquery.dataTables.bootstrap
//= require datatables.min.js
//= require jquery-ui/datepicker
//= require jquery-ui/autocomplete
//= require cocoon
Expand Down Expand Up @@ -88,6 +87,18 @@ $(document).ready(function() {
]
});

// For DataTables in Bootstrap tabs
// see https://datatables.net/examples/api/tabs_and_scrolling.html
$('a[data-toggle="tab"]').on( 'shown.bs.tab', function (e) {
$.fn.dataTable.tables( {visible: true, api: true} ).columns.adjust();
} );

// User profile history datatable default sorting
$("#res-history-checked_out").DataTable().order([3, "asc"]).draw();
$("#res-history-future").DataTable().order([2, "asc"]).draw();
$("#res-history-overdue,#res-history-past,#res-history-past_overdue").DataTable().order([4, "desc"]).draw();


// ### REPORTS JS ### //

$('.report_table').dataTable({
Expand Down
2 changes: 1 addition & 1 deletion app/assets/stylesheets/_bootstrap_and_overrides.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ body {
}

@import "font-awesome";
@import "dataTables/bootstrap/3/jquery.dataTables.bootstrap";
@import "datatables.min";
3 changes: 2 additions & 1 deletion app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ def show
if @user.role == 'banned' && @user.id != current_user.id
flash[:error] = 'Please note that this user is banned.'
end
@user_reservations = @user.reservations
@user_reservations = @user.reservations.includes(:equipment_item,
:equipment_model)
@all_equipment = Reservation.active.for_reserver(@user)
@show_equipment = { checked_out: @user_reservations.checked_out,
overdue: @user_reservations.overdue,
Expand Down
18 changes: 13 additions & 5 deletions app/views/users/_history_table.html.erb
Original file line number Diff line number Diff line change
@@ -1,29 +1,37 @@
<table class="history_table table table-striped table-bordered">
<table id=<%= "res-history-#{key}" %> class="datatable table table-striped table-bordered">
<thead>
<tr>
<th>Reservation #</th>
<th>Equipment</th>
<% unless key == (:current_reservations || :missed_reservations) %>
<% unless [:future, :missed].include?(key) %>
<th>Item</th>
<% end %>
<th>Start Date</th>
<th>Due Date</th>
<% if key.to_s.include?('past') %>
<th>Checked In</th>
<% else %>
<th>Due Date</th>
<% end %>
</tr>
</thead>
<tbody>
<% value.each do |reservation| %>
<tr>
<td><%= link_to reservation.id, reservation %></td>
<td><%= link_to reservation.equipment_model.name, reservation.equipment_model %></td>
<% unless key == (:current_reservations || :missed_reservations) %>
<% unless [:future, :missed].include?(key) %>
<td>
<% unless reservation.equipment_item.nil? %>
<%= link_to_if (can? :manage, Reservation), reservation.equipment_item.name %>
<% end %>
</td>
<% end %>
<td><%= reservation.start_date.to_s(:long) %></td>
<td><%= reservation.due_date.to_s(:long) %></td>
<% if key.to_s.include?('past') %>
<td><%= reservation.checked_in.to_s(:long) %></td>
<% else %>
<td><%= reservation.due_date.to_s(:long) %></td>
<% end %>
</tr>
<% end %>
</tbody>
Expand Down
189 changes: 189 additions & 0 deletions vendor/assets/javascripts/datatables.min.js

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions vendor/assets/stylesheets/datatables.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.