Pagination
This commit is contained in:
parent
b49c582c6e
commit
457533154a
|
@ -8,7 +8,7 @@ class Admin::BooksController < OrbitMemberController
|
||||||
before_action :set_plugin
|
before_action :set_plugin
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@writing_books = Book.all
|
@writing_books = Book.order_by(:year=>'desc').page(params[:page]).per(10)
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html # index.html.erb
|
format.html # index.html.erb
|
||||||
format.js { }
|
format.js { }
|
||||||
|
|
|
@ -1,16 +1,23 @@
|
||||||
class BooksController < ApplicationController
|
class BooksController < ApplicationController
|
||||||
def index
|
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_list = books.collect do |book|
|
||||||
{
|
{
|
||||||
"book_title" => book.book_title,
|
"book_title" => book.book_title,
|
||||||
"authors" => book.authors,
|
"author" => book.authors,
|
||||||
|
"year" => book.year,
|
||||||
"link_to_show" => OrbitHelper.url_to_show(book.to_param)
|
"link_to_show" => OrbitHelper.url_to_show(book.to_param)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
{
|
{
|
||||||
"books" => book_list,
|
"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
|
end
|
||||||
|
|
||||||
|
|
|
@ -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"><%= writing_book.year %></td>
|
||||||
<td class="span1">
|
<td class="span1">
|
||||||
<%= link_to writing_book.create_link, page_for_book(writing_book), target: "blank" %>
|
<%= link_to writing_book.create_link, page_for_book(writing_book), target: "blank" %>
|
||||||
|
@ -12,4 +13,5 @@
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td class="span1"><%= writing_book.authors%></td>
|
<td class="span1"><%= writing_book.authors%></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<% end %>
|
|
@ -7,7 +7,7 @@
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody id="tbody_writing_books" class="sort-holder">
|
<tbody id="tbody_writing_books" class="sort-holder">
|
||||||
<%= render :partial => 'writing_book', :collection => @writing_books %>
|
<%= render 'writing_book' %>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</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-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' %>
|
<%= 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>
|
||||||
|
<div class="pagination pagination-centered">
|
||||||
|
<%= content_tag :div, paginate(@writing_books), class: "pagination pagination-centered" %>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
|
@ -13,6 +13,7 @@ module PersonalBook
|
||||||
update_info 'some update_info'
|
update_info 'some update_info'
|
||||||
frontend_enabled
|
frontend_enabled
|
||||||
icon_class_no_sidebar "icons-user"
|
icon_class_no_sidebar "icons-user"
|
||||||
|
data_count 1..10
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue