Update personal_journals_controller.rb

This commit is contained in:
chiu 2019-08-13 15:58:01 +08:00
parent ebe9772a23
commit cdadf32b15
1 changed files with 17 additions and 2 deletions

View File

@ -24,7 +24,22 @@ class PersonalJournalsController < ApplicationController
journal_papers = JournalPaper.where(:is_hidden=>false)#Mongoid::Sessions.default[:journal_papers].find() journal_papers = JournalPaper.where(:is_hidden=>false)#Mongoid::Sessions.default[:journal_papers].find()
journal_papers_count = journal_papers.count 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_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 journal_papers.total_pages = (journal_papers_temp.length / OrbitHelper.page_data_count.to_f).ceil
if params[:page_no].nil? if params[:page_no].nil?
page_to_show = 1 page_to_show = 1
@ -83,7 +98,7 @@ class PersonalJournalsController < ApplicationController
"total_pages" => journal_papers.total_pages, "total_pages" => journal_papers.total_pages,
"choice" => {"choice_value" => choice_value ,"choice_show" => choice_show}, "choice" => {"choice_value" => choice_value ,"choice_show" => choice_show},
"url" => "/"+params[:locale]+params[:url], "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 "all_n" => JournalPaper.where(:is_hidden=>false).count
} }
end end