forked from saurabh/personal-journal
now can select between one line and table
This commit is contained in:
parent
cb4f813db7
commit
33acff9f10
|
@ -1,21 +1,58 @@
|
|||
class PersonalJournalsController < ApplicationController
|
||||
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_paper_list = journal_papers.collect do |journal_paper|
|
||||
{
|
||||
"year" => journal_paper.year,
|
||||
"paper_title" => journal_paper.create_link,
|
||||
"link_to_show" => OrbitHelper.url_to_show(journal_paper.to_param)
|
||||
page = Page.where(:page_id => params[:page_id]).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 = [
|
||||
"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
|
||||
|
||||
{
|
||||
"journal_papers" => journal_paper_list,
|
||||
"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')
|
||||
},
|
||||
"headers" => headers,
|
||||
"extras" => {"widget-title" => t("module_name.journal_paper")},
|
||||
"total_pages" => journal_papers.total_pages
|
||||
}
|
||||
end
|
||||
|
|
|
@ -70,10 +70,24 @@ class JournalPaper
|
|||
end
|
||||
|
||||
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 = [
|
||||
"year",
|
||||
"paper_title"
|
||||
]
|
||||
end
|
||||
|
||||
fields_to_remove = []
|
||||
|
||||
|
@ -96,12 +110,23 @@ class JournalPaper
|
|||
|
||||
pd_data = []
|
||||
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"
|
||||
pd_data << { "data_title" => "<a href='#{OrbitHelper.url_to_plugin_show(p.to_param,'personal_journal')}' target='_blank'>#{p.create_link}</a>" }
|
||||
else
|
||||
pd_data << { "data_title" => p.send(t) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
{
|
||||
"pd_datas" => pd_data
|
||||
|
|
|
@ -4,7 +4,7 @@ module PersonalJournal
|
|||
OrbitApp.registration "PersonalJournal",:type=> 'ModuleApp' do
|
||||
module_label 'module_name.journal_paper'
|
||||
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"
|
||||
desktop_enabled true
|
||||
|
|
Loading…
Reference in New Issue