Add authors settings.
This commit is contained in:
parent
05bbab70b8
commit
774a5ec062
|
@ -137,7 +137,16 @@ class Admin::PersonalPluginFieldsController < OrbitMemberController
|
||||||
begin
|
begin
|
||||||
in_use_locales = Site.first.in_use_locales
|
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 = @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 = Dir.glob("#{cp_template_dir_path}config/locales/*.yml")
|
||||||
yml_files.each do |yml_file|
|
yml_files.each do |yml_file|
|
||||||
locale = yml_file.split("/").last.split(".yml").first
|
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 = @personal_plugin_field.backend_fields["index"].to_a rescue []
|
||||||
backend_index_fields_contents = backend_index_fields.map do |field_name|
|
backend_index_fields_contents = backend_index_fields.map do |field_name|
|
||||||
if field_name == slug_title
|
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" +
|
||||||
" <div class=\"quick-edit\">\n"+
|
" <div class=\"quick-edit\">\n"+
|
||||||
" <ul class=\"nav nav-pills hide\">\n"+
|
" <ul class=\"nav nav-pills hide\">\n"+
|
||||||
" <li><%= link_to t('edit'), edit_admin_#{plugin_template}_path(#{plugin_template},:page => params[:page]) %></li>\n"+
|
" <li><%= link_to t('edit'), edit_admin_#{plugin_template}_path(#{plugin_template},:page => params[:page]) %></li>\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 = @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_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 []
|
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
|
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}\")"]
|
["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|
|
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]]]
|
[field_value[:field_name],datetime_field_types_hash[field_value[:field_type]]]
|
||||||
}.to_h
|
}.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 ? \"<a href='\#{OrbitHelper.url_to_plugin_show(member.to_param,'member')}' title='\#{member_name}'>\#{member_name}</a>\" : \"\")"]
|
||||||
|
end
|
||||||
value_case_codes = ["value = #{plugin_template}.send(field) rescue \"\"",
|
value_case_codes = ["value = #{plugin_template}.send(field) rescue \"\"",
|
||||||
"if field.include?(\".\")",
|
"if field.include?(\".\")",
|
||||||
"#{@blank_text}value = #{plugin_template}",
|
"#{@blank_text}value = #{plugin_template}",
|
||||||
|
@ -336,8 +358,7 @@ class Admin::PersonalPluginFieldsController < OrbitMemberController
|
||||||
"#{@blank_text}}",
|
"#{@blank_text}}",
|
||||||
"#{@blank_text}join_text = (text_only rescue false) ? \",\" : \"<br>\"",
|
"#{@blank_text}join_text = (text_only rescue false) ? \",\" : \"<br>\"",
|
||||||
"#{@blank_text}value = value.join(join_text)",
|
"#{@blank_text}value = value.join(join_text)",
|
||||||
"elsif field == \"member_profile\" || field == \"authors\"",
|
*authors_codes,
|
||||||
"#{@blank_text}value = get_authors_show(#{plugin_template})",
|
|
||||||
"end",
|
"end",
|
||||||
"strftime_hash = #{datetime_fields}",
|
"strftime_hash = #{datetime_fields}",
|
||||||
"if strftime_hash.keys.include?(field)",
|
"if strftime_hash.keys.include?(field)",
|
||||||
|
|
|
@ -5,7 +5,9 @@ class PersonalPluginField
|
||||||
include MemberHelper
|
include MemberHelper
|
||||||
field :one_line_title_format, :type => String, :default => ""
|
field :one_line_title_format, :type => String, :default => ""
|
||||||
field :enable_one_line_title, :type => Boolean, :default => false
|
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 :author_name, :type => String, :default => "",:localize => true
|
||||||
|
field :authors_name, :type => String, :default => "",:localize => true
|
||||||
field :title, :type => String, :default => "",:localize => true
|
field :title, :type => String, :default => "",:localize => true
|
||||||
field :module_name, :type => String, :default => ""
|
field :module_name, :type => String, :default => ""
|
||||||
field :primary_modal_name, :type => String, :default => ""
|
field :primary_modal_name, :type => String, :default => ""
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
.ui-helper-hidden-accessible{
|
.ui-helper-hidden-accessible{
|
||||||
display: none;
|
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;
|
float: left;
|
||||||
margin-right: 0.2em;
|
margin-right: 0.2em;
|
||||||
}
|
}
|
||||||
|
@ -64,6 +64,15 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<!-- authors_translation_name -->
|
||||||
|
<div class="control-group input-title">
|
||||||
|
<label class="control-label muted"><%= t("personal_plugin_generator.authors_translation_name") %></label>
|
||||||
|
<div class="controls">
|
||||||
|
<%= 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 %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
@ -107,6 +116,12 @@
|
||||||
<button type="button" class="btn btn-primary" id="add_related_modal"><%= t(:add) %></button>
|
<button type="button" class="btn btn-primary" id="add_related_modal"><%= t(:add) %></button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="control-group input-title">
|
||||||
|
<label class="control-label muted"><%= t("personal_plugin_generator.authors") %></label>
|
||||||
|
<div class="controls">
|
||||||
|
<label for="enable_authors"><%= f.check_box :enable_authors, :checked => (f.object.enable_authors), :class=>"toggle-check", :id=>"enable_authors", :data=> { disabled: true }, :style=> "float: left;" %><span style="float: left;"><%=thead_field_for_ppg("enable")%></span></label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label muted"><%=thead_field_for_ppg("one_line_title_format")%></label>
|
<label class="control-label muted"><%=thead_field_for_ppg("one_line_title_format")%></label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
|
|
|
@ -8,6 +8,8 @@ en:
|
||||||
one_line_title_format: "Paper Format Title"
|
one_line_title_format: "Paper Format Title"
|
||||||
download: Download
|
download: Download
|
||||||
author_translation_name: Author translation name
|
author_translation_name: Author translation name
|
||||||
|
authors_translation_name: Authors translation name
|
||||||
|
authors: Authors
|
||||||
personal_plugin_generate: Personal Plugin Generate
|
personal_plugin_generate: Personal Plugin Generate
|
||||||
personal_plugin_name: Personal Plugin Name Translation
|
personal_plugin_name: Personal Plugin Name Translation
|
||||||
module_name: Module Key
|
module_name: Module Key
|
||||||
|
|
|
@ -8,6 +8,8 @@ zh_tw:
|
||||||
one_line_title_format: "論文格式標題"
|
one_line_title_format: "論文格式標題"
|
||||||
download: 下載
|
download: 下載
|
||||||
author_translation_name: 著作人翻譯名稱
|
author_translation_name: 著作人翻譯名稱
|
||||||
|
authors_translation_name: 全部作者翻譯名稱
|
||||||
|
authors: 全部作者
|
||||||
personal_plugin_generate: 個人外掛生成
|
personal_plugin_generate: 個人外掛生成
|
||||||
personal_plugin_name: 個人外掛翻譯名稱
|
personal_plugin_name: 個人外掛翻譯名稱
|
||||||
module_name: 模組Key
|
module_name: 模組Key
|
||||||
|
|
|
@ -57,7 +57,7 @@ module Admin::PluginTemplatesHelper
|
||||||
end
|
end
|
||||||
def page_for_plugin_template(plugin_template_object)
|
def page_for_plugin_template(plugin_template_object)
|
||||||
page = Page.where(:module=>"personal_plugin_template").first
|
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
|
end
|
||||||
|
|
||||||
def get_data_for_excel(analysis_field_name_start,analysis_field_name_end,timezone)
|
def get_data_for_excel(analysis_field_name_start,analysis_field_name_end,timezone)
|
||||||
|
|
|
@ -66,7 +66,12 @@ class PluginTemplate
|
||||||
pd_title = []
|
pd_title = []
|
||||||
|
|
||||||
fields_to_show.each do |t|
|
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)
|
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)
|
elsif (self.relations.include?(t.pluralize) rescue false)
|
||||||
fields_to_remove << t if (datas.where(t.pluralize.to_sym.ne=>[]).count == 0 rescue false)
|
fields_to_remove << t if (datas.where(t.pluralize.to_sym.ne=>[]).count == 0 rescue false)
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 4.0 KiB |
Loading…
Reference in New Issue