adds pagination to admin lists

Ref: #80
This commit is contained in:
Juanjo Bazán
2015-08-19 14:08:22 +02:00
committed by Juanjo Bazán
parent a43c753ebb
commit fda8412ed3
8 changed files with 20 additions and 6 deletions

View File

@@ -1,7 +1,7 @@
class Admin::CommentsController < Admin::BaseController class Admin::CommentsController < Admin::BaseController
def index def index
@comments = Comment.only_hidden @comments = Comment.only_hidden.page(params[:page])
end end
def restore def restore

View File

@@ -1,7 +1,7 @@
class Admin::DebatesController < Admin::BaseController class Admin::DebatesController < Admin::BaseController
def index def index
@debates = Debate.only_hidden @debates = Debate.only_hidden.page(params[:page])
end end
def show def show

View File

@@ -6,7 +6,7 @@ class Admin::OrganizationsController < Admin::BaseController
def index def index
@organizations = @organizations.send(@filter) @organizations = @organizations.send(@filter)
@organizations = @organizations.includes(:user).order(:name, 'users.email') @organizations = @organizations.includes(:user).order(:name, 'users.email').page(params[:page])
end end
def verify def verify

View File

@@ -4,7 +4,7 @@ class Admin::TagsController < Admin::BaseController
respond_to :html, :js respond_to :html, :js
def index def index
@tags = ActsAsTaggableOn::Tag.order(featured: :desc) @tags = ActsAsTaggableOn::Tag.order(featured: :desc).page(params[:page])
@tag = ActsAsTaggableOn::Tag.new @tag = ActsAsTaggableOn::Tag.new
end end

View File

@@ -1,5 +1,7 @@
<h2><%= t("admin.comments.index.title") %></h2> <h2><%= t("admin.comments.index.title") %></h2>
<h3><%= page_entries_info @comments %></h3>
<ul class="admin-list"> <ul class="admin-list">
<% @comments.each do |comment| %> <% @comments.each do |comment| %>
<li id="<%= dom_id(comment) %>"> <li id="<%= dom_id(comment) %>">
@@ -16,3 +18,5 @@
</li> </li>
<% end %> <% end %>
</ul> </ul>
<%= paginate @comments %>

View File

@@ -1,5 +1,7 @@
<h2><%= t("admin.debates.index.title") %></h2> <h2><%= t("admin.debates.index.title") %></h2>
<h3><%= page_entries_info @debates %></h3>
<ul class="admin-list"> <ul class="admin-list">
<% @debates.each do |debate| %> <% @debates.each do |debate| %>
<li id="<%= dom_id(debate) %>"> <li id="<%= dom_id(debate) %>">
@@ -11,3 +13,5 @@
</li> </li>
<% end %> <% end %>
</ul> </ul>
<%= paginate @debates %>

View File

@@ -13,6 +13,8 @@
<% end %> <% end %>
</p> </p>
<h3><%= page_entries_info @organizations %></h3>
<table> <table>
<% @organizations.each do |organization| %> <% @organizations.each do |organization| %>
<tr> <tr>
@@ -41,4 +43,6 @@
<% end %> <% end %>
</tr> </tr>
<% end %> <% end %>
</table> </table>
<%= paginate @organizations %>

View File

@@ -20,7 +20,7 @@
<% end %> <% end %>
<h3><%= t("admin.tags.index.title") %></h3> <h3><%= t("admin.tags.index.title") %>: <%= page_entries_info @tags %></h3>
<ul class="admin-list"> <ul class="admin-list">
<% @tags.each do |tag| %> <% @tags.each do |tag| %>
@@ -44,3 +44,5 @@
</li> </li>
<% end %> <% end %>
</ul> </ul>
<%= paginate @tags %>