Update personal_conferences_controller.rb

This commit is contained in:
chiu 2019-08-15 09:47:16 +08:00
parent fbf6433036
commit 609a1c83ba
1 changed files with 14 additions and 9 deletions

View File

@ -1,4 +1,9 @@
class PersonalConferencesController < ApplicationController class PersonalConferencesController < ApplicationController
def search_all_words(target,word)
target=target.upcase
words=word.upcase.split(' ')
return words.select{|value| target.include? value}==words
end
def index def index
params = OrbitHelper.params params = OrbitHelper.params
writing_conferences = WritingConference.where(:is_hidden=>false).sort_for_frontend.page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count) writing_conferences = WritingConference.where(:is_hidden=>false).sort_for_frontend.page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count)
@ -26,24 +31,24 @@ class PersonalConferencesController < 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"
writing_conferences_show = writing_conferences_temp.select {|value| value.paper_title.include? params[:keywords]} writing_conferences_show = writing_conferences_temp.select {|value| search_all_words(value.paper_title, params[:keywords])}
else else
writing_conferences_show = writing_conferences_temp.select {|value| value.create_link.include? params[:keywords]} writing_conferences_show = writing_conferences_temp.select {|value| search_all_words(value.create_link, params[:keywords])}
end end
when "paper_levels" when "paper_levels"
writing_conferences_show = writing_conferences_temp.select {|value| value.conference_paper_levels.collect{|x| x.title}.join(', ').to_s.include? params[:keywords]} writing_conferences_show = writing_conferences_temp.select {|value| search_all_words(value.conference_paper_levels.collect{|x| x.title}.join(', ').to_s, params[:keywords])}
when "paper_types" when "paper_types"
writing_conferences_show = writing_conferences_temp.select {|value| value.conference_paper_types.collect{|x| x.title}.join(', ').to_s.include? params[:keywords]} writing_conferences_show = writing_conferences_temp.select {|value| search_all_words(value.conference_paper_types.collect{|x| x.title}.join(', ').to_s, params[:keywords])}
when "period" when "period"
writing_conferences_show = writing_conferences_temp.select {|value| value.duration.include? params[:keywords]} writing_conferences_show = writing_conferences_temp.select {|value| search_all_words(value.duration.include? params[:keywords]}
when "publication_date" when "publication_date"
writing_conferences_show = writing_conferences_temp.select {|value| value.send("publication_date").strftime("%Y/%m").collect{|x| x.title}.join(', ').include? params[:keywords]} writing_conferences_show = writing_conferences_temp.select {|value| search_all_words(value.send("publication_date").strftime("%Y/%m").collect{|x| x.title}.join(', '), params[:keywords])}
when "author_type" when "author_type"
writing_conferences_show = writing_conferences_temp.select {|value| value.conference_author_types.collect{|cat| cat.title}.join(", ").include? params[:keywords]} writing_conferences_show = writing_conferences_temp.select {|value| search_all_words(value.conference_author_types.collect{|cat| cat.title}.join(", "), params[:keywords])}
when "language" when "language"
writing_conferences_show = writing_conferences_temp.select {|value| (!value.language.nil? ? t("#{value.language}") : "").include? params[:keywords]} writing_conferences_show = writing_conferences_temp.select {|value| search_all_words((!value.language.nil? ? t("#{value.language}") : ""), params[:keywords])}
else else
writing_conferences_show = writing_conferences_temp.select {|value| value.send(params[:selectbox]).to_s.include? params[:keywords]} writing_conferences_show = writing_conferences_temp.select {|value| search_all_words(value.send(params[:selectbox]).to_s, params[:keywords])}
end end
if params[:page_no].nil? if params[:page_no].nil?
page_to_show = 1 page_to_show = 1