diff --git a/app/controllers/personal_journals_controller.rb b/app/controllers/personal_journals_controller.rb index 6a937b6..a4aca2f 100644 --- a/app/controllers/personal_journals_controller.rb +++ b/app/controllers/personal_journals_controller.rb @@ -23,15 +23,21 @@ class PersonalJournalsController < ApplicationController if params[:selectbox] !=nil journal_papers = Mongoid::Sessions.default[:journal_papers].find() journal_papers_count = journal_papers.count - journal_papers_temp = Mongoid::Sessions.default[:journal_papers].find().take(journal_papers_count) - journal_papers_show = journal_papers_temp.select {|value| value[params[:selectbox]][OrbitHelper.params[:locale]].include? params[:keywords]} + journal_papers_temp = Mongoid::Sessions.default[:journal_papers].find().take(journal_papers_count).sort_by{ |tp| [-tp[:year].to_i,-tp[:publication_date].to_i] } + journal_papers_show = journal_papers_temp.select {|value| value[params[:selectbox]][params[:locale]].include? params[:keywords]} + if params[:page_no].nil? + page_to_show = 1 + else + page_to_show = params[:page_no].to_i + end + journal_papers_show_last = journal_papers_show[(page_to_show-1)*OrbitHelper.page_data_count...page_to_show*OrbitHelper.page_data_count] { "journal_papers" => [{"jps"=>[{"value"=>"2019"}, {"value"=>"123, 456"}]}], "headers" => [{"head-title"=>"年度", "col"=>2}, {"head-title"=>"論文名稱", "col"=>3}], "extras" => {"widget-title" => "module_name.journal_paper"}, "total_pages" => 1, "choice" => 1, - "all" => OrbitHelper.page_data_count + "all" => journal_papers_show_last } else journal_paper_list = []