From 942e7af4d5df690547b391e24e239f5e64fa8add Mon Sep 17 00:00:00 2001 From: bohung Date: Fri, 14 Aug 2020 11:07:30 +0800 Subject: [PATCH] Add display author text fields in the frontend authors field. --- app/helpers/admin/journal_papers_helper.rb | 5 +++-- app/models/journal_paper.rb | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/helpers/admin/journal_papers_helper.rb b/app/helpers/admin/journal_papers_helper.rb index 50e45a6..cfe0bb6 100644 --- a/app/helpers/admin/journal_papers_helper.rb +++ b/app/helpers/admin/journal_papers_helper.rb @@ -3,13 +3,14 @@ module Admin::JournalPapersHelper (journal.authors.to_s.blank? ? get_member(journal).collect(&:name).join('/') : Nokogiri::HTML(journal.authors.to_s).text rescue "") end def get_authors_show(journal) - (journal.authors.to_s.blank? ? get_member_show(journal) : (journal.authors.to_s) rescue "") + member_names = get_member_show(journal) + (journal.authors.to_s.blank? ? get_member_show(journal) : (member_names.blank? ? journal.authors.to_s : (member_names + "、" + journal.authors.to_s.gsub(",","、").gsub(",","、")) ) rescue "") end def get_member(journal) Array(MemberProfile.find(Array(journal).collect(&:member_profile_id))) rescue [] end def get_member_show(journal) - get_member(journal).collect{|member| "#{member.name}"}.join('/') + get_member(journal).collect{|member| "#{member.name}"}.join('、') end def get_level_type(journal) !journal.journal_levels.blank? ? "(#{journal.journal_levels.collect(&:title).join(', ')})" : nil diff --git a/app/models/journal_paper.rb b/app/models/journal_paper.rb index 3630718..2905019 100644 --- a/app/models/journal_paper.rb +++ b/app/models/journal_paper.rb @@ -218,7 +218,7 @@ class JournalPaper when "url" value = self.url.to_s.blank? ? "" : "#{self.url}" when "authors" - value = get_member_show(self) rescue "" + value = get_authors_show(self) rescue "" else value = self.send(field) rescue "" end