auto indent app/controllers/personal_honors_controller.rb

This commit is contained in:
EricTYL 2019-11-04 10:40:59 +08:00
parent bcbfd97106
commit 06c1446a5b
1 changed files with 43 additions and 43 deletions

View File

@ -18,20 +18,20 @@ class PersonalHonorsController < ApplicationController
honors.each do |honor| honors.each do |honor|
t = [] t = []
fields_to_show.each do |fs| fields_to_show.each do |fs|
case fs case fs
when "award_name" when "award_name"
t << {"value" => "<a href='#{OrbitHelper.url_to_show(honor.to_param)}'>" + (honor.send(fs) rescue "") + "</a>"} t << {"value" => "<a href='#{OrbitHelper.url_to_show(honor.to_param)}'>" + (honor.send(fs) rescue "") + "</a>"}
when "honor_type" when "honor_type"
t << {"value" => (honor.send("honor_type").title rescue "")} t << {"value" => (honor.send("honor_type").title rescue "")}
when "authors" when "authors"
t << {"value" => (honor.send(:member_profile).name rescue "")} t << {"value" => (honor.send(:member_profile).name rescue "")}
when "award_date" when "award_date"
t << {"value" => (honor.send(fs).strftime("%Y/%m") rescue "")} t << {"value" => (honor.send(fs).strftime("%Y/%m") rescue "")}
else else
t << {"value" => (honor.send(fs) rescue "")} t << {"value" => (honor.send(fs) rescue "")}
end end
end end
honor_list << {"personal_honors" => t} honor_list << {"personal_honors" => t}
end end
headers = [] headers = []
@ -73,35 +73,35 @@ class PersonalHonorsController < ApplicationController
end end
def get_fields_for_index def get_fields_for_index
@page = Page.find(params[:page_id]) rescue nil @page = Page.find(params[:page_id]) rescue nil
@fields_to_show = [ @fields_to_show = [
"year", "year",
"award_name", "award_name",
"awarding_unit", "awarding_unit",
"honor_type", "honor_type",
"award_date", "award_date",
"country", "country",
"keywords", "keywords",
"url", "url",
"note", "note",
"authors", "authors",
"award_winner" "award_winner"
] ]
@fields_to_show = @fields_to_show.map{|fs| [(fs == "authors" ? t("users.name") : t("personal_honor.#{fs}")), fs]} @fields_to_show = @fields_to_show.map{|fs| [(fs == "authors" ? t("users.name") : t("personal_honor.#{fs}")), fs]}
@default_fields_to_show = [ @default_fields_to_show = [
"honor_type", "honor_type",
"year", "year",
"award_name", "award_name",
"authors", "authors",
"awarding_unit" "awarding_unit"
] ]
render :layout => false render :layout => false
end end
def save_index_fields def save_index_fields
page = Page.find(params[:page_id]) rescue nil page = Page.find(params[:page_id]) rescue nil
page.custom_array_field = params[:keys] page.custom_array_field = params[:keys]
page.save page.save
render :json => {"success" => true}.to_json render :json => {"success" => true}.to_json
end end
end end