mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-04-02 04:35:26 +00:00
Removed the use of datatables and added pagination and search on all_matches.
This commit is contained in:
@@ -1,11 +1,5 @@
|
||||
<% if @tournaments.size > 0 %>
|
||||
<h3>My Tournaments</h3>
|
||||
<script>
|
||||
// $(document).ready(function() {
|
||||
// $('#tournamentList').dataTable();
|
||||
// pagingType: "bootstrap";
|
||||
// } );
|
||||
</script>
|
||||
<table class="table table-hover" id="tournamentList">
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
|
||||
|
||||
<h1>All <%= @tournament.name %> matches</h1>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#matchesList').dataTable();
|
||||
pagingType: "bootstrap";
|
||||
} );
|
||||
</script>
|
||||
</br>
|
||||
|
||||
<% matches_path = "/tournaments/#{@tournament.id}/matches" %>
|
||||
|
||||
<%= form_tag(matches_path, method: :get, id: "search-form") do %>
|
||||
<%= text_field_tag :search, params[:search], placeholder: "Search wrestler, school, or bout #" %>
|
||||
<%= submit_tag "Search" %>
|
||||
<% end %>
|
||||
|
||||
<p>Search by wrestler name, school name, or bout number.</p>
|
||||
|
||||
<br>
|
||||
<table class="table table-striped table-bordered table-condensed" id="matchesList">
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -35,6 +37,49 @@
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<% if @total_pages.present? && @total_pages > 1 %>
|
||||
<nav aria-label="Matches pagination">
|
||||
<ul class="pagination">
|
||||
<% if @page > 1 %>
|
||||
<li class="page-item">
|
||||
<%= link_to "Previous", { controller: "tournaments", action: "matches", id: @tournament.id, page: @page - 1, search: params[:search] }, class: "page-link" %>
|
||||
</li>
|
||||
<% else %>
|
||||
<li class="page-item disabled"><span class="page-link">Previous</span></li>
|
||||
<% end %>
|
||||
|
||||
<% window = 5
|
||||
left = [1, @page - window / 2].max
|
||||
right = [@total_pages, left + window - 1].min
|
||||
left = [1, right - window + 1].max
|
||||
%>
|
||||
<% (left..right).each do |p| %>
|
||||
<% if p == @page %>
|
||||
<li class="page-item active"><span class="page-link"><%= p %></span></li>
|
||||
<% else %>
|
||||
<li class="page-item"><%= link_to p, { controller: "tournaments", action: "matches", id: @tournament.id, page: p, search: params[:search] }, class: "page-link" %></li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% if @page < @total_pages %>
|
||||
<li class="page-item">
|
||||
<%= link_to "Next", { controller: "tournaments", action: "matches", id: @tournament.id, page: @page + 1, search: params[:search] }, class: "page-link" %>
|
||||
</li>
|
||||
<% else %>
|
||||
<li class="page-item disabled"><span class="page-link">Next</span></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</nav>
|
||||
|
||||
<p class="text-muted">
|
||||
<% start_index = ((@page - 1) * @per_page) + 1
|
||||
end_index = [@page * @per_page, @total_count].min
|
||||
%>
|
||||
Showing <%= start_index %> - <%= end_index %> of <%= @total_count %> matches
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
<br>
|
||||
<p>Total matches without byes: <%= @matches.select{|m| m.loser1_name != 'BYE' and m.loser2_name != 'BYE'}.size %></p>
|
||||
<p>Unfinished matches: <%= @matches.select{|m| m.finished != 1 and m.loser1_name != 'BYE' and m.loser2_name != 'BYE'}.size %></p>
|
||||
<p>Total matches without byes: <%= @matches_without_byes_count %></p>
|
||||
<p>Unfinished matches: <%= @unfinished_matches_without_byes_count %></p>
|
||||
|
||||
@@ -1,8 +1,3 @@
|
||||
<script>
|
||||
// $(document).ready(function() {
|
||||
// $('#matchList').dataTable();
|
||||
// } );
|
||||
</script>
|
||||
<script>
|
||||
const setUpMatchesRefresh = () => {
|
||||
if (window.__upMatchesRefreshTimeout) {
|
||||
|
||||
Reference in New Issue
Block a user