now can select between one line and table

This commit is contained in:
Harry Bomrah 2016-03-22 17:58:37 +08:00
parent cb4f813db7
commit 33acff9f10
3 changed files with 81 additions and 19 deletions

View File

@ -1,21 +1,58 @@
class PersonalJournalsController < ApplicationController class PersonalJournalsController < ApplicationController
def index def index
params = OrbitHelper.params
journal_papers = JournalPaper.where(:is_hidden=>false).order_by(:year=>'desc').page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count) journal_papers = JournalPaper.where(:is_hidden=>false).order_by(:year=>'desc').page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count)
journal_paper_list = journal_papers.collect do |journal_paper| page = Page.where(:page_id => params[:page_id]).first rescue nil
{ if page.custom_string_field == "table"
"year" => journal_paper.year, fields_to_show = [
"paper_title" => journal_paper.create_link, "paper_title",
"link_to_show" => OrbitHelper.url_to_show(journal_paper.to_param) "journal_title",
"authors",
"year",
"issue_no",
"vol_no",
"level_type"
]
else
fields_to_show = [
"year",
"paper_title"
]
end
journal_paper_list = []
journal_papers.each do |journal_paper|
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(journal_paper.to_param)}'>#{journal_paper.paper_title}</a>"}
else
t << {"value" => "<a href='#{OrbitHelper.url_to_show(journal_paper.to_param)}'>#{journal_paper.create_link}</a>"}
end
when "level_type"
t << {"value" => ( !journal_paper.journal_levels.blank? ? "(#{journal_paper.journal_levels.collect{|x| x.title}.join(', ')})" : nil)}
else
t << {"value" => journal_paper.send(fs)}
end
end
journal_paper_list << {"jps" => t}
end
headers = []
fields_to_show.each do |fs|
col = 2
col = 3 if fs == "paper_title"
headers << {
"head-title" => t("personal_journal.#{fs}"),
"col" => col
} }
end end
{ {
"journal_papers" => journal_paper_list, "journal_papers" => journal_paper_list,
"extras" => { "headers" => headers,
"widget-title" => t("module_name.journal_paper"), "extras" => {"widget-title" => t("module_name.journal_paper")},
"th_year" => t('personal_plugins.year'),
"th_title" => t("personal_conference.paper_title"),
"th_author" => t('personal_plugins.author')
},
"total_pages" => journal_papers.total_pages "total_pages" => journal_papers.total_pages
} }
end end

View File

@ -70,10 +70,24 @@ class JournalPaper
end end
def self.get_plugin_datas_to_member(datas) def self.get_plugin_datas_to_member(datas)
page = Page.where(:module => "personal_journal").first rescue nil
if page.custom_string_field == "table"
fields_to_show = [
"paper_title",
"journal_title",
"authors",
"year",
"issue_no",
"vol_no",
"level_type"
]
else
fields_to_show = [ fields_to_show = [
"year", "year",
"paper_title" "paper_title"
] ]
end
fields_to_remove = [] fields_to_remove = []
@ -96,12 +110,23 @@ class JournalPaper
pd_data = [] pd_data = []
fields_to_show.collect do |t| fields_to_show.collect do |t|
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_journal')}' target='_blank'>#{p.paper_title}</a>" }
when "level_type"
pd_data << {"data_title" => ( !p.journal_levels.blank? ? "(#{p.journal_levels.collect{|x| x.title}.join(', ')})" : nil)}
else
pd_data << {"data_title" => p.send(t)}
end
else
if t == "paper_title" if t == "paper_title"
pd_data << { "data_title" => "<a href='#{OrbitHelper.url_to_plugin_show(p.to_param,'personal_journal')}' target='_blank'>#{p.create_link}</a>" } pd_data << { "data_title" => "<a href='#{OrbitHelper.url_to_plugin_show(p.to_param,'personal_journal')}' target='_blank'>#{p.create_link}</a>" }
else else
pd_data << { "data_title" => p.send(t) } pd_data << { "data_title" => p.send(t) }
end end
end end
end
{ {
"pd_datas" => pd_data "pd_datas" => pd_data

View File

@ -4,7 +4,7 @@ module PersonalJournal
OrbitApp.registration "PersonalJournal",:type=> 'ModuleApp' do OrbitApp.registration "PersonalJournal",:type=> 'ModuleApp' do
module_label 'module_name.journal_paper' module_label 'module_name.journal_paper'
base_url File.expand_path File.dirname(__FILE__) base_url File.expand_path File.dirname(__FILE__)
personal_plugin :enable => true, :sort_number => '5', :app_name=>"JournalPaper", :intro_app_name=>"JournalPaperlIntro",:path=>"/plugin/personal_journal/profile",:front_path=>"/profile",:admin_path=>"/admin/journal_papers/",:i18n=>'module_name.journal_paper', :module_app_name=>'PersonalJournal' personal_plugin :enable => true, :sort_number => '5', :app_name=>"JournalPaper", :intro_app_name=>"JournalPaperlIntro",:path=>"/plugin/personal_journal/profile",:front_path=>"/profile",:admin_path=>"/admin/journal_papers/",:i18n=>'module_name.journal_paper', :module_app_name=>'PersonalJournal', :one_line_title => true
version "0.1" version "0.1"
desktop_enabled true desktop_enabled true