Update personal_journals_controller.rb

This commit is contained in:
chiu 2019-08-15 09:40:33 +08:00
parent 473ad7d534
commit c6a2a6418c
1 changed files with 9 additions and 8 deletions

View File

@ -1,6 +1,7 @@
class PersonalJournalsController < ApplicationController
def search_all_words(target,word)
words=word.split(' ')
target=target.upcase
words=word.upcase.split(' ')
return words.select{|value| target.include? value}==words
end
def index
@ -29,20 +30,20 @@ class PersonalJournalsController < ApplicationController
case params[:selectbox]
when "paper_title","default"
if page.custom_string_field == "table"
journal_papers_show = journal_papers_temp.select {|value| search_all_words(value.paper_title.upcase,params[:keywords].upcase)}
journal_papers_show = journal_papers_temp.select {|value| search_all_words(value.paper_title,params[:keywords])}
else
journal_papers_show = journal_papers_temp.select {|value| search_all_words(value.create_link.upcase,params[:keywords].upcase)}
journal_papers_show = journal_papers_temp.select {|value| search_all_words(value.create_link,params[:keywords])}
end
when "level_type"
journal_papers_show = journal_papers_temp.select {|value| search_all_words(value.journal_levels.collect{|x| x.title}.join(', ').to_s.upcase,params[:keywords].upcase)}
journal_papers_show = journal_papers_temp.select {|value| search_all_words(value.journal_levels.collect{|x| x.title}.join(', ').to_s,params[:keywords])}
when "publication_date"
journal_papers_show = journal_papers_temp.select {|value| search_all_words(value.send("publication_date").strftime("%Y/%m").collect{|x| x.title}.join(', ').upcase,params[:keywords].upcase)}
journal_papers_show = journal_papers_temp.select {|value| search_all_words(value.send("publication_date").strftime("%Y/%m").collect{|x| x.title}.join(', '),params[:keywords])}
when "author_type"
journal_papers_show = journal_papers_temp.select {|value| search_all_words(value.journal_paper_author_types.collect{|jat| jat.title}.join(", ").upcase,params[:keywords].upcase)}
journal_papers_show = journal_papers_temp.select {|value| search_all_words(value.journal_paper_author_types.collect{|jat| jat.title}.join(", "),params[:keywords])}
when "language"
journal_papers_show = journal_papers_temp.select {|value| search_all_words((!value.language.nil? ? t("#{value.language}") : "").upcase,params[:keywords].upcase)}
journal_papers_show = journal_papers_temp.select {|value| search_all_words((!value.language.nil? ? t("#{value.language}") : ""),params[:keywords])}
else
journal_papers_show = jjournal_papers_temp.select {|value| search_all_words(value.send(params[:selectbox]).to_s.upcase,params[:keywords].upcase)}
journal_papers_show = jjournal_papers_temp.select {|value| search_all_words(value.send(params[:selectbox]).to_s,params[:keywords])}
end
if params[:page_no].nil?
page_to_show = 1