Update personal_patents_controller.rb

coding style fix
This commit is contained in:
chiu 2019-08-19 16:43:30 +08:00
parent 3e85585152
commit 00103841c3
1 changed files with 13 additions and 11 deletions

View File

@ -1,12 +1,8 @@
class PersonalPatentsController < 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
patents = Patent.where(:is_hidden=>false).sort_for_frontend.page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count)
page_data_count = OrbitHelper.page_data_count
patents = Patent.where(:is_hidden=>false).sort_for_frontend.page(OrbitHelper.params[:page_no]).per(page_data_count)
fields_to_show = Page.where(:page_id => params[:page_id]).first.custom_array_field rescue []
if fields_to_show.blank?
fields_to_show = [
@ -38,8 +34,8 @@ class PersonalPatentsController < ApplicationController
else
page_to_show = params[:page_no].to_i
end
patents = patents_show[(page_to_show-1)*OrbitHelper.page_data_count...page_to_show*OrbitHelper.page_data_count]
patents_total_pages = (patents_show.length/OrbitHelper.page_data_count.to_f).ceil
patents = patents_show[(page_to_show-1)*page_data_count...page_to_show*page_data_count]
patents_total_pages = (patents_show.length/page_data_count.to_f).ceil
else
patents_total_pages = patents.total_pages
end
@ -85,13 +81,13 @@ class PersonalPatentsController < 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_patent.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_patent.search_class")
search_text = t("personal_patent.word_to_search")
{
"patents" => patent_list,
"extras" => { "widget-title" => t("module_name.personal_patent"),
@ -170,4 +166,10 @@ class PersonalPatentsController < 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