Pagination

This commit is contained in:
manson 2014-07-18 15:04:07 +08:00
parent 32ffdce5d2
commit f87acca529
5 changed files with 29 additions and 19 deletions

View File

@ -10,7 +10,7 @@ class Admin::JournalPapersController < OrbitMemberController
def index
@writing_journals = JournalPaper.all
@writing_journals = JournalPaper.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 JournalPapersController < ApplicationController
def index
journal_papers = JournalPaper.asc(:created_at)
journal_papers = JournalPaper.where(:is_hidden=>false).order_by(:year=>'desc').page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count)
journal_paper_list = journal_papers.collect do |journal_paper|
{
"year" => journal_paper.year,
"paper_title" => journal_paper.paper_title,
"authors" => journal_paper.authors,
"author" => journal_paper.authors,
"link_to_show" => OrbitHelper.url_to_show(journal_paper.to_param)
}
end
{
"journal_papers" => journal_paper_list,
"extras" => {"widget-title" => "Journal Papers"}
"extras" => {
"widget-title" => t("module_name.journal_paper"),
"th_year" => t('personal_plugins.year'),
"th_title" => t("personal_conference.paper_title"),
"th_author" => t('personal_plugins.author')
},
"total_pages" => journal_papers.total_pages
}
end

View File

@ -1,14 +1,15 @@
<tr id="<%= dom_id writing_journal %>" class="with_action">
<td class="span1"><%= writing_journal.year %></td>
<td class="span1">
<%= link_to writing_journal.create_link, page_for_journal_paper(writing_journal), target: "blank"%>
<div class="quick-edit">
<ul class="nav nav-pills hide">
<li><%= link_to t('edit'), edit_admin_journal_paper_path(writing_journal) %></li>
<li><%= link_to t(:delete_), admin_journal_paper_path(id: writing_journal.id), method: :delete, remote: true, data: { confirm: 'Are you sure?' } %></li>
</ul>
</div>
</td>
<td class="span1"><%= writing_journal.authors%></td>
</tr>
<% @writing_journals.each do |writing_journal| %>
<tr id="<%= dom_id writing_journal %>" class="with_action">
<td class="span1"><%= writing_journal.year %></td>
<td class="span1">
<%= link_to writing_journal.create_link, page_for_journal_paper(writing_journal), target: "blank"%>
<div class="quick-edit">
<ul class="nav nav-pills hide">
<li><%= link_to t('edit'), edit_admin_journal_paper_path(writing_journal) %></li>
<li><%= link_to t(:delete_), admin_journal_paper_path(id: writing_journal.id), method: :delete, remote: true, data: { confirm: 'Are you sure?' } %></li>
</ul>
</div>
</td>
<td class="span1"><%= writing_journal.authors%></td>
</tr>
<% end %>

View File

@ -7,7 +7,7 @@
</tr>
</thead>
<tbody id="tbody_writing_journals" class="sort-holder">
<%= render :partial => 'writing_journal', :collection => @writing_journals %>
<%= render 'writing_journal' %>
</tbody>
</table>
@ -17,5 +17,6 @@
<%= link_to content_tag(:i, nil, :class => 'icon-plus icon-white') + t('announcement.add_new'), new_admin_journal_paper_path, :class => 'btn btn-primary pull-right' %>
</div>
<div class="pagination pagination-centered">
<%= content_tag :div, paginate(@writing_journals), class: "pagination pagination-centered" %>
</div>
</div>

View File

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