2016-03-21 08:39:54 +00:00
|
|
|
class PersonalTechnologyTransfersController < ApplicationController
|
|
|
|
def index
|
|
|
|
params = OrbitHelper.params
|
2016-04-11 11:27:06 +00:00
|
|
|
tts = TechnologyTransfer.where(:is_hidden=>false).sort_for_frontend.page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count)
|
2016-03-21 08:39:54 +00:00
|
|
|
fields_to_show = Page.where(:page_id => params[:page_id]).first.custom_array_field rescue []
|
|
|
|
|
|
|
|
if fields_to_show.blank?
|
|
|
|
fields_to_show = [
|
|
|
|
"year",
|
|
|
|
"title",
|
|
|
|
"patent_title",
|
|
|
|
"category",
|
|
|
|
"patent_granted",
|
|
|
|
"patent_number",
|
|
|
|
"authors"
|
|
|
|
]
|
|
|
|
end
|
|
|
|
|
|
|
|
tts_list = []
|
|
|
|
|
|
|
|
tts.each do |tt|
|
|
|
|
t = []
|
|
|
|
fields_to_show.each do |fs|
|
|
|
|
case fs
|
2016-04-11 11:27:06 +00:00
|
|
|
when "title"
|
|
|
|
t << {"value" => "<a href='#{OrbitHelper.url_to_show(tt.to_param)}'>" + (tt.send(fs) rescue "") + "</a>"}
|
|
|
|
when "category"
|
|
|
|
t << {"value" => (tt.send("technology_transfer_category").title rescue "")}
|
|
|
|
when "authors"
|
|
|
|
t << {"value" => (tt.send(:member_profile).name rescue "")}
|
|
|
|
when "patent_granted"
|
|
|
|
t << {"value" => (tt.patent_granted ? t("personal_technology_transfer.y_es") : t("personal_technology_transfer.n_o"))}
|
|
|
|
else
|
|
|
|
t << {"value" => (tt.send(fs) rescue "")}
|
|
|
|
end
|
2016-03-21 08:39:54 +00:00
|
|
|
end
|
|
|
|
tts_list << {"technology_transfers" => t}
|
|
|
|
end
|
|
|
|
|
|
|
|
headers = []
|
|
|
|
fields_to_show.each do |fs|
|
|
|
|
col = 2
|
|
|
|
col = 3 if fs == "patent_title"
|
|
|
|
header = fs == "authors" ? t("users.name") : t("personal_technology_transfer.#{fs}")
|
|
|
|
headers << {
|
|
|
|
"head-title" => header,
|
|
|
|
"col" => col
|
|
|
|
}
|
|
|
|
end
|
|
|
|
{
|
|
|
|
"tts" => tts_list,
|
|
|
|
"extras" => { "widget-title" => t("module_name.personal_technology_transfer")},
|
|
|
|
"headers" => headers,
|
|
|
|
"total_pages" => tts.total_pages
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def show
|
|
|
|
params = OrbitHelper.params
|
|
|
|
plugin = TechnologyTransfer.where(:is_hidden=>false).find_by(uid: params[:uid])
|
|
|
|
fields_to_show = [
|
|
|
|
"year",
|
2016-04-13 08:38:59 +00:00
|
|
|
"category",
|
2016-03-21 08:39:54 +00:00
|
|
|
"title",
|
|
|
|
"patent_title",
|
|
|
|
"category",
|
|
|
|
"patent_granted",
|
|
|
|
"patent_number",
|
2016-04-13 08:38:59 +00:00
|
|
|
"authors"
|
2016-03-21 08:39:54 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
{"plugin_datas"=>plugin.get_plugin_data(fields_to_show)}
|
|
|
|
end
|
|
|
|
|
|
|
|
def get_fields_for_index
|
|
|
|
@page = Page.find(params[:page_id]) rescue nil
|
|
|
|
@fields_to_show = [
|
|
|
|
"year",
|
|
|
|
"title",
|
|
|
|
"patent_title",
|
|
|
|
"category",
|
|
|
|
"patent_granted",
|
|
|
|
"patent_number",
|
|
|
|
"authors"
|
|
|
|
]
|
|
|
|
@fields_to_show = @fields_to_show.map{|fs| [(fs == "authors" ? t("users.name") : t("personal_technology_transfer.#{fs}")), fs]}
|
|
|
|
@default_fields_to_show = [
|
|
|
|
"category",
|
|
|
|
"year",
|
|
|
|
"title",
|
|
|
|
"patent_granted",
|
|
|
|
"patent_title",
|
|
|
|
"patent_number"
|
|
|
|
]
|
|
|
|
render :layout => false
|
|
|
|
end
|
|
|
|
|
|
|
|
def save_index_fields
|
|
|
|
page = Page.find(params[:page_id]) rescue nil
|
|
|
|
page.custom_array_field = params[:keys]
|
|
|
|
page.save
|
|
|
|
render :json => {"success" => true}.to_json
|
|
|
|
end
|
|
|
|
end
|