From f87acca529de3a75f11887c71230ab8eb0db13b5 Mon Sep 17 00:00:00 2001 From: manson Date: Fri, 18 Jul 2014 15:04:07 +0800 Subject: [PATCH] Pagination --- .../admin/journal_papers_controller.rb | 2 +- app/controllers/journal_papers_controller.rb | 13 +++++++-- .../journal_papers/_writing_journal.html.erb | 29 ++++++++++--------- app/views/admin/journal_papers/index.html.erb | 3 +- lib/personal_journal/engine.rb | 1 + 5 files changed, 29 insertions(+), 19 deletions(-) diff --git a/app/controllers/admin/journal_papers_controller.rb b/app/controllers/admin/journal_papers_controller.rb index 4576601..2b47643 100644 --- a/app/controllers/admin/journal_papers_controller.rb +++ b/app/controllers/admin/journal_papers_controller.rb @@ -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 { } diff --git a/app/controllers/journal_papers_controller.rb b/app/controllers/journal_papers_controller.rb index 4739304..c7aa0ab 100644 --- a/app/controllers/journal_papers_controller.rb +++ b/app/controllers/journal_papers_controller.rb @@ -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 diff --git a/app/views/admin/journal_papers/_writing_journal.html.erb b/app/views/admin/journal_papers/_writing_journal.html.erb index c19325e..a365844 100644 --- a/app/views/admin/journal_papers/_writing_journal.html.erb +++ b/app/views/admin/journal_papers/_writing_journal.html.erb @@ -1,14 +1,15 @@ - - - <%= writing_journal.year %> - - <%= link_to writing_journal.create_link, page_for_journal_paper(writing_journal), target: "blank"%> -
- -
- - <%= writing_journal.authors%> - \ No newline at end of file +<% @writing_journals.each do |writing_journal| %> + + <%= writing_journal.year %> + + <%= link_to writing_journal.create_link, page_for_journal_paper(writing_journal), target: "blank"%> +
+ +
+ + <%= writing_journal.authors%> + +<% end %> \ No newline at end of file diff --git a/app/views/admin/journal_papers/index.html.erb b/app/views/admin/journal_papers/index.html.erb index 52f0f70..ca1d9eb 100644 --- a/app/views/admin/journal_papers/index.html.erb +++ b/app/views/admin/journal_papers/index.html.erb @@ -7,7 +7,7 @@ - <%= render :partial => 'writing_journal', :collection => @writing_journals %> + <%= render 'writing_journal' %> @@ -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' %> \ No newline at end of file diff --git a/lib/personal_journal/engine.rb b/lib/personal_journal/engine.rb index 0eca3c0..5536ba6 100644 --- a/lib/personal_journal/engine.rb +++ b/lib/personal_journal/engine.rb @@ -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