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 :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
|
||||
params['writing_conference_id'].each do |writing_conference_id|
|
||||
writing_conference_ids = writing_conference_id.split('/')
|
||||
|
|
|
@ -76,6 +76,7 @@ class WritingConference
|
|||
|
||||
|
||||
def self.get_plugin_datas_to_member(datas)
|
||||
get_setting
|
||||
page = Page.where(:module => "personal_conference").first rescue nil
|
||||
if !page.nil? && page.custom_string_field == "table"
|
||||
if !page.custom_array_field.blank?
|
||||
|
@ -91,13 +92,10 @@ class WritingConference
|
|||
]
|
||||
end
|
||||
else
|
||||
fields_to_show = [
|
||||
"year",
|
||||
"paper_title"
|
||||
]
|
||||
fields_to_show = @setting.display_fields_in_member_page.clone
|
||||
fields_to_show << "paper_title"
|
||||
end
|
||||
|
||||
fields_to_remove = []
|
||||
fields_to_remove = []
|
||||
|
||||
pd_title = []
|
||||
|
||||
|
@ -138,6 +136,8 @@ class WritingConference
|
|||
pd_data << {"data_title" => p.duration}
|
||||
when "url"
|
||||
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
|
||||
pd_data << { "data_title" => p.send(t) }
|
||||
end
|
||||
|
@ -146,6 +146,8 @@ class WritingConference
|
|||
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>")
|
||||
pd_data << { "data_title" => link }
|
||||
elsif t == "publication_date"
|
||||
pd_data << { "data_title" => (p.publication_date.strftime(@setting.publication_date_format) rescue "") }
|
||||
else
|
||||
pd_data << { "data_title" => p.send(t) }
|
||||
end
|
||||
|
@ -187,7 +189,8 @@ class WritingConference
|
|||
end
|
||||
value = value.join(" / ")
|
||||
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"
|
||||
value = nl2br(self.abstract)
|
||||
when "language"
|
||||
|
@ -218,7 +221,12 @@ class WritingConference
|
|||
"value"=>value
|
||||
}
|
||||
end
|
||||
|
||||
def get_setting
|
||||
@setting ||= WritingConferenceSetting.first
|
||||
end
|
||||
def self.get_setting
|
||||
@setting ||= WritingConferenceSetting.first
|
||||
end
|
||||
protected
|
||||
|
||||
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| %>
|
||||
<tr id="<%= dom_id writing_conference %>" class="<%= writing_conference.is_hidden ? "checkHide" : "" %>">
|
||||
<td><%= writing_conference.year %></td>
|
||||
|
|
|
@ -15,6 +15,10 @@
|
|||
.totle span{
|
||||
font-size: 18px;
|
||||
}
|
||||
#conference_setting input[type="checkbox"]{
|
||||
margin-top: 0;
|
||||
margin-right: 0.3em;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="row">
|
||||
|
@ -98,6 +102,36 @@
|
|||
</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 id="paper_type_qe">
|
||||
|
|
|
@ -4,6 +4,9 @@ en:
|
|||
personal_conference: Conference Paper
|
||||
|
||||
personal_conference:
|
||||
publication_date_format: "Publication date format"
|
||||
page_settings: "Page settings"
|
||||
display_fields_in_member_page: "Display fields in member page"
|
||||
merge: Merge
|
||||
upload: Upload
|
||||
no_input: No Input
|
||||
|
|
|
@ -3,6 +3,9 @@ zh_tw:
|
|||
module_name:
|
||||
personal_conference: 研討會論文
|
||||
personal_conference:
|
||||
publication_date_format: "發表日期顯示格式"
|
||||
page_settings: "頁面設定"
|
||||
display_fields_in_member_page: "在會員頁面顯示欄位"
|
||||
merge: "合併"
|
||||
upload: "上傳"
|
||||
no_input: "未輸入"
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
Rails.application.routes.draw do
|
||||
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
|
||||
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_conferences/download_excel_format' => 'writing_conferences#excel_format'
|
||||
post 'writing_conferences/import_from_excel' => 'writing_conferences#import_from_excel'
|
||||
|
|
Loading…
Reference in New Issue