Update frontend
This commit is contained in:
parent
510fb3bf0b
commit
1e306cf6b1
|
@ -27,47 +27,22 @@ class PersonalPatentsController < ApplicationController
|
||||||
|
|
||||||
def show
|
def show
|
||||||
params = OrbitHelper.params
|
params = OrbitHelper.params
|
||||||
patent = Patent.where(:is_hidden=>false).find_by(uid: params[:uid])
|
plugin = Patent.where(:is_hidden=>false).find_by(uid: params[:uid])
|
||||||
|
fields_to_show = [
|
||||||
|
"patent_title",
|
||||||
|
"patent_type",
|
||||||
|
"authors",
|
||||||
|
"year",
|
||||||
|
"language",
|
||||||
|
"keywords",
|
||||||
|
"patent_no",
|
||||||
|
"patent_country",
|
||||||
|
"publish_date",
|
||||||
|
"url",
|
||||||
|
"note",
|
||||||
|
"file"
|
||||||
|
]
|
||||||
|
|
||||||
files = patent.patent_files.map do |file|
|
{"plugin_datas"=>plugin.get_plugin_data(fields_to_show)}
|
||||||
{
|
|
||||||
"file_url" => file.file.url,
|
|
||||||
"file_title" => (file.title.blank? ? File.basename(file.file.path) : file.title),
|
|
||||||
"file_ext" => File.extname(file.file.path).sub('.',''),
|
|
||||||
"file_description" => file.description
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
{
|
|
||||||
"files" => files,
|
|
||||||
|
|
||||||
"data" => {
|
|
||||||
"patent_title" => patent.patent_title,
|
|
||||||
"patent_type" => (patent.patent_type.title rescue ""),
|
|
||||||
"authors" => patent.authors,
|
|
||||||
"year" => patent.year,
|
|
||||||
"language" => (t(patent.language) rescue ""),
|
|
||||||
"keywords" => patent.keywords,
|
|
||||||
"patent_no" => patent.patent_no,
|
|
||||||
"patent_country" => patent.patent_country,
|
|
||||||
"publish_date" => (patent.publish_date.strftime("%Y.%m") rescue ""),
|
|
||||||
"url" => patent.url,
|
|
||||||
"note" => patent.note,
|
|
||||||
|
|
||||||
"th_patent_title" => t("personal_patent.patent_title"),
|
|
||||||
"th_authors" => t("personal_patent.authors"),
|
|
||||||
"th_year" => t("personal_patent.year"),
|
|
||||||
"th_language" => t("personal_patent.language"),
|
|
||||||
"th_keywords" => t("personal_patent.keywords"),
|
|
||||||
"th_patent_no" => t("personal_patent.patent_no"),
|
|
||||||
"th_patent_country" => t("personal_patent.patent_country"),
|
|
||||||
"th_publish_date" => t("personal_patent.publication_date"),
|
|
||||||
"th_url" => t("personal_patent.url"),
|
|
||||||
"th_note" => t("personal_patent.note"),
|
|
||||||
|
|
||||||
"th_patent_type" => t("personal_patent.patent_category"),
|
|
||||||
"th_files" => t(:file_)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -29,6 +29,43 @@ class Patent
|
||||||
|
|
||||||
before_validation :add_http
|
before_validation :add_http
|
||||||
|
|
||||||
|
def get_plugin_data(fields_to_show)
|
||||||
|
plugin_datas = []
|
||||||
|
fields_to_show.each do |field|
|
||||||
|
plugin_data = self.get_plugin_field_data(field)
|
||||||
|
next if plugin_data.blank? or plugin_data['value'].blank?
|
||||||
|
plugin_datas << plugin_data
|
||||||
|
end
|
||||||
|
plugin_datas
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_plugin_field_data(field)
|
||||||
|
case field
|
||||||
|
when "language"
|
||||||
|
value = I18n.t(self.language) rescue ""
|
||||||
|
when "file"
|
||||||
|
files = []
|
||||||
|
self.patent_files.each do |patent_file|
|
||||||
|
url = patent_file.file.url
|
||||||
|
title = (patent_file.title.blank? ? File.basename(patent_file.file.path) : patent_file.title)
|
||||||
|
files << "<li><a href='#{url}'' target='_blank'>#{title}</li>"
|
||||||
|
end
|
||||||
|
value = files.join("")
|
||||||
|
else
|
||||||
|
value = self.send(field) rescue ""
|
||||||
|
end
|
||||||
|
|
||||||
|
value = (value =~ /\A#{URI::regexp(['http', 'https'])}\z/) ? "<a href='#{value}' target='blank'>#{value}</a>" : value
|
||||||
|
|
||||||
|
{
|
||||||
|
"key"=>field,
|
||||||
|
"title_class"=>"patent-#{field.gsub('_','-')}-field",
|
||||||
|
"value_class"=>"patent-#{field.gsub('_','-')}-value",
|
||||||
|
"title"=>I18n.t('personal_patent.'+field),
|
||||||
|
"value"=>value
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def add_http
|
def add_http
|
||||||
|
|
|
@ -22,6 +22,7 @@ en:
|
||||||
keywords : "Keywords"
|
keywords : "Keywords"
|
||||||
abstract : "Abstract"
|
abstract : "Abstract"
|
||||||
publication_date : "Date of Publication"
|
publication_date : "Date of Publication"
|
||||||
|
publish_date: "Publish Date"
|
||||||
url : "Reference URL"
|
url : "Reference URL"
|
||||||
note : "Note"
|
note : "Note"
|
||||||
level_type : "Level Type"
|
level_type : "Level Type"
|
||||||
|
|
|
@ -22,6 +22,7 @@ zh_tw:
|
||||||
keywords : "關鍵字"
|
keywords : "關鍵字"
|
||||||
abstract : "摘要"
|
abstract : "摘要"
|
||||||
publication_date : "發表日期"
|
publication_date : "發表日期"
|
||||||
|
publish_date : "發表日期"
|
||||||
url : "參考連結"
|
url : "參考連結"
|
||||||
note : "記事"
|
note : "記事"
|
||||||
level_type : "期刊類別"
|
level_type : "期刊類別"
|
||||||
|
|
Loading…
Reference in New Issue