can select one line and table

This commit is contained in:
Harry Bomrah 2016-03-22 18:00:05 +08:00
parent b4fcb4d2f1
commit 98ce21d67e
5 changed files with 87 additions and 19 deletions

View File

@ -1,22 +1,60 @@
class PersonalConferencesController < ApplicationController
def index
params = OrbitHelper.params
writing_conferences = WritingConference.where(:is_hidden=>false).order_by(:year=>'desc').page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count)
page = Page.where(:page_id => params[:page_id]).first rescue nil
if page.custom_string_field == "table"
fields_to_show = [
"authors",
"paper_title",
"conference_title",
"location",
"paper_types",
"paper_levels"
]
else
fields_to_show = [
"year",
"paper_title"
]
end
writing_conference_list = writing_conferences.collect do |writing_conference|
{
"year" => writing_conference.year,
"paper_title" => writing_conference.create_link,
"link_to_show" => OrbitHelper.url_to_show(writing_conference.to_param)
writing_conference_list = []
writing_conferences.each do |writing_conference|
t = []
fields_to_show.each do |fs|
case fs
when "paper_title"
if page.custom_string_field == "table"
t << {"value" => "<a href='#{OrbitHelper.url_to_show(writing_conference.to_param)}'>#{writing_conference.paper_title}</a>"}
else
t << {"value" => "<a href='#{OrbitHelper.url_to_show(writing_conference.to_param)}'>#{writing_conference.create_link}</a>"}
end
when "paper_levels"
t << {"value" => ( !writing_conference.conference_paper_levels.blank? ? "(#{writing_conference.conference_paper_levels.collect{|x| x.title}.join(', ')})" : nil)}
when "paper_types"
t << {"value" => ( !writing_conference.conference_paper_levels.blank? ? "(#{writing_conference.conference_paper_levels.collect{|x| x.title}.join(', ')})" : nil)}
else
t << {"value" => writing_conference.send(fs)}
end
end
writing_conference_list << {"cps" => t}
end
headers = []
fields_to_show.each do |fs|
col = 2
col = 3 if fs == "paper_title"
headers << {
"head-title" => t("personal_conference.#{fs}"),
"col" => col
}
end
{
"writing_conferences" => writing_conference_list,
"extras" => {
"widget-title" => t("module_name.personal_conference"),
"th_year" => t('personal_plugins.year'),
"th_title" => t("personal_conference.paper_title"),
"th_author" => t('personal_plugins.author')
},
"extras" => { "widget-title" => t("module_name.personal_conference") },
"headers" => headers,
"total_pages" => writing_conferences.total_pages
}
end

View File

@ -64,12 +64,25 @@ class WritingConference
title.join(', ')
end
def self.get_plugin_datas_to_member(datas)
fields_to_show = [
"year",
"paper_title"
]
page = Page.where(:module => "personal_conference").first rescue nil
if page.custom_string_field == "table"
fields_to_show = [
"authors",
"paper_title",
"conference_title",
"location",
"paper_types",
"paper_levels"
]
else
fields_to_show = [
"year",
"paper_title"
]
end
fields_to_remove = []
@ -92,10 +105,23 @@ class WritingConference
pd_data = []
fields_to_show.collect do |t|
if t == "paper_title"
pd_data << { "data_title" => "<a href='#{OrbitHelper.url_to_plugin_show(p.to_param,'personal_conference')}' target='_blank'>#{p.create_link}</a>" }
if page.custom_string_field == "table"
case t
when "paper_title"
pd_data << { "data_title" => "<a href='#{OrbitHelper.url_to_plugin_show(p.to_param,'personal_conference')}' target='_blank'>#{p.paper_title}</a>" }
when "paper_types"
pd_data << {"data_title" => ( !p.conference_paper_types.blank? ? p.conference_paper_types.collect{|x| x.title}.join(', ') : "")}
when "paper_levels"
pd_data << {"data_title" => ( !p.conference_paper_levels.blank? ? p.conference_paper_levels.collect{|x| x.title}.join(', ') : "")}
else
pd_data << { "data_title" => p.send(t) }
end
else
pd_data << { "data_title" => p.send(t) }
if t == "paper_title"
pd_data << { "data_title" => "<a href='#{OrbitHelper.url_to_plugin_show(p.to_param,'personal_conference')}' target='_blank'>#{p.create_link}</a>" }
else
pd_data << { "data_title" => p.send(t) }
end
end
end

View File

@ -9,6 +9,8 @@ en:
paper_title : "Paper Title"
paper_type : "Paper Type"
paper_level : "Paper Level"
paper_types : "Paper Type"
paper_levels : "Paper Level"
conference_title : "Conference Name"
conference_time: "Conference Time"
period_start_date : "Start Date"

View File

@ -8,6 +8,8 @@ zh_tw:
paper_title : "論文名稱"
paper_type : "論文類型"
paper_level: "論文等級"
paper_types : "論文類型"
paper_levels: "論文等級"
conference_title : "會議名稱"
conference_time: "會議時間"
period_start_date : "會議開始時間"

View File

@ -4,7 +4,7 @@ module PersonalConference
OrbitApp.registration "PersonalConference",:type=> 'ModuleApp' do
module_label 'module_name.personal_conference'
base_url File.expand_path File.dirname(__FILE__)
personal_plugin :enable => true, :sort_number => '6', :app_name=>"WritingConference", :intro_app_name=>"PersonalConferenceIntro",:path=>"/plugin/personal_conference/profile",:front_path=>"/profile",:admin_path=>"/admin/writing_conferences",:i18n=>'module_name.personal_conference', :module_app_name=>'PersonalConference'
personal_plugin :enable => true, :sort_number => '6', :app_name=>"WritingConference", :intro_app_name=>"PersonalConferenceIntro",:path=>"/plugin/personal_conference/profile",:front_path=>"/profile",:admin_path=>"/admin/writing_conferences",:i18n=>'module_name.personal_conference', :module_app_name=>'PersonalConference', :one_line_title => true
version "0.1"
desktop_enabled true