Add fields display setting for member page.
This commit is contained in:
parent
82584741ba
commit
0d10389597
|
@ -8,6 +8,12 @@ class Admin::WritingConferencesController < OrbitMemberController
|
||||||
|
|
||||||
before_action :need_access_right
|
before_action :need_access_right
|
||||||
before_action :allow_admin_only, :only => [:index, :setting]
|
before_action :allow_admin_only, :only => [:index, :setting]
|
||||||
|
def update_setting
|
||||||
|
setting_params = params.require(:writing_conference_setting).permit!
|
||||||
|
setting_params[:display_fields_in_member_page] = [] if setting_params[:display_fields_in_member_page].nil?
|
||||||
|
WritingConferenceSetting.update_all(setting_params)
|
||||||
|
redirect_to admin_writing_conference_setting_path
|
||||||
|
end
|
||||||
def merge_process
|
def merge_process
|
||||||
params['writing_conference_id'].each do |writing_conference_id|
|
params['writing_conference_id'].each do |writing_conference_id|
|
||||||
writing_conference_ids = writing_conference_id.split('/')
|
writing_conference_ids = writing_conference_id.split('/')
|
||||||
|
|
|
@ -76,6 +76,7 @@ class WritingConference
|
||||||
|
|
||||||
|
|
||||||
def self.get_plugin_datas_to_member(datas)
|
def self.get_plugin_datas_to_member(datas)
|
||||||
|
get_setting
|
||||||
page = Page.where(:module => "personal_conference").first rescue nil
|
page = Page.where(:module => "personal_conference").first rescue nil
|
||||||
if !page.nil? && page.custom_string_field == "table"
|
if !page.nil? && page.custom_string_field == "table"
|
||||||
if !page.custom_array_field.blank?
|
if !page.custom_array_field.blank?
|
||||||
|
@ -91,12 +92,9 @@ class WritingConference
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
fields_to_show = [
|
fields_to_show = @setting.display_fields_in_member_page.clone
|
||||||
"year",
|
fields_to_show << "paper_title"
|
||||||
"paper_title"
|
|
||||||
]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
fields_to_remove = []
|
fields_to_remove = []
|
||||||
|
|
||||||
pd_title = []
|
pd_title = []
|
||||||
|
@ -138,6 +136,8 @@ class WritingConference
|
||||||
pd_data << {"data_title" => p.duration}
|
pd_data << {"data_title" => p.duration}
|
||||||
when "url"
|
when "url"
|
||||||
pd_data << { "data_title" => "<a href='#{p.url}' title=\"#{p.url}\" target='_blank'>#{p.url}</a>" }
|
pd_data << { "data_title" => "<a href='#{p.url}' title=\"#{p.url}\" target='_blank'>#{p.url}</a>" }
|
||||||
|
when "publication_date"
|
||||||
|
pd_data << { "data_title" => (p.publication_date.strftime(@setting.publication_date_format) rescue "") }
|
||||||
else
|
else
|
||||||
pd_data << { "data_title" => p.send(t) }
|
pd_data << { "data_title" => p.send(t) }
|
||||||
end
|
end
|
||||||
|
@ -146,6 +146,8 @@ class WritingConference
|
||||||
link = OrbitHelper.url_to_plugin_show(p.to_param,'personal_conference')
|
link = OrbitHelper.url_to_plugin_show(p.to_param,'personal_conference')
|
||||||
link = (link == "#" ? p.create_link : "<a href='#{link}' title=\"#{p.create_link}\" target='_blank'>#{p.create_link}</a>")
|
link = (link == "#" ? p.create_link : "<a href='#{link}' title=\"#{p.create_link}\" target='_blank'>#{p.create_link}</a>")
|
||||||
pd_data << { "data_title" => link }
|
pd_data << { "data_title" => link }
|
||||||
|
elsif t == "publication_date"
|
||||||
|
pd_data << { "data_title" => (p.publication_date.strftime(@setting.publication_date_format) rescue "") }
|
||||||
else
|
else
|
||||||
pd_data << { "data_title" => p.send(t) }
|
pd_data << { "data_title" => p.send(t) }
|
||||||
end
|
end
|
||||||
|
@ -187,7 +189,8 @@ class WritingConference
|
||||||
end
|
end
|
||||||
value = value.join(" / ")
|
value = value.join(" / ")
|
||||||
when "publication_date"
|
when "publication_date"
|
||||||
value = self.publication_date.strftime("%Y-%m-%d") rescue ""
|
get_setting
|
||||||
|
value = self.publication_date.strftime(@setting.publication_date_format) rescue ""
|
||||||
when "abstract"
|
when "abstract"
|
||||||
value = nl2br(self.abstract)
|
value = nl2br(self.abstract)
|
||||||
when "language"
|
when "language"
|
||||||
|
@ -218,7 +221,12 @@ class WritingConference
|
||||||
"value"=>value
|
"value"=>value
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
def get_setting
|
||||||
|
@setting ||= WritingConferenceSetting.first
|
||||||
|
end
|
||||||
|
def self.get_setting
|
||||||
|
@setting ||= WritingConferenceSetting.first
|
||||||
|
end
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def add_http
|
def add_http
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
class WritingConferenceSetting
|
||||||
|
include Mongoid::Document
|
||||||
|
include Mongoid::Timestamps
|
||||||
|
Fields_names = ["year","publication_date"]
|
||||||
|
field :display_fields_in_member_page, :type => Array, :default => ["year"]
|
||||||
|
field :publication_date_format, :type => String, :default => "%Y-%m-%d"
|
||||||
|
end
|
|
@ -1,3 +1,4 @@
|
||||||
|
<% OrbitHelper.set_site_locale(I18n.locale) %>
|
||||||
<% @writing_conferences.each do |writing_conference| %>
|
<% @writing_conferences.each do |writing_conference| %>
|
||||||
<tr id="<%= dom_id writing_conference %>" class="<%= writing_conference.is_hidden ? "checkHide" : "" %>">
|
<tr id="<%= dom_id writing_conference %>" class="<%= writing_conference.is_hidden ? "checkHide" : "" %>">
|
||||||
<td><%= writing_conference.year %></td>
|
<td><%= writing_conference.year %></td>
|
||||||
|
|
|
@ -15,6 +15,10 @@
|
||||||
.totle span{
|
.totle span{
|
||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
}
|
}
|
||||||
|
#conference_setting input[type="checkbox"]{
|
||||||
|
margin-top: 0;
|
||||||
|
margin-right: 0.3em;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
@ -98,6 +102,36 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="element span4">
|
||||||
|
<div class="detail w-a h-a">
|
||||||
|
<p class="totle">
|
||||||
|
<a class="btn btn-small btn-primary pull-right" href="<%= new_admin_conference_author_type_path %>#author_type_modal" data-toggle="modal" data-remote="true"><i class="icon-plus"></i> <%= t('add')%></a>
|
||||||
|
<span><%= t("personal_conference.page_settings") %></span>
|
||||||
|
</p>
|
||||||
|
<div class="detal-list my_scroll">
|
||||||
|
<% @setting = WritingConferenceSetting.first%>
|
||||||
|
<% @setting = WritingConferenceSetting.create if @setting.nil? %>
|
||||||
|
<%= form_for @setting, url: admin_writing_conference_update_setting_path, html: {id: 'conference_setting'} do |f| %>
|
||||||
|
<div class="control-group">
|
||||||
|
<div class="control-label"><%= t("personal_conference.display_fields_in_member_page") %>:</div>
|
||||||
|
<div class="controls">
|
||||||
|
<% WritingConferenceSetting::Fields_names.each do |f| %>
|
||||||
|
<label><input type="checkbox" name="writing_conference_setting[display_fields_in_member_page][]" value="<%=f%>" <%=@setting.display_fields_in_member_page.include?(f) ? "checked=\"checked\"" : "" %> /><%=t("personal_conference.#{f}")%></label>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="control-group">
|
||||||
|
<label class="control-label" for="publication_date_format"><%= t("personal_conference.publication_date_format") %>:</label>
|
||||||
|
<div class="controls">
|
||||||
|
<input type="text" name="writing_conference_setting[publication_date_format]" value="<%=@setting.publication_date_format%>" placeholder="%Y-%m-%d" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div><%= f.submit "Save", :class=>"btn btn-primary btn-small" %></div>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="paper_type_qe">
|
<div id="paper_type_qe">
|
||||||
|
|
|
@ -4,6 +4,9 @@ en:
|
||||||
personal_conference: Conference Paper
|
personal_conference: Conference Paper
|
||||||
|
|
||||||
personal_conference:
|
personal_conference:
|
||||||
|
publication_date_format: "Publication date format"
|
||||||
|
page_settings: "Page settings"
|
||||||
|
display_fields_in_member_page: "Display fields in member page"
|
||||||
merge: Merge
|
merge: Merge
|
||||||
upload: Upload
|
upload: Upload
|
||||||
no_input: No Input
|
no_input: No Input
|
||||||
|
|
|
@ -3,6 +3,9 @@ zh_tw:
|
||||||
module_name:
|
module_name:
|
||||||
personal_conference: 研討會論文
|
personal_conference: 研討會論文
|
||||||
personal_conference:
|
personal_conference:
|
||||||
|
publication_date_format: "發表日期顯示格式"
|
||||||
|
page_settings: "頁面設定"
|
||||||
|
display_fields_in_member_page: "在會員頁面顯示欄位"
|
||||||
merge: "合併"
|
merge: "合併"
|
||||||
upload: "上傳"
|
upload: "上傳"
|
||||||
no_input: "未輸入"
|
no_input: "未輸入"
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
Rails.application.routes.draw do
|
Rails.application.routes.draw do
|
||||||
locales = Site.find_by(site_active: true).in_use_locales rescue I18n.available_locales
|
locales = Site.find_by(site_active: true).in_use_locales rescue I18n.available_locales
|
||||||
|
WritingConferenceSetting.create if WritingConferenceSetting.count == 0
|
||||||
scope "(:locale)", locale: Regexp.new(locales.join("|")) do
|
scope "(:locale)", locale: Regexp.new(locales.join("|")) do
|
||||||
namespace :admin do
|
namespace :admin do
|
||||||
|
post 'writing_conference_update_setting' => "writing_conferences#update_setting"
|
||||||
|
patch 'writing_conference_update_setting' => "writing_conferences#update_setting"
|
||||||
get 'writing_conference_setting' => "writing_conferences#setting"
|
get 'writing_conference_setting' => "writing_conferences#setting"
|
||||||
get 'writing_conferences/download_excel_format' => 'writing_conferences#excel_format'
|
get 'writing_conferences/download_excel_format' => 'writing_conferences#excel_format'
|
||||||
post 'writing_conferences/import_from_excel' => 'writing_conferences#import_from_excel'
|
post 'writing_conferences/import_from_excel' => 'writing_conferences#import_from_excel'
|
||||||
|
|
Loading…
Reference in New Issue