Update personal_journals_controller.rb
This commit is contained in:
parent
f1e57a93ab
commit
93616514bc
|
@ -1,4 +1,8 @@
|
||||||
class PersonalJournalsController < ApplicationController
|
class PersonalJournalsController < ApplicationController
|
||||||
|
def search_all_words(target,word)
|
||||||
|
words=word.split(' ')
|
||||||
|
return words.select{|value| target.include? value}==words
|
||||||
|
end
|
||||||
def index
|
def index
|
||||||
params = OrbitHelper.params
|
params = OrbitHelper.params
|
||||||
journal_papers = JournalPaper.where(:is_hidden=>false).sort_for_frontend.page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count)
|
journal_papers = JournalPaper.where(:is_hidden=>false).sort_for_frontend.page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count)
|
||||||
|
@ -28,20 +32,20 @@ class PersonalJournalsController < ApplicationController
|
||||||
case params[:selectbox]
|
case params[:selectbox]
|
||||||
when "paper_title","default"
|
when "paper_title","default"
|
||||||
if page.custom_string_field == "table"
|
if page.custom_string_field == "table"
|
||||||
journal_papers_show = journal_papers_temp.select {|value| value.paper_title.upcase.include? params[:keywords].upcase}
|
journal_papers_show = journal_papers_temp.select {|value| search_all_words(value.paper_title.upcase,params[:keywords].upcase)}
|
||||||
else
|
else
|
||||||
journal_papers_show = journal_papers_temp.select {|value| value.create_link.upcase.include? params[:keywords].upcase}
|
journal_papers_show = journal_papers_temp.select {|value| search_all_words(value.create_link.upcase,params[:keywords].upcase)}
|
||||||
end
|
end
|
||||||
when "level_type"
|
when "level_type"
|
||||||
journal_papers_show = journal_papers_temp.select {|value| value.journal_levels.collect{|x| x.title}.join(', ').to_s.upcase.include? params[:keywords].upcase}
|
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)}
|
||||||
when "publication_date"
|
when "publication_date"
|
||||||
journal_papers_show = journal_papers_temp.select {|value| value.send("publication_date").strftime("%Y/%m").collect{|x| x.title}.join(', ').upcase.include? 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(', ').upcase,params[:keywords].upcase)}
|
||||||
when "author_type"
|
when "author_type"
|
||||||
journal_papers_show = journal_papers_temp.select {|value| value.journal_paper_author_types.collect{|jat| jat.title}.join(", ").upcase.include? params[:keywords].upcase}
|
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)}
|
||||||
when "language"
|
when "language"
|
||||||
journal_papers_show = journal_papers_temp.select {|value| (!value.language.nil? ? t("#{value.language}") : "").upcase.include? params[:keywords].upcase}
|
journal_papers_show = journal_papers_temp.select {|value| search_all_words((!value.language.nil? ? t("#{value.language}") : "").upcase,params[:keywords].upcase)}
|
||||||
else
|
else
|
||||||
journal_papers_show = journal_papers_temp.select {|value| value.send(params[:selectbox]).to_s.upcase.include? params[:keywords].upcase}
|
journal_papers_show = jjournal_papers_temp.select {|value| search_all_words(value.send(params[:selectbox]).to_s.upcase,params[:keywords].upcase)}
|
||||||
end
|
end
|
||||||
timer = Time.now-t
|
timer = Time.now-t
|
||||||
if params[:page_no].nil?
|
if params[:page_no].nil?
|
||||||
|
|
Loading…
Reference in New Issue