From 779e5c3939631cbe059ade9f6b337b20d754ed7e Mon Sep 17 00:00:00 2001 From: chiu Date: Tue, 13 Aug 2019 17:26:16 +0800 Subject: [PATCH] Update personal_journals_controller.rb --- .../personal_journals_controller.rb | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/app/controllers/personal_journals_controller.rb b/app/controllers/personal_journals_controller.rb index 383c6d9..2e4d599 100644 --- a/app/controllers/personal_journals_controller.rb +++ b/app/controllers/personal_journals_controller.rb @@ -51,29 +51,29 @@ class PersonalJournalsController < ApplicationController else journal_papers_total_pages = journal_papers.total_pages end - journal_paper_list = [] - journal_papers.each do |journal_paper| - t = [] - fields_to_show.each do |fs| - case fs - when "paper_title" - if page.custom_string_field == "table" - t << {"value" => "#{journal_paper.paper_title}"} - else - t << {"value" => "#{journal_paper.create_link}"} - 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 + journal_paper_list = [] + journal_papers.each do |journal_paper| + t = [] + fields_to_show.each do |fs| + case fs + when "paper_title" + if page.custom_string_field == "table" + t << {"value" => "#{journal_paper.paper_title}"} + else + t << {"value" => "#{journal_paper.create_link}"} 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 + journal_paper_list << {"jps" => t} + end headers = [] choice_show = [] fields_to_show.each do |fs| @@ -89,15 +89,15 @@ class PersonalJournalsController < ApplicationController choice_value.unshift("paper_title") choice_default = OrbitHelper.params[:locale]!='en' ? "——選取分類——" : "——select class——" choice_show.unshift(choice_default) - journal_papers1 = Mongoid::Sessions.default[:journal_papers].find() - journal_papers_count = journal_papers1.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_count = journal_papers1.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" => journal_paper_list, "headers" => headers, "extras" => {"widget-title" => t("module_name.journal_paper")}, "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}, "url" => "/"+params[:locale]+params[:url], "all" => journal_papers_show_last