Update personal_journals_controller.rb

This commit is contained in:
chiu 2019-08-13 17:26:16 +08:00
parent e7880ea2a1
commit 779e5c3939
1 changed files with 25 additions and 25 deletions

View File

@ -51,29 +51,29 @@ class PersonalJournalsController < ApplicationController
else else
journal_papers_total_pages = journal_papers.total_pages journal_papers_total_pages = journal_papers.total_pages
end end
journal_paper_list = [] journal_paper_list = []
journal_papers.each do |journal_paper| journal_papers.each do |journal_paper|
t = [] t = []
fields_to_show.each do |fs| fields_to_show.each do |fs|
case fs case fs
when "paper_title" when "paper_title"
if page.custom_string_field == "table" if page.custom_string_field == "table"
t << {"value" => "<a href='#{OrbitHelper.url_to_show(journal_paper.to_param)}'>#{journal_paper.paper_title}</a>"} t << {"value" => "<a href='#{OrbitHelper.url_to_show(journal_paper.to_param)}'>#{journal_paper.paper_title}</a>"}
else else
t << {"value" => "<a href='#{OrbitHelper.url_to_show(journal_paper.to_param)}'>#{journal_paper.create_link}</a>"} t << {"value" => "<a href='#{OrbitHelper.url_to_show(journal_paper.to_param)}'>#{journal_paper.create_link}</a>"}
end
when "level_type"
t << {"value" => ( !journal_paper.journal_levels.blank? ? "(#{journal_paper.journal_levels.collect{|x| x.title}.join(', ')})" : nil)}
when "publication_date"
t << {"value" => (journal_paper.send(fs).strftime("%Y/%m") rescue "")}
when "author_type"
t << {"value" => (journal_paper.journal_paper_author_types.collect{|jat| jat.title}.join(", ") rescue "")}
else
t << {"value" => journal_paper.send(fs)}
end
end end
journal_paper_list << {"jps" => t} when "level_type"
t << {"value" => ( !journal_paper.journal_levels.blank? ? "(#{journal_paper.journal_levels.collect{|x| x.title}.join(', ')})" : nil)}
when "publication_date"
t << {"value" => (journal_paper.send(fs).strftime("%Y/%m") rescue "")}
when "author_type"
t << {"value" => (journal_paper.journal_paper_author_types.collect{|jat| jat.title}.join(", ") rescue "")}
else
t << {"value" => journal_paper.send(fs)}
end end
end
journal_paper_list << {"jps" => t}
end
headers = [] headers = []
choice_show = [] choice_show = []
fields_to_show.each do |fs| fields_to_show.each do |fs|
@ -89,15 +89,15 @@ class PersonalJournalsController < ApplicationController
choice_value.unshift("paper_title") choice_value.unshift("paper_title")
choice_default = OrbitHelper.params[:locale]!='en' ? "——選取分類——" : "——select class——" choice_default = OrbitHelper.params[:locale]!='en' ? "——選取分類——" : "——select class——"
choice_show.unshift(choice_default) choice_show.unshift(choice_default)
journal_papers1 = Mongoid::Sessions.default[:journal_papers].find() journal_papers_count = journal_papers1.count
journal_papers_count = journal_papers1.count journal_papers_temp = journal_papers1.take(journal_papers_count)
journal_papers_temp = journal_papers1.take(journal_papers_count) journal_papers_show = journal_papers_temp.select {|value| value["paper_title"][OrbitHelper.params[:locale]].include? "1"}
journal_papers_show = journal_papers_temp.select {|value| value["paper_title"][OrbitHelper.params[:locale]].include? "1"}
{ {
"journal_papers" => journal_paper_list, "journal_papers" => journal_paper_list,
"headers" => headers, "headers" => headers,
"extras" => {"widget-title" => t("module_name.journal_paper")}, "extras" => {"widget-title" => t("module_name.journal_paper")},
"total_pages" => journal_papers_total_pages, "total_pages" => journal_papers_total_pages,
"search_text" =>{"select" => params[:locale]!='en' ? "搜尋類別:" : "search class:", "search" => params[:locale]!='en' ? "關鍵字搜尋:" : "word to search:"},
"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" => journal_papers_show_last "all" => journal_papers_show_last