add pagination for personal plugin

This commit is contained in:
Rueshyna 2013-03-08 12:00:44 +08:00 committed by Matt K. Fu
parent d840b82fa9
commit e9ddb85734
6 changed files with 32 additions and 6 deletions

View File

@ -1,8 +1,11 @@
class Panel::PersonalConference::Desktop::ConferenceCoAuthorRelationsController < ApplicationController class Panel::PersonalConference::Desktop::ConferenceCoAuthorRelationsController < ApplicationController
def index def index
page = params[:page]
page ||= 1
@conference_co_author_relations = ConferenceCoAuthorRelation.all @conference_co_author_relations = ConferenceCoAuthorRelation.all
new new
@conference_co_author_relations = @conference_co_author_relations.page(page).per(5)
respond_to do |format| respond_to do |format|
format.html {render layout: false } format.html {render layout: false }
end end

View File

@ -1,10 +1,12 @@
class Panel::PersonalConference::Desktop::ConferenceCoAuthorsController < ApplicationController class Panel::PersonalConference::Desktop::ConferenceCoAuthorsController < ApplicationController
def index def index
nils, not_nils = ConferenceCoAuthor.where(name_id: current_user.id)\ page = params[:page]
.asc(:co_author).partition{|p| p.email.nil?} page ||= 1
@conference_co_authors = not_nils + nils @conference_co_authors = ConferenceCoAuthor.where(name_id: current_user.id).asc(:co_author)
@conference_co_author_relations = ConferenceCoAuthorRelation.all @conference_co_author_relations = ConferenceCoAuthorRelation.all
@conference_co_authors = @conference_co_authors.page(page).per(5)
respond_to do |format| respond_to do |format|
format.html { render :layout => false} format.html { render :layout => false}
end end

View File

@ -2,6 +2,8 @@ class Panel::PersonalConference::Desktop::ConferencePagesController < Applicatio
def index def index
@view_by = params[:view] @view_by = params[:view]
@writing_conferences = WritingConference.where(create_user_id: current_user.id) @writing_conferences = WritingConference.where(create_user_id: current_user.id)
page = params[:page]
page ||= 1
if @view_by.nil? if @view_by.nil?
@writing_conferences = @writing_conferences.asc(:paper_title) @writing_conferences = @writing_conferences.asc(:paper_title)
@ -11,6 +13,8 @@ class Panel::PersonalConference::Desktop::ConferencePagesController < Applicatio
@level_types = ConferencePaperType.all @level_types = ConferencePaperType.all
@writing_conferences = @writing_conferences.page(page).per(5)
respond_to do |format| respond_to do |format|
format.html { render :layout => false} format.html { render :layout => false}
end end
@ -84,9 +88,13 @@ class Panel::PersonalConference::Desktop::ConferencePagesController < Applicatio
end end
def conference_type def conference_type
page = params[:page]
page ||= 1
conference_types = ConferencePaperType.all conference_types = ConferencePaperType.all
all_conference_lists = WritingConference.where(create_user_id: current_user.id) all_conference_lists = WritingConference.where(create_user_id: current_user.id)
all_conference_lists = all_conference_lists.asc(:conference_title) all_conference_lists = all_conference_lists.asc(:conference_title)
all_conference_lists = all_conference_lists.page(page).per(5)
all_conference_lists = all_conference_lists.map do |j| all_conference_lists = all_conference_lists.map do |j|
[ j.conference_title, [ j.conference_title,
j.conference_paper_type_ids.map do |type| j.conference_paper_type_ids.map do |type|

View File

@ -1,8 +1,11 @@
class Panel::PersonalJournal::Desktop::JournalCoAuthorRelationsController < ApplicationController class Panel::PersonalJournal::Desktop::JournalCoAuthorRelationsController < ApplicationController
def index def index
page = params[:page]
page ||= 1
@journal_co_author_relations = JournalCoAuthorRelation.all @journal_co_author_relations = JournalCoAuthorRelation.all
new new
@journal_co_author_relations = @journal_co_author_relations.page(page).per(5)
respond_to do |format| respond_to do |format|
format.html {render layout: false } format.html {render layout: false }
end end

View File

@ -1,10 +1,12 @@
class Panel::PersonalJournal::Desktop::JournalCoAuthorsController < ApplicationController class Panel::PersonalJournal::Desktop::JournalCoAuthorsController < ApplicationController
def index def index
nils, not_nils = JournalCoAuthor.where(name_id: current_user.id)\ page = params[:page]
.asc(:co_author).partition{|p| p.email.nil?} page ||= 1
@journal_co_authors = not_nils + nils @journal_co_authors = JournalCoAuthor.where(name_id: current_user.id).asc(:co_author)
@journal_co_author_relations = JournalCoAuthorRelation.all @journal_co_author_relations = JournalCoAuthorRelation.all
@journal_co_authors = @journal_co_authors.page(page).per(5)
respond_to do |format| respond_to do |format|
format.html { render :layout => false} format.html { render :layout => false}
end end

View File

@ -3,6 +3,8 @@ class Panel::PersonalJournal::Desktop::JournalPagesController < ApplicationContr
@writing_journals = WritingJournal.where(create_user_id: current_user.id) @writing_journals = WritingJournal.where(create_user_id: current_user.id)
@level_types = JournalLevelType.all @level_types = JournalLevelType.all
@view_by = params[:view] @view_by = params[:view]
page = params[:page]
page ||= 1
if @view_by.nil? if @view_by.nil?
@writing_journals = @writing_journals.asc(:paper_title) @writing_journals = @writing_journals.asc(:paper_title)
@ -12,6 +14,8 @@ class Panel::PersonalJournal::Desktop::JournalPagesController < ApplicationContr
@level_types = ConferencePaperType.all @level_types = ConferencePaperType.all
@writing_journals = @writing_journals.page(page).per(5)
respond_to do |format| respond_to do |format|
format.html { render :layout => false} format.html { render :layout => false}
end end
@ -85,9 +89,13 @@ class Panel::PersonalJournal::Desktop::JournalPagesController < ApplicationContr
end end
def journal_type def journal_type
page = params[:page]
page ||= 1
level_types = JournalLevelType.all level_types = JournalLevelType.all
all_journal_lists = WritingJournal.where(create_user_id: current_user.id) all_journal_lists = WritingJournal.where(create_user_id: current_user.id)
all_journal_lists = all_journal_lists.asc(:journal_title) all_journal_lists = all_journal_lists.asc(:journal_title)
all_journal_lists = all_journal_lists.page(page).per(5)
all_journal_lists = all_journal_lists.map do |j| all_journal_lists = all_journal_lists.map do |j|
[ j.journal_title, [ j.journal_title,
j.journal_level_type_ids.map do |type| j.journal_level_type_ids.map do |type|