From 949993f85206a198901080ab195a5f98160548ed Mon Sep 17 00:00:00 2001 From: chiu Date: Fri, 16 Aug 2019 09:27:54 +0800 Subject: [PATCH 01/12] Update personal_patents_controller.rb --- .../personal_patents_controller.rb | 57 +++++++++++++++++-- 1 file changed, 53 insertions(+), 4 deletions(-) diff --git a/app/controllers/personal_patents_controller.rb b/app/controllers/personal_patents_controller.rb index d58c112..81ffac9 100644 --- a/app/controllers/personal_patents_controller.rb +++ b/app/controllers/personal_patents_controller.rb @@ -1,4 +1,9 @@ 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) @@ -12,6 +17,32 @@ class PersonalPatentsController < ApplicationController "authors" ] end + if params[:selectbox] !=nil + patents_temp = Patent.where(:is_hidden=>false).sort_by{ |tp| [-tp[:year].to_i,-tp[:publication_date].to_i] } + case params[:selectbox] + when "patent_title","default" + patents_show = patents_temp.select {|value| search_all_words((value.patent_title rescue ""), params[:keywords])} + when "publish_date", "application_date", "end_date" + patents_show = patents_temp.select {|value| search_all_words((value.send(params[:selectbox]).strftime("%Y/%m/%d") rescue ""), params[:keywords])} + when "patent_category" + patent_show = patents_temp.select {|value| search_all_words(value.patent_types.collect{|pt| pt.title}.join(", "), params[:keywords])} + when "author_type" + patents_show = patents_temp.select {|value| search_all_words(value.patent_author_types.collect{|pt| pt.title}.join(", "), params[:keywords])} + when "language" + patents_show = patents_temp.select {|value| search_all_words((!value.language.nil? ? t("#{value.language}") : ""), params[:keywords])} + else + patentes_show = patents_temp.select {|value| search_all_words(value.send(params[:selectbox]).to_s, params[:keywords])} + end + if params[:page_no].nil? + page_to_show = 1 + 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 + else + patents_total_pages = patents.total_pages + end patent_list = [] patents.each do |patent| t = [] @@ -35,8 +66,8 @@ class PersonalPatentsController < ApplicationController end patent_list << {"patent_list" => t} end - - headers = [] + choice_show = [] + headers = [] fields_to_show.each do |fs| col = 2 col = 3 if fs == "patent_title" @@ -45,12 +76,30 @@ class PersonalPatentsController < ApplicationController "head-title" => header, "col" => col } + choice_show << header end + choice_value = fields_to_show + choice_value.unshift("default") + 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_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:" { "patents" => patent_list, - "extras" => { "widget-title" => t("module_name.personal_patent") }, + "extras" => { "widget-title" => t("module_name.personal_patent"), + "url" => "/"+params[:locale]+params[:url], + "select_text" => select_text, + "search_text" => search_text, + "search_value" => params[:keywords] }, "headers" => headers, - "total_pages" => patents.total_pages + "total_pages" => patents_total_pages, + "choice" => choice } end From dda9a8842a549336d84b0dcd5709e706e62acd9c Mon Sep 17 00:00:00 2001 From: chiu Date: Fri, 16 Aug 2019 09:38:21 +0800 Subject: [PATCH 02/12] Update personal_patents_controller.rb fix error --- app/controllers/personal_patents_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/personal_patents_controller.rb b/app/controllers/personal_patents_controller.rb index 81ffac9..157be02 100644 --- a/app/controllers/personal_patents_controller.rb +++ b/app/controllers/personal_patents_controller.rb @@ -31,7 +31,7 @@ class PersonalPatentsController < ApplicationController when "language" patents_show = patents_temp.select {|value| search_all_words((!value.language.nil? ? t("#{value.language}") : ""), params[:keywords])} else - patentes_show = patents_temp.select {|value| search_all_words(value.send(params[:selectbox]).to_s, params[:keywords])} + patentes_show = patents_temp.select {|value| search_all_words((value.send(params[:selectbox]).to_s rescue ""), params[:keywords])} end if params[:page_no].nil? page_to_show = 1 From f389fa90ea76250b6528a61c2b321eb4985a66c4 Mon Sep 17 00:00:00 2001 From: chiu Date: Fri, 16 Aug 2019 09:42:38 +0800 Subject: [PATCH 03/12] Update personal_patents_controller.rb fix error --- app/controllers/personal_patents_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/personal_patents_controller.rb b/app/controllers/personal_patents_controller.rb index 157be02..58aaed4 100644 --- a/app/controllers/personal_patents_controller.rb +++ b/app/controllers/personal_patents_controller.rb @@ -31,7 +31,7 @@ class PersonalPatentsController < ApplicationController when "language" patents_show = patents_temp.select {|value| search_all_words((!value.language.nil? ? t("#{value.language}") : ""), params[:keywords])} else - patentes_show = patents_temp.select {|value| search_all_words((value.send(params[:selectbox]).to_s rescue ""), params[:keywords])} + patents_show = patents_temp.select {|value| search_all_words((value.send(params[:selectbox]).to_s rescue ""), params[:keywords])} end if params[:page_no].nil? page_to_show = 1 From 1f3e11e1464a4e469e3fb1b095bb526bd9dd8cdc Mon Sep 17 00:00:00 2001 From: chiu Date: Fri, 16 Aug 2019 09:48:43 +0800 Subject: [PATCH 04/12] Update personal_patents_controller.rb fix language not been translated to show --- app/controllers/personal_patents_controller.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/controllers/personal_patents_controller.rb b/app/controllers/personal_patents_controller.rb index 58aaed4..c68c49a 100644 --- a/app/controllers/personal_patents_controller.rb +++ b/app/controllers/personal_patents_controller.rb @@ -60,6 +60,8 @@ class PersonalPatentsController < ApplicationController t << {"value" => (patent.patent_types.collect{|pt| pt.title}.join(", ") rescue "")} when "author_type" t << {"value" => (patent.patent_author_types.collect{|pt| pt.title}.join(", ") rescue "")} + when "language" + t << {"value" => (!patent.language.nil? ? t("#{patent.language}") : "")} else t << {"value" => patent.send(fs)} end From 80472eec7a1071644101f4a9c6d8e6d7bac9a2b5 Mon Sep 17 00:00:00 2001 From: chiu Date: Fri, 16 Aug 2019 10:00:30 +0800 Subject: [PATCH 05/12] Update personal_patents_controller.rb fix error --- app/controllers/personal_patents_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/personal_patents_controller.rb b/app/controllers/personal_patents_controller.rb index c68c49a..25b8cad 100644 --- a/app/controllers/personal_patents_controller.rb +++ b/app/controllers/personal_patents_controller.rb @@ -25,7 +25,7 @@ class PersonalPatentsController < ApplicationController when "publish_date", "application_date", "end_date" patents_show = patents_temp.select {|value| search_all_words((value.send(params[:selectbox]).strftime("%Y/%m/%d") rescue ""), params[:keywords])} when "patent_category" - patent_show = patents_temp.select {|value| search_all_words(value.patent_types.collect{|pt| pt.title}.join(", "), params[:keywords])} + patent_show = patents_temp.select {|value| search_all_words((value.patent_types.collect{|pt| pt.title}.join(", ") rescue ""), params[:keywords])} when "author_type" patents_show = patents_temp.select {|value| search_all_words(value.patent_author_types.collect{|pt| pt.title}.join(", "), params[:keywords])} when "language" From ab9b6385bc81630899655d6bf3d74ae5c2ed695a Mon Sep 17 00:00:00 2001 From: chiu Date: Fri, 16 Aug 2019 10:01:17 +0800 Subject: [PATCH 06/12] Update personal_patents_controller.rb fix error --- app/controllers/personal_patents_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/personal_patents_controller.rb b/app/controllers/personal_patents_controller.rb index 25b8cad..a1c7546 100644 --- a/app/controllers/personal_patents_controller.rb +++ b/app/controllers/personal_patents_controller.rb @@ -25,7 +25,7 @@ class PersonalPatentsController < ApplicationController when "publish_date", "application_date", "end_date" patents_show = patents_temp.select {|value| search_all_words((value.send(params[:selectbox]).strftime("%Y/%m/%d") rescue ""), params[:keywords])} when "patent_category" - patent_show = patents_temp.select {|value| search_all_words((value.patent_types.collect{|pt| pt.title}.join(", ") rescue ""), params[:keywords])} + patent_show = patents_temp.select {|value| search_all_words((value.patent_types.collect{|pt| pt.title}.join(", ").to_s rescue ""), params[:keywords])} when "author_type" patents_show = patents_temp.select {|value| search_all_words(value.patent_author_types.collect{|pt| pt.title}.join(", "), params[:keywords])} when "language" From 4c6cc5e836c692955df4f31d95eb243ea70d4296 Mon Sep 17 00:00:00 2001 From: chiu Date: Fri, 16 Aug 2019 10:04:54 +0800 Subject: [PATCH 08/12] Update personal_patents_controller.rb fix error --- app/controllers/personal_patents_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/personal_patents_controller.rb b/app/controllers/personal_patents_controller.rb index a1c7546..4aab49a 100644 --- a/app/controllers/personal_patents_controller.rb +++ b/app/controllers/personal_patents_controller.rb @@ -25,7 +25,7 @@ class PersonalPatentsController < ApplicationController when "publish_date", "application_date", "end_date" patents_show = patents_temp.select {|value| search_all_words((value.send(params[:selectbox]).strftime("%Y/%m/%d") rescue ""), params[:keywords])} when "patent_category" - patent_show = patents_temp.select {|value| search_all_words((value.patent_types.collect{|pt| pt.title}.join(", ").to_s rescue ""), params[:keywords])} + patents_show = patents_temp.select {|value| search_all_words((value.patent_types.collect{|pt| pt.title}.join(", ").to_s rescue ""), params[:keywords])} when "author_type" patents_show = patents_temp.select {|value| search_all_words(value.patent_author_types.collect{|pt| pt.title}.join(", "), params[:keywords])} when "language" From ec87f059f6476b4e6cc89453d538d443b37c4410 Mon Sep 17 00:00:00 2001 From: chiu Date: Fri, 16 Aug 2019 10:39:14 +0800 Subject: [PATCH 09/12] =?UTF-8?q?Update=20=5Fform.html.erb=20=E6=8A=8A?= =?UTF-8?q?=E8=BC=B8=E5=85=A5=E6=AC=84=E4=BD=8D=E6=94=B9=E6=88=90=E8=83=BD?= =?UTF-8?q?=E8=BC=B8=E5=85=A5=E7=95=B6=E6=9C=88=E7=9A=84=E5=B9=BE=E8=99=9F?= =?UTF-8?q?=E8=80=8C=E9=9D=9E=E9=A0=90=E8=A8=AD=E7=82=BA=E7=95=B6=E6=97=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/admin/patents/_form.html.erb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/admin/patents/_form.html.erb b/app/views/admin/patents/_form.html.erb index 6c76bd4..0ca6e38 100644 --- a/app/views/admin/patents/_form.html.erb +++ b/app/views/admin/patents/_form.html.erb @@ -212,7 +212,7 @@
- <%= f.datetime_picker :publish_date, :no_label => true, :format=>"yyyy/MM", :value => @patent.publish_date, :new_record => @patent.new_record? %> + <%= f.datetime_picker :publish_date, :no_label => true, :format=>"yyyy/MM/dd", :value => @patent.publish_date, :new_record => @patent.new_record? %>
@@ -220,7 +220,7 @@
- <%= f.datetime_picker :application_date, :no_label => true, :format=>"yyyy/MM", :value => @patent.application_date, :new_record => @patent.new_record? %> + <%= f.datetime_picker :application_date, :no_label => true, :format=>"yyyy/MM/dd", :value => @patent.application_date, :new_record => @patent.new_record? %>
@@ -228,7 +228,7 @@
- <%= f.datetime_picker :end_date, :no_label => true, :format=>"yyyy/MM", :value => @patent.end_date, :new_record => @patent.new_record? %> + <%= f.datetime_picker :end_date, :no_label => true, :format=>"yyyy/MM/dd", :value => @patent.end_date, :new_record => @patent.new_record? %>
From 2eb27ea58e9931c679c542f89bfad64eb06955dc Mon Sep 17 00:00:00 2001 From: chiu Date: Fri, 16 Aug 2019 10:49:19 +0800 Subject: [PATCH 10/12] =?UTF-8?q?Update=20=5Fprofile.html.erb=20=E5=8E=9F?= =?UTF-8?q?=E6=9C=AC=E5=8F=AA=E6=9C=89=E9=A1=AF=E7=A4=BA=E5=88=B0=E6=9C=88?= =?UTF-8?q?=E4=BB=BD=EF=BC=8C=E6=94=B9=E7=82=BA=E9=A1=AF=E7=A4=BA=E5=88=B0?= =?UTF-8?q?=E5=B9=BE=E8=99=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/plugin/personal_patent/_profile.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/plugin/personal_patent/_profile.html.erb b/app/views/plugin/personal_patent/_profile.html.erb index 705da9d..767e286 100644 --- a/app/views/plugin/personal_patent/_profile.html.erb +++ b/app/views/plugin/personal_patent/_profile.html.erb @@ -43,7 +43,7 @@ <%= check_box_tag 'to_change[]', patent.id.to_s, false, :class => "list-check" %> <% end %> - <%= (patent.publish_date.strftime("%Y.%m") rescue "") %> + <%= (patent.publish_date.strftime("%Y.%m.%d") rescue "") %> <%= link_to patent.patent_title, OrbitHelper.url_to_plugin_show(patent.to_param,'personal_patent').to_s, target: "blank"%>
From c5b77493c5d5e3cdfdd82f1491ec646b821b5cf9 Mon Sep 17 00:00:00 2001 From: chiu Date: Fri, 16 Aug 2019 10:53:29 +0800 Subject: [PATCH 11/12] =?UTF-8?q?Update=20excel=5Fformat.xlsx.axlsx=20?= =?UTF-8?q?=E6=8F=90=E9=86=92=E5=8F=AF=E8=BC=B8=E5=85=A5=E5=B9=BE=E8=99=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/admin/patents/excel_format.xlsx.axlsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/admin/patents/excel_format.xlsx.axlsx b/app/views/admin/patents/excel_format.xlsx.axlsx index bfed97d..6acaab1 100644 --- a/app/views/admin/patents/excel_format.xlsx.axlsx +++ b/app/views/admin/patents/excel_format.xlsx.axlsx @@ -65,7 +65,7 @@ wb.add_worksheet(name: "Patents") do |sheet| row << t("personal_patent.publication_date") row1 << "date" - row2 << "Format: YYYY/MM, Example: 2015/12" + row2 << "Format: YYYY/MM/DD, Example: 2015/12/31" row << t("personal_patent.url") row1 << "textfield" From 0e13e154e285f0e6ea5d856b4d19bfe0c1c67604 Mon Sep 17 00:00:00 2001 From: chiu Date: Fri, 16 Aug 2019 10:56:32 +0800 Subject: [PATCH 12/12] =?UTF-8?q?Update=20=5Fpatent.html.erb=20=E6=94=B9?= =?UTF-8?q?=E7=82=BA=E9=A1=AF=E7=A4=BA=E5=88=B0=E5=B9=BE=E8=99=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/admin/patents/_patent.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/admin/patents/_patent.html.erb b/app/views/admin/patents/_patent.html.erb index e137c2e..a6df1c7 100644 --- a/app/views/admin/patents/_patent.html.erb +++ b/app/views/admin/patents/_patent.html.erb @@ -1,6 +1,6 @@ <% @patents.each do |patent| %> "> - <%= patent.publish_date.strftime("%Y.%m") rescue "" %> + <%= patent.publish_date.strftime("%Y.%m.%d") rescue "" %> <%= link_to patent.patent_title, OrbitHelper.url_to_plugin_show(patent.to_param,'personal_patent').to_s, target: "blank"%>