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 def index
@writing_journals = JournalPaper.all @writing_journals = JournalPaper.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 { }

View File

@ -1,16 +1,23 @@
class JournalPapersController < ApplicationController class JournalPapersController < ApplicationController
def index 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| journal_paper_list = journal_papers.collect do |journal_paper|
{ {
"year" => journal_paper.year,
"paper_title" => journal_paper.paper_title, "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) "link_to_show" => OrbitHelper.url_to_show(journal_paper.to_param)
} }
end end
{ {
"journal_papers" => journal_paper_list, "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 end

View File

@ -1,5 +1,5 @@
<% @writing_journals.each do |writing_journal| %>
<tr id="<%= dom_id writing_journal %>" class="with_action"> <tr id="<%= dom_id writing_journal %>" class="with_action">
<td class="span1"><%= writing_journal.year %></td> <td class="span1"><%= writing_journal.year %></td>
<td class="span1"> <td class="span1">
<%= link_to writing_journal.create_link, page_for_journal_paper(writing_journal), target: "blank"%> <%= link_to writing_journal.create_link, page_for_journal_paper(writing_journal), target: "blank"%>
@ -12,3 +12,4 @@
</td> </td>
<td class="span1"><%= writing_journal.authors%></td> <td class="span1"><%= writing_journal.authors%></td>
</tr> </tr>
<% end %>

View File

@ -7,7 +7,7 @@
</tr> </tr>
</thead> </thead>
<tbody id="tbody_writing_journals" class="sort-holder"> <tbody id="tbody_writing_journals" class="sort-holder">
<%= render :partial => 'writing_journal', :collection => @writing_journals %> <%= render 'writing_journal' %>
</tbody> </tbody>
</table> </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' %> <%= 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>
<div class="pagination pagination-centered"> <div class="pagination pagination-centered">
<%= content_tag :div, paginate(@writing_journals), class: "pagination pagination-centered" %>
</div> </div>
</div> </div>

View File

@ -13,6 +13,7 @@ module PersonalJournal
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