diff --git a/app/controllers/admin/personal_plugin_fields_controller.rb b/app/controllers/admin/personal_plugin_fields_controller.rb
index 6ff92dc..f50d947 100644
--- a/app/controllers/admin/personal_plugin_fields_controller.rb
+++ b/app/controllers/admin/personal_plugin_fields_controller.rb
@@ -137,7 +137,16 @@ class Admin::PersonalPluginFieldsController < OrbitMemberController
begin
in_use_locales = Site.first.in_use_locales
primary_modal_fields = @personal_plugin_field.primary_modal_fields.select{|f| (f[:field_name].present? rescue false)}
- primary_modal_fields << {:field_name=>"authors", :translation_name=>{"zh_tw"=>"全部作者", "en"=>"Authors"}, :field_type=>"text_editor", :localize=>"1", :slug_title=>"0", :periodic_time=>"0"} if primary_modal_fields.select{|f| f[:field_name] == "authors"}.count == 0
+ authors_translation_name = @personal_plugin_field.authors_name_translations
+ in_use_locales.each do |l|
+ l = l.to_s
+ if authors_translation_name[l].blank?
+ I18n.with_locale(l) do
+ authors_translation_name[l] = I18n.t("personal_plugin_generator.authors")
+ end
+ end
+ end
+ primary_modal_fields << {:field_name=>"authors", :translation_name=> authors_translation_name, :field_type=>"text_editor", :localize=>"1", :slug_title=>"0", :periodic_time=>"0"} if primary_modal_fields.select{|f| f[:field_name] == "authors"}.count == 0 && @personal_plugin_field.enable_authors
yml_files = Dir.glob("#{cp_template_dir_path}config/locales/*.yml")
yml_files.each do |yml_file|
locale = yml_file.split("/").last.split(".yml").first
@@ -232,7 +241,7 @@ class Admin::PersonalPluginFieldsController < OrbitMemberController
backend_index_fields = @personal_plugin_field.backend_fields["index"].to_a rescue []
backend_index_fields_contents = backend_index_fields.map do |field_name|
if field_name == slug_title
- "\n <%= link_to #{plugin_template}.#{field_name}, page_for_#{plugin_template}(#{plugin_template}), target: \"blank\" %>\n" +
+ "\n <%= link_to #{plugin_template}.#{field_name}, OrbitHelper.url_to_plugin_show(plugin_template.to_param,'personal_plugin_template').to_s, target: \"blank\" %>\n" +
"
\n"+
"
\n"+
" - <%= link_to t('edit'), edit_admin_#{plugin_template}_path(#{plugin_template},:page => params[:page]) %>
\n"+
@@ -274,6 +283,10 @@ class Admin::PersonalPluginFieldsController < OrbitMemberController
col_name_to_show = @personal_plugin_field.frontend_fields["member_show"].to_a rescue []
col_name_to_show_in_show_page = @personal_plugin_field.frontend_fields["show"].to_a rescue []
col_name_to_show_in_index_page = @personal_plugin_field.frontend_fields["index"].to_a rescue []
+ if @personal_plugin_field.enable_authors
+ col_name_to_show_in_show_page = col_name_to_show_in_show_page.map{|col| (col == 'member_profile' ? 'authors' : col)}
+ col_name_to_show_in_index_page = col_name_to_show_in_index_page.map{|col| (col == 'member_profile' ? 'authors' : col)}
+ end
extra_translate_title = col_name_to_show_in_index_page.map{|field_name| #在個人外掛前台index頁面的欄位翻譯名稱hash
["th-#{field_name}","I18n.t(\"#{@personal_plugin_field.module_name}.#{field_name}\")"]
}
@@ -304,6 +317,15 @@ class Admin::PersonalPluginFieldsController < OrbitMemberController
datetime_fields = primary_modal_fields.select{|field_value| datetime_field_types_hash.keys.include?(field_value[:field_type])}.map{|field_value|
[field_value[:field_name],datetime_field_types_hash[field_value[:field_type]]]
}.to_h
+ if @personal_plugin_field.enable_authors
+ authors_codes = ["elsif field == \"member_profile\" || field == \"authors\"",
+ "#{@blank_text}value = get_authors_show(#{plugin_template})"]
+ else
+ authors_codes = ["elsif field == \"member_profile\"",
+ "#{@blank_text}member = #{plugin_template}.member_profile",
+ "#{@blank_text}member_name = (member ? member.name : nil)",
+ "#{@blank_text}value = (member ? \"\#{member_name}\" : \"\")"]
+ end
value_case_codes = ["value = #{plugin_template}.send(field) rescue \"\"",
"if field.include?(\".\")",
"#{@blank_text}value = #{plugin_template}",
@@ -336,8 +358,7 @@ class Admin::PersonalPluginFieldsController < OrbitMemberController
"#{@blank_text}}",
"#{@blank_text}join_text = (text_only rescue false) ? \",\" : \"
\"",
"#{@blank_text}value = value.join(join_text)",
- "elsif field == \"member_profile\" || field == \"authors\"",
- "#{@blank_text}value = get_authors_show(#{plugin_template})",
+ *authors_codes,
"end",
"strftime_hash = #{datetime_fields}",
"if strftime_hash.keys.include?(field)",
diff --git a/app/models/personal_plugin_field.rb b/app/models/personal_plugin_field.rb
index aecd973..b8cad09 100644
--- a/app/models/personal_plugin_field.rb
+++ b/app/models/personal_plugin_field.rb
@@ -5,7 +5,9 @@ class PersonalPluginField
include MemberHelper
field :one_line_title_format, :type => String, :default => ""
field :enable_one_line_title, :type => Boolean, :default => false
+ field :enable_authors, :type => Boolean, :default => true
field :author_name, :type => String, :default => "",:localize => true
+ field :authors_name, :type => String, :default => "",:localize => true
field :title, :type => String, :default => "",:localize => true
field :module_name, :type => String, :default => ""
field :primary_modal_name, :type => String, :default => ""
diff --git a/app/views/admin/personal_plugin_fields/_form.html.erb b/app/views/admin/personal_plugin_fields/_form.html.erb
index 0b3d794..2b63925 100644
--- a/app/views/admin/personal_plugin_fields/_form.html.erb
+++ b/app/views/admin/personal_plugin_fields/_form.html.erb
@@ -9,7 +9,7 @@
.ui-helper-hidden-accessible{
display: none;
}
- label[for="enable_one_line_title"] .toggle-control{
+ label[for="enable_one_line_title"] .toggle-control, label[for="enable_authors"] .toggle-control {
float: left;
margin-right: 0.2em;
}
@@ -64,6 +64,15 @@
<% end %>
+
+
<% end %>
@@ -107,6 +116,12 @@
+
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 51cda13..dfff8ab 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -8,6 +8,8 @@ en:
one_line_title_format: "Paper Format Title"
download: Download
author_translation_name: Author translation name
+ authors_translation_name: Authors translation name
+ authors: Authors
personal_plugin_generate: Personal Plugin Generate
personal_plugin_name: Personal Plugin Name Translation
module_name: Module Key
diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml
index f3f95bb..1ee868c 100644
--- a/config/locales/zh_tw.yml
+++ b/config/locales/zh_tw.yml
@@ -8,6 +8,8 @@ zh_tw:
one_line_title_format: "論文格式標題"
download: 下載
author_translation_name: 著作人翻譯名稱
+ authors_translation_name: 全部作者翻譯名稱
+ authors: 全部作者
personal_plugin_generate: 個人外掛生成
personal_plugin_name: 個人外掛翻譯名稱
module_name: 模組Key
diff --git a/template_generator/app/helpers/admin/plugin_templates_helper.rb b/template_generator/app/helpers/admin/plugin_templates_helper.rb
index 281a1dd..b7a2e66 100644
--- a/template_generator/app/helpers/admin/plugin_templates_helper.rb
+++ b/template_generator/app/helpers/admin/plugin_templates_helper.rb
@@ -57,7 +57,7 @@ module Admin::PluginTemplatesHelper
end
def page_for_plugin_template(plugin_template_object)
page = Page.where(:module=>"personal_plugin_template").first
- ("/#{I18n.locale}"+page.url+'/'+plugin_template_object.to_param).gsub('//','/') rescue "#"
+ ("/#{I18n.locale}"+page.url+'/'+plugin_template_object.to_param).gsub('//','/') rescue "javascript:void(0)"
end
def get_data_for_excel(analysis_field_name_start,analysis_field_name_end,timezone)
diff --git a/template_generator/app/models/plugin_template.rb b/template_generator/app/models/plugin_template.rb
index 8d0b3e6..ecd7c88 100644
--- a/template_generator/app/models/plugin_template.rb
+++ b/template_generator/app/models/plugin_template.rb
@@ -66,7 +66,12 @@ class PluginTemplate
pd_title = []
fields_to_show.each do |t|
- if (self.fields[t].type.to_s == "String" || self.fields[t].type.to_s == "Object" rescue false)
+ if t == 'authors'
+ t_f = 'member_profile'
+ else
+ t_f = t
+ end
+ if (self.fields[t_f].type.to_s == "String" || self.fields[t_f].type.to_s == "Object" rescue false)
fields_to_remove << t if (datas.where(t.to_sym.ne => nil, t.to_sym.ne => "").count == 0 rescue false)
elsif (self.relations.include?(t.pluralize) rescue false)
fields_to_remove << t if (datas.where(t.pluralize.to_sym.ne=>[]).count == 0 rescue false)
diff --git a/template_generator/modules/personal_plugin_template/thumbs/thumb.png b/template_generator/modules/personal_plugin_template/thumbs/thumb.png
index 266af56..78158c4 100644
Binary files a/template_generator/modules/personal_plugin_template/thumbs/thumb.png and b/template_generator/modules/personal_plugin_template/thumbs/thumb.png differ