From 774a5ec062e2bad13c2bcbfa2c6d355283efbe24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B1=E5=8D=9A=E4=BA=9E?= Date: Mon, 22 Jan 2024 23:37:49 +0800 Subject: [PATCH] Add authors settings. --- .../personal_plugin_fields_controller.rb | 29 +++++++++++++++--- app/models/personal_plugin_field.rb | 2 ++ .../personal_plugin_fields/_form.html.erb | 17 +++++++++- config/locales/en.yml | 2 ++ config/locales/zh_tw.yml | 2 ++ .../helpers/admin/plugin_templates_helper.rb | 2 +- .../app/models/plugin_template.rb | 7 ++++- .../personal_plugin_template/thumbs/thumb.png | Bin 4075 -> 4074 bytes 8 files changed, 54 insertions(+), 7 deletions(-) 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"+ "
+ +
+ +
+ <%= f.fields_for :authors_name_translations do |f| %> + <%= f.text_field locale, class: "input-block-level", placeholder: t("personal_plugin_generator.authors_translation_name"), value: (@personal_plugin_field.authors_name_translations[locale] rescue nil) %> + <% 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 266af5606742714c262a949cd58aedc2b84b1959..78158c4d86fb8eb8fdff552e06693c09f06ff957 100644 GIT binary patch delta 13 UcmaDY|4N>vGr-S%BkMDM04FsCF#rGn delta 14 VcmaDQ|5~24Gr-TCcO%O)egG>01wH@(