Pagination

This commit is contained in:
manson 2014-07-18 14:29:33 +08:00
parent b49c582c6e
commit 457533154a
5 changed files with 33 additions and 20 deletions

View File

@ -8,7 +8,7 @@ class Admin::BooksController < OrbitMemberController
before_action :set_plugin
def index
@writing_books = Book.all
@writing_books = Book.order_by(:year=>'desc').page(params[:page]).per(10)
respond_to do |format|
format.html # index.html.erb
format.js { }

View File

@ -1,16 +1,23 @@
class BooksController < ApplicationController
def index
books = Book.asc(:created_at)
books = Book.order_by(:year=>'desc').page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count)
book_list = books.collect do |book|
{
"book_title" => book.book_title,
"authors" => book.authors,
"author" => book.authors,
"year" => book.year,
"link_to_show" => OrbitHelper.url_to_show(book.to_param)
}
end
{
"books" => book_list,
"extras" => {"widget-title" => "Books"}
"extras" => {
"widget-title" => t("module_name.book"),
"th_year" => t('personal_plugins.year'),
"th_title" => t("personal_book.book_title"),
"th_author" => t('personal_plugins.author')
},
"total_pages" => books.total_pages
}
end

View File

@ -1,4 +1,5 @@
<tr id="<%= dom_id writing_book %>" class="with_action">
<% @writing_books.each do |writing_book| %>
<tr id="<%= dom_id writing_book %>" class="with_action">
<td class="span1"><%= writing_book.year %></td>
<td class="span1">
<%= link_to writing_book.create_link, page_for_book(writing_book), target: "blank" %>
@ -12,4 +13,5 @@
</div>
</td>
<td class="span1"><%= writing_book.authors%></td>
</tr>
</tr>
<% end %>

View File

@ -7,7 +7,7 @@
</tr>
</thead>
<tbody id="tbody_writing_books" class="sort-holder">
<%= render :partial => 'writing_book', :collection => @writing_books %>
<%= render 'writing_book' %>
</tbody>
</table>
@ -16,4 +16,7 @@
<%= link_to content_tag(:i, nil, :class => 'icon-cog icon-white') + t('setting'), admin_book_setting_path, :class => 'btn btn-primary pull-right' %>
<%= link_to content_tag(:i, nil, :class => 'icon-plus icon-white') + t('announcement.add_new'), new_admin_book_path, :class => 'btn btn-primary pull-right' %>
</div>
<div class="pagination pagination-centered">
<%= content_tag :div, paginate(@writing_books), class: "pagination pagination-centered" %>
</div>
</div>

View File

@ -13,6 +13,7 @@ module PersonalBook
update_info 'some update_info'
frontend_enabled
icon_class_no_sidebar "icons-user"
data_count 1..10
end
end
end