diff --git a/app/controllers/personal_journals_controller.rb b/app/controllers/personal_journals_controller.rb index 9219f3e..4a0a6b6 100644 --- a/app/controllers/personal_journals_controller.rb +++ b/app/controllers/personal_journals_controller.rb @@ -4,6 +4,7 @@ class PersonalJournalsController < ApplicationController journal_papers = JournalPaper.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 = page.custom_array_field rescue [] fields_to_show = [ "paper_title", "journal_title", @@ -12,7 +13,7 @@ class PersonalJournalsController < ApplicationController "issue_no", "vol_no", "level_type" - ] + ] if fields_to_show.blank? else fields_to_show = [ "year", @@ -32,6 +33,8 @@ class PersonalJournalsController < ApplicationController end when "level_type" t << {"value" => ( !journal_paper.journal_levels.blank? ? "(#{journal_paper.journal_levels.collect{|x| x.title}.join(', ')})" : nil)} + when "publication_date" + t << {"value" => (journal_paper.send(fs).strftime("%Y/%m/%d") rescue "")} else t << {"value" => journal_paper.send(fs)} end @@ -84,4 +87,44 @@ class PersonalJournalsController < ApplicationController {"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", + "authors", + "author_type", + "paper_title", + "journal_title", + "vol_no", + "issue_no", + "form_to_start", + "form_to_end", + "level_type", + "paper_type", + "total_pages", + "publication_date", + "isbn", + "abstract", + "language", + "url" + ] + @fields_to_show = @fields_to_show.map{|fs| [t("personal_journal.#{fs}"), fs]} + @default_fields_to_show = [ + "paper_title", + "journal_title", + "authors", + "year", + "issue_no", + "vol_no", + "level_type" + ] + 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 diff --git a/app/models/journal_paper.rb b/app/models/journal_paper.rb index d682197..b223334 100644 --- a/app/models/journal_paper.rb +++ b/app/models/journal_paper.rb @@ -73,15 +73,19 @@ class JournalPaper page = Page.where(:module => "personal_journal").first rescue nil if !page.nil? && page.custom_string_field == "table" - fields_to_show = [ - "paper_title", - "journal_title", - "authors", - "year", - "issue_no", - "vol_no", - "level_type" - ] + if !page.custom_array_field.blank? + fields_to_show = page.custom_array_field + else + fields_to_show = [ + "paper_title", + "journal_title", + "authors", + "year", + "issue_no", + "vol_no", + "level_type" + ] + end else fields_to_show = [ "year", @@ -116,6 +120,8 @@ class JournalPaper pd_data << { "data_title" => "#{p.paper_title}" } when "level_type" pd_data << {"data_title" => ( !p.journal_levels.blank? ? "(#{p.journal_levels.collect{|x| x.title}.join(', ')})" : nil)} + when "publication_date" + pd_data << {"data_title" => (p.send(t).strftime("%Y/%m/%d") rescue "")} else pd_data << {"data_title" => p.send(t)} end @@ -183,6 +189,8 @@ class JournalPaper value = self.journal_paper_author_types.collect{|type| type.title}.join(',') rescue "" when "paper_type" value = self.journal_paper_type.title rescue "" + when "publication_date" + value = p.send(t).strftime("%Y/%m/%d") rescue "" when "author_name" value = [] ([I18n.locale]+(Site.first.in_use_locales-[I18n.locale])).each do |locale| diff --git a/app/views/personal_journals/get_fields_for_index.html.erb b/app/views/personal_journals/get_fields_for_index.html.erb new file mode 100644 index 0000000..7a3da03 --- /dev/null +++ b/app/views/personal_journals/get_fields_for_index.html.erb @@ -0,0 +1,48 @@ +<% if !@page.nil? %> +
+ +<% else %> +