- <%= render 'layouts/sidebar' %> - <% end %> -
- <%= render 'layouts/sidebar' %> - <% end %> -
diff --git a/Gemfile b/Gemfile index 2603e80a..1e13303e 100644 --- a/Gemfile +++ b/Gemfile @@ -7,6 +7,7 @@ gem 'sass-rails' gem 'uglifier' gem 'coffee-rails' gem 'jquery-rails' +gem 'jquery-datatables' gem 'jbuilder' gem 'bootstrap-sass' gem 'simple_form' diff --git a/Gemfile.lock b/Gemfile.lock index 003dcddf..6bc8bc0e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -159,6 +159,7 @@ GEM jbuilder (2.4.1) activesupport (>= 3.0.0, < 5.1) multi_json (~> 1.2) + jquery-datatables (1.10.19.1) jquery-rails (4.1.1) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) @@ -358,6 +359,7 @@ DEPENDENCIES factory_girl_rails highline jbuilder + jquery-datatables jquery-rails mysql2 (~> 0.4.10) newrelic_rpm @@ -396,4 +398,4 @@ RUBY VERSION ruby 2.3.0p0 BUNDLED WITH - 1.14.5 + 1.17.3 diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index ebfd1166..35999c03 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -14,6 +14,7 @@ //= require jquery_ujs //= require bootstrap //= require turbolinks +//= require datatables //= require_tree . $(document).on("ready page:change", function(){ @@ -57,4 +58,11 @@ function _toggleText(el, opt1, opt2){ var $el = $(el); if($el.html().trim() == opt1.trim()) $el.html(opt2); else if($el.html().trim() == opt2.trim()) $el.html(opt1); -} \ No newline at end of file +} + +$(document).ready(function () { + $('#tasks').DataTable({ + "ordering": false +}); +}); + diff --git a/app/assets/javascripts/datatables.js b/app/assets/javascripts/datatables.js new file mode 100644 index 00000000..d5cfb74b --- /dev/null +++ b/app/assets/javascripts/datatables.js @@ -0,0 +1,65 @@ +//= require datatables/jquery.dataTables + +// optional change '//' --> '//=' to enable + +// require datatables/extensions/AutoFill/dataTables.autoFill +// require datatables/extensions/Buttons/dataTables.buttons +// require datatables/extensions/Buttons/buttons.html5 +// require datatables/extensions/Buttons/buttons.print +// require datatables/extensions/Buttons/buttons.colVis +// require datatables/extensions/Buttons/buttons.flash +// require datatables/extensions/ColReorder/dataTables.colReorder +// require datatables/extensions/FixedColumns/dataTables.fixedColumns +// require datatables/extensions/FixedHeader/dataTables.fixedHeader +// require datatables/extensions/KeyTable/dataTables.keyTable +// require datatables/extensions/Responsive/dataTables.responsive +// require datatables/extensions/RowGroup/dataTables.rowGroup +// require datatables/extensions/RowReorder/dataTables.rowReorder +// require datatables/extensions/Scroller/dataTables.scroller +// require datatables/extensions/Select/dataTables.select + +//= require datatables/dataTables.bootstrap4 +// require datatables/extensions/AutoFill/autoFill.bootstrap4 +// require datatables/extensions/Buttons/buttons.bootstrap4 +// require datatables/extensions/Responsive/responsive.bootstrap4 + + +//Global setting and initializer + +$.extend( $.fn.dataTable.defaults, { + responsive: true, + pagingType: 'full', + //dom: + // "<'row'<'col-sm-4 text-left'f><'right-action col-sm-8 text-right'<'buttons'B> <'select-info'> >>" + + // "<'row'<'dttb col-12 px-0'tr>>" + + // "<'row'<'col-sm-12 table-footer'lip>>" +}); + + +$(document).on('preInit.dt', function(e, settings) { + var api, table_id, url; + api = new $.fn.dataTable.Api(settings); + table_id = "#" + api.table().node().id; + url = $(table_id).data('source'); + if (url) { + return api.ajax.url(url); + } +}); + + +// init on turbolinks load +$(document).on('turbolinks:load', function() { + if (!$.fn.DataTable.isDataTable("table[id^=dttb-]")) { + $("table[id^=dttb-]").DataTable(); + } +}); + +// turbolinks cache fix +$(document).on('turbolinks:before-cache', function() { + var dataTable = $($.fn.dataTable.tables(true)).DataTable(); + if (dataTable !== null) { + dataTable.clear(); + dataTable.destroy(); + return dataTable = null; + } +}); diff --git a/app/assets/stylesheets/application.css.scss b/app/assets/stylesheets/application.css.scss index cbc93a82..c0e06bb9 100644 --- a/app/assets/stylesheets/application.css.scss +++ b/app/assets/stylesheets/application.css.scss @@ -10,41 +10,43 @@ * *= require_self *= require_tree . + *= require datatables */ -@import "bootstrap"; +@import 'bootstrap'; +@import 'datatables'; body { padding-bottom: 30px; } -.alert-inline{ +.alert-inline { margin: 4px; padding: 10px; } -.full-width{ +.full-width { width: 100%; } -.cart-item{ +.cart-item { padding: 8px 4px 8px 4px; border-top: 1px solid lightgrey; width: 100%; margin: 0; } -.cart-item div{ +.cart-item div { padding: 0; } -.cart-warning{ +.cart-warning { background-color: #fcf3dd; } -.cart-button{ +.cart-button { width: 33%; white-space: normal; height: 55px; border-color: #1d4b97; -} \ No newline at end of file +} diff --git a/app/assets/stylesheets/datatables.scss b/app/assets/stylesheets/datatables.scss new file mode 100644 index 00000000..5d298609 --- /dev/null +++ b/app/assets/stylesheets/datatables.scss @@ -0,0 +1,15 @@ +@import 'datatables/dataTables.bootstrap4'; + +// optional remove '//=' to enable + +//@import 'datatables/extensions/AutoFill/autoFill.bootstrap4'; +//@import 'datatables/extensions/Buttons/buttons.bootstrap4'; +//@import 'datatables/extensions/ColReorder/colReorder.bootstrap4'; +//@import 'datatables/extensions/FixedColumns/fixedColumns.bootstrap4'; +//@import 'datatables/extensions/FixedHeader/fixedHeader.bootstrap4'; +//@import 'datatables/extensions/KeyTable/keyTable.bootstrap4'; +//@import 'datatables/extensions/Responsive/responsive.bootstrap4'; +//@import 'datatables/extensions/RowGroup/rowGroup.bootstrap4'; +//@import 'datatables/extensions/RowReorder/rowReorder.bootstrap4'; +//@import 'datatables/extensions/Scroller/scroller.bootstrap4'; +//@import 'datatables/extensions/Select/select.bootstrap4'; diff --git a/app/views/home/_quick_links.html.erb b/app/views/home/_quick_links.html.erb index 9141aa52..0d440aa2 100644 --- a/app/views/home/_quick_links.html.erb +++ b/app/views/home/_quick_links.html.erb @@ -2,7 +2,7 @@
<%= link_to "Login to Begin", main_app.user_omniauth_authorize_path(:shibboleth), :class => "btn btn-success" %>
@@ -11,45 +11,69 @@Please login to continue.
<% end %> <% elsif user_signed_in? and !current_user.participant.has_signed_waiver? then %> -<%= link_to "Sign Waiver", new_waiver_path, :class => "btn btn-success" %>
-<%= link_to "Charges", charges_path, :class => "btn btn-primary" %>
- <% end %> - <% if can?(:downtime, OrganizationTimelineEntry) %> -<%= link_to "Downtime", downtime_index_path, :class => "btn btn-primary" %>
- <% end %> - <% if can?(:read, Faq) %> -<%= link_to "FAQs", faqs_path, :class => "btn btn-primary" %>
- <% end %> - <% if can?(:read, Shift) %> -<%= link_to "Shifts", shifts_path, :class => "btn btn-primary" %>
+ <% if can?(:read, Faq) && %> + <%= link_to "FAQs", faqs_path, :class => "btn btn-primary" %> <% end %> - <% if can?(:read, Task) %> -<%= link_to "Tasks", tasks_path, :class => "btn btn-primary" %>
- <% end %> - <% if can?(:structural, OrganizationTimelineEntry) %> -<%= link_to "Structural Queue", structural_path, :class => "btn btn-primary" %>
- <% end %> - <% if can?(:electrical, OrganizationTimelineEntry) %> -<%= link_to "Electrical Queue", electrical_path, :class => "btn btn-primary" %>
- <% end %> +