forked from saurabh/personal-diploma
Update frontend
This commit is contained in:
parent
893313741f
commit
774df67db0
|
@ -26,32 +26,20 @@ class PersonalDiplomasController < ApplicationController
|
||||||
|
|
||||||
def show
|
def show
|
||||||
params = OrbitHelper.params
|
params = OrbitHelper.params
|
||||||
diploma = Diploma.where(:is_hidden=>false).find_by(uid: params[:uid])
|
plugin = Diploma.where(:is_hidden=>false).find_by(uid: params[:uid])
|
||||||
|
|
||||||
{
|
fields_to_show = [
|
||||||
"school_name" => diploma.school_name,
|
"name",
|
||||||
"country" => diploma.country,
|
"school_name",
|
||||||
"department" => diploma.department,
|
"duration",
|
||||||
"degree" => diploma.degree,
|
"country",
|
||||||
"language" => t(diploma.language),
|
"department",
|
||||||
"keywords" => diploma.keywords,
|
"degree",
|
||||||
"start_date" => diploma.start_date,
|
"url",
|
||||||
"end_date" => diploma.end_date,
|
"keywords",
|
||||||
"duration" => diploma.duration,
|
"note"
|
||||||
"url" => diploma.url,
|
]
|
||||||
"note" => diploma.note,
|
|
||||||
|
|
||||||
"th_school_name" => t("personal_diploma.school_name"),
|
{"plugin_datas"=>plugin.get_plugin_data(fields_to_show)}
|
||||||
"th_country" => t("personal_diploma.country"),
|
|
||||||
"th_department" => t("personal_diploma.department"),
|
|
||||||
"th_degree" => t("personal_diploma.degree"),
|
|
||||||
"th_language" => t("personal_diploma.language"),
|
|
||||||
"th_keywords" => t("personal_diploma.keywords"),
|
|
||||||
"th_start_date" => t("personal_diploma.start_date"),
|
|
||||||
"th_end_date" => t("personal_diploma.end_date"),
|
|
||||||
"th_duration" => t("personal_diploma.duration"),
|
|
||||||
"th_url" => t("personal_diploma.url"),
|
|
||||||
"th_note" => t("personal_diploma.note")
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -37,6 +37,35 @@ class Diploma
|
||||||
[self.school_name,self.department,self.degree].join(' ')
|
[self.school_name,self.department,self.degree].join(' ')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
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 ""
|
||||||
|
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"=>"diploma-#{field.gsub('_','-')}-field",
|
||||||
|
"value_class"=>"diploma-#{field.gsub('_','-')}-value",
|
||||||
|
"title"=>I18n.t('personal_diploma.'+field),
|
||||||
|
"value"=>value
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def add_http
|
def add_http
|
||||||
|
|
Loading…
Reference in New Issue