Update personal_conferences_controller.rb

搜尋改為支持多國語言
coding style fix
This commit is contained in:
chiu 2019-08-19 16:27:46 +08:00
parent e6bfdda9bf
commit f1fa503b8b
1 changed files with 13 additions and 11 deletions

View File

@ -1,12 +1,8 @@
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
params = OrbitHelper.params
writing_conferences = WritingConference.where(:is_hidden=>false).sort_for_frontend.page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count)
page_data_count = OrbitHelper.page_data_count
writing_conferences = WritingConference.where(:is_hidden=>false).sort_for_frontend.page(OrbitHelper.params[:page_no]).per(page_data_count)
page = Page.where(:page_id => params[:page_id]).first rescue nil
if page.custom_string_field == "table"
fields_to_show = page.custom_array_field rescue []
@ -53,8 +49,8 @@ class PersonalConferencesController < ApplicationController
else
page_to_show = params[:page_no].to_i
end
writing_conferences = writing_conferences_show[(page_to_show-1)*OrbitHelper.page_data_count...page_to_show*OrbitHelper.page_data_count]
writing_conferences_total_pages = (writing_conferences_show.length/OrbitHelper.page_data_count.to_f).ceil
writing_conferences = writing_conferences_show[(page_to_show-1)*page_data_count...page_to_show*page_data_count]
writing_conferences_total_pages = (writing_conferences_show.length/page_data_count.to_f).ceil
else
writing_conferences_total_pages = writing_conferences.total_pages
end
@ -103,13 +99,13 @@ class PersonalConferencesController < ApplicationController
choice_select=choice_value.map{|iter| iter==params[:selectbox] ? "selected" : ""}
choice_select=choice_select.map{|value| {"choice_select" => value}}
choice_value=choice_value.map{|value| {"choice_value" => value}}
choice_default = params[:locale]!='en' ? "——選取分類——" : "——select class——"
choice_default = t("personal_conference.select_class")
choice_show.unshift(choice_default)
choice_show=choice_show.map{|value| {"choice_show" => value}}
choice=choice_value.zip(choice_show,choice_select)
choice=choice.map{|value| value.inject:merge}
select_text = params[:locale]!='en' ? "搜尋類別:" : "search class:"
search_text = params[:locale]!='en' ? "關鍵字搜尋:" : "word to search:"
select_text = t("personal_conference.search_class")
search_text = t("personal_conference.word_to_search")
{
"writing_conferences" => writing_conference_list,
"extras" => { "widget-title" => t("module_name.personal_conference"),
@ -194,4 +190,10 @@ class PersonalConferencesController < ApplicationController
page.save
render :json => {"success" => true}.to_json
end
private
def search_all_words(target,word)
target=target.upcase
words=word.upcase.split(' ')
return words.select{|value| target.include? value}==words
end
end