From cdadf32b154d497cde716d8aeb12da8c049e40bc Mon Sep 17 00:00:00 2001 From: chiu Date: Tue, 13 Aug 2019 15:58:01 +0800 Subject: [PATCH] Update personal_journals_controller.rb --- .../personal_journals_controller.rb | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/app/controllers/personal_journals_controller.rb b/app/controllers/personal_journals_controller.rb index e5adfd1..ad7dd7e 100644 --- a/app/controllers/personal_journals_controller.rb +++ b/app/controllers/personal_journals_controller.rb @@ -24,7 +24,22 @@ class PersonalJournalsController < ApplicationController journal_papers = JournalPaper.where(:is_hidden=>false)#Mongoid::Sessions.default[:journal_papers].find() journal_papers_count = journal_papers.count journal_papers_temp = journal_papers.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]} + case params[:selectbox] + when "paper_title" + if page.custom_string_field == "table" + journal_papers_show = journal_papers_temp.select {|value| value.paper_title.include? params[:keywords]} + else + journal_papers_show = journal_papers_temp.select {|value| value.create_link.include? params[:keywords]} + end + when "level_type" + journal_papers_show = journal_papers_temp.select {|value| value.journal_levels.collect{|x| x.title}.join(', ')}).to_s.include? params[:keywords]} + when "publication_date" + journal_papers_show = journal_papers_temp.select {|value| value.send("publication_date").strftime("%Y/%m").collect{|x| x.title}.join(', ')}).include? params[:keywords]} + when "author_type" + ournal_papers_show = journal_papers_temp.select {|value| value.journal_paper_author_types.collect{|jat| jat.title}.join(", ").include? params[:keywords]} + else + journal_papers_show = journal_papers_temp.select {|value| value.send(params[:selectbox]).to_s.include? params[:keywords]} + end journal_papers.total_pages = (journal_papers_temp.length / OrbitHelper.page_data_count.to_f).ceil if params[:page_no].nil? page_to_show = 1 @@ -83,7 +98,7 @@ class PersonalJournalsController < ApplicationController "total_pages" => journal_papers.total_pages, "choice" => {"choice_value" => choice_value ,"choice_show" => choice_show}, "url" => "/"+params[:locale]+params[:url], - "all" => JournalPaper.where(:is_hidden=>false).take(4).sort_by{ |tp| [-tp[:year].to_i,-tp[:publication_date].to_i] }[0].paper_title, + "all" => journal_papers_show_last, "all_n" => JournalPaper.where(:is_hidden=>false).count } end