update
This commit is contained in:
parent
efbf71a7c7
commit
b65696fea6
|
@ -22,6 +22,9 @@
|
||||||
<a href="#sidebar-nav" data-toggle="tab"><%= t('preferences.sidebar_nav') %></a>
|
<a href="#sidebar-nav" data-toggle="tab"><%= t('preferences.sidebar_nav') %></a>
|
||||||
</li>
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<li>
|
||||||
|
<a href="#page_set" data-toggle="tab"><%= t('preferences.page_set') %></a>
|
||||||
|
</li>
|
||||||
<li class="active">
|
<li class="active">
|
||||||
<a href="#system-email" data-toggle="tab"><%= t('preferences.system_email') %></a>
|
<a href="#system-email" data-toggle="tab"><%= t('preferences.system_email') %></a>
|
||||||
</li>
|
</li>
|
||||||
|
@ -58,7 +61,12 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<!-- Page set -->
|
||||||
|
<div id="page_set" class="tab-pane fade">
|
||||||
|
<%= f.fields_for :page_sets do |page_set| %>
|
||||||
|
<%= page_set.check_box :auto_convert_flag %> <%= t('preferences.auto_convert_flag') %>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
<!-- System Email -->
|
<!-- System Email -->
|
||||||
<%= f.fields_for :site_settings, @site['site_settings'] do |f| %>
|
<%= f.fields_for :site_settings, @site['site_settings'] do |f| %>
|
||||||
|
|
||||||
|
@ -273,6 +281,46 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="control-group">
|
||||||
|
<label class="control-label muted"><%= t('preferences.orbit_bar_background_color') %></label>
|
||||||
|
<div class="controls">
|
||||||
|
<%= f.text_field :orbit_bar_background_color, :class=>'set_color',:type=>'color',:value=>@site.orbit_bar_background_color%>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="control-group">
|
||||||
|
<label class="control-label muted"><%= t('preferences.orbit_bar_text_color') %></label>
|
||||||
|
<div class="controls">
|
||||||
|
<%= f.text_field :orbit_bar_text_color, :class=>'set_color',:type=>'color',:value=>@site.orbit_bar_text_color%>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="control-group">
|
||||||
|
<label class="control-label muted"><%= t('preferences.orbit_bar_submenu_background_color') %></label>
|
||||||
|
<div class="controls">
|
||||||
|
<%= f.text_field :orbit_bar_submenu_background_color, :class=>'set_color',:type=>'color',:value=>@site.orbit_bar_submenu_background_color%>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="control-group">
|
||||||
|
<label class="control-label muted"><%= t('preferences.orbit_bar_submenu_text_color') %></label>
|
||||||
|
<div class="controls">
|
||||||
|
<%= f.text_field :orbit_bar_submenu_text_color, :class=>'set_color',:type=>'color',:value=>@site.orbit_bar_submenu_text_color%>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="control-group">
|
||||||
|
<label class="control-label muted"><%= t('preferences.is_hidden_orbit_bar') %></label>
|
||||||
|
<div class="controls">
|
||||||
|
<%if @site.is_hidden_orbit_bar%>
|
||||||
|
<%= f.check_box :is_hidden_orbit_bar ,:checked=>'checked'%>
|
||||||
|
<%else%>
|
||||||
|
<%= f.check_box :is_hidden_orbit_bar ,:checked=>false%>
|
||||||
|
<%end%>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="control-group">
|
||||||
|
<label class="control-label muted"><%= t('preferences.orbit_bar_animation_time') %></label>
|
||||||
|
<div class="controls">
|
||||||
|
<%= f.text_field :orbit_bar_animation_time ,:value=>@site.orbit_bar_animation_time %>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label muted">Orbit <%= t('preferences.site_logo') %>(second image or the only one image)</label>
|
<label class="control-label muted">Orbit <%= t('preferences.site_logo') %>(second image or the only one image)</label>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
class MembersController < ApplicationController
|
class MembersController < ApplicationController
|
||||||
helper_method :current_user
|
helper_method :current_user
|
||||||
|
include AttributeValuesHelper
|
||||||
def index
|
def index
|
||||||
page_roles = OrbitHelper.page_categories
|
page_roles = OrbitHelper.page_categories
|
||||||
page_role_status = OrbitHelper.page_role_status
|
page_role_status = OrbitHelper.page_role_status
|
||||||
|
@ -15,22 +16,8 @@ class MembersController < ApplicationController
|
||||||
member_sort_position = OrbitHelper.member_sort_position
|
member_sort_position = OrbitHelper.member_sort_position
|
||||||
sort = nil
|
sort = nil
|
||||||
if !member_sort_position
|
if !member_sort_position
|
||||||
# sort = "data['list_order']"
|
sort_select = fields_to_show.to_enum.with_index.select{|v| v[0]['key']=='name'}
|
||||||
# else
|
sort = sort_select.blank? ? nil : sort_select[0][1]
|
||||||
# sort = fields_to_show
|
|
||||||
# .collect.with_index{|field,idx| {'sort_order'=>field['sort_order'], 'index'=>idx}}
|
|
||||||
# .select{|field|!field['sort_order'].blank?}
|
|
||||||
# .sort_by{|field|field['sort_order']}
|
|
||||||
# .collect.with_index{|field| "data['profile_data'][#{field['index']}]['sort_value'] rescue 0"}
|
|
||||||
# # sort = "[(data['first_name'][0])]"
|
|
||||||
|
|
||||||
# sort = '[('+sort.join('),(')+')]'
|
|
||||||
fields_to_show.each_with_index do |field, idx|
|
|
||||||
if field["key"] == "name"
|
|
||||||
# sort = "[(data['profile_data'][idx]['sort_value'] rescue 0)]"
|
|
||||||
sort = idx
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
if page_roles.include?("all")
|
if page_roles.include?("all")
|
||||||
roles = Role.all.asc(:key).collect do |role|
|
roles = Role.all.asc(:key).collect do |role|
|
||||||
|
@ -38,7 +25,7 @@ class MembersController < ApplicationController
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
page_role_status.each do |status_id|
|
page_role_status.each do |status_id|
|
||||||
page_roles << RoleStatus.find(status_id).role.id.to_s
|
page_roles << (RoleStatus.find(status_id).role.id.to_s rescue '')
|
||||||
end
|
end
|
||||||
roles = Role.where(:id.in => page_roles.uniq).asc(:key).collect do |role|
|
roles = Role.where(:id.in => page_roles.uniq).asc(:key).collect do |role|
|
||||||
{ "title" => role.title, "id" => role.id, "status" => RoleStatus.where(:role_id=>role, :_id.in=>page_role_status).asc(:key).to_a }
|
{ "title" => role.title, "id" => role.id, "status" => RoleStatus.where(:role_id=>role, :_id.in=>page_role_status).asc(:key).to_a }
|
||||||
|
@ -134,7 +121,7 @@ class MembersController < ApplicationController
|
||||||
def get_member_data(member, fields_to_show)
|
def get_member_data(member, fields_to_show)
|
||||||
image = member.avatar.present? ? member.avatar.thumb.url : ActionController::Base.helpers.asset_path('member-pic.png')
|
image = member.avatar.present? ? member.avatar.thumb.url : ActionController::Base.helpers.asset_path('member-pic.png')
|
||||||
member_data_return = member_data(member, fields_to_show)
|
member_data_return = member_data(member, fields_to_show)
|
||||||
if !member_data_return.nil? && (!member_data_return.empty? rescue false)
|
if !member_data_return.blank?
|
||||||
{
|
{
|
||||||
'profile_data'=> member_data_return,
|
'profile_data'=> member_data_return,
|
||||||
'list_order' => member.position,
|
'list_order' => member.position,
|
||||||
|
@ -149,7 +136,7 @@ class MembersController < ApplicationController
|
||||||
|
|
||||||
def show
|
def show
|
||||||
params = OrbitHelper.params
|
params = OrbitHelper.params
|
||||||
member = MemberProfile.find_by(uid: params[:uid])
|
member = MemberProfile.find_by(uid: params[:uid]) rescue nil
|
||||||
page = Page.where(:page_id => params[:page_id]).first rescue nil
|
page = Page.where(:page_id => params[:page_id]).first rescue nil
|
||||||
|
|
||||||
profile_data = []
|
profile_data = []
|
||||||
|
@ -162,8 +149,10 @@ class MembersController < ApplicationController
|
||||||
role_status = member.role_statuses.where(role_id: role.id).map{|t|t.title.to_s}.join(',') rescue ''
|
role_status = member.role_statuses.where(role_id: role.id).map{|t|t.title.to_s}.join(',') rescue ''
|
||||||
profile_data = profile_data.push({"key"=>"role_status", "title"=>"", "value"=> role_status, "title_class"=>"member-data-title-role-status", "value_class"=>"member-data-value-role-status"}) if !role_status.blank?
|
profile_data = profile_data.push({"key"=>"role_status", "title"=>"", "value"=> role_status, "title_class"=>"member-data-title-role-status", "value_class"=>"member-data-value-role-status"}) if !role_status.blank?
|
||||||
if fields_to_show.blank?
|
if fields_to_show.blank?
|
||||||
attribute_field = role.attribute_fields.where(:key => 'job_title').first
|
attribute_field = role.attribute_fields.first
|
||||||
profile_data = profile_data + member_data(member, [{"id"=> attribute_field.id.to_s, "key"=> attribute_field.key, "type"=>"role"}]) if !attribute_field.blank? and !attribute_field.to_show.blank?
|
if !attribute_field.blank? && !attribute_field.to_show.blank?
|
||||||
|
profile_data = profile_data + member_data(member, [{"id"=> attribute_field.id.to_s, "key"=> attribute_field.key.to_s, "type"=>"role"}])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if fields_to_show.blank?
|
if fields_to_show.blank?
|
||||||
|
@ -190,7 +179,7 @@ class MembersController < ApplicationController
|
||||||
role_fields_to_show = []
|
role_fields_to_show = []
|
||||||
member.roles.where(:disabled => false).asc("_id").collect do |role|
|
member.roles.where(:disabled => false).asc("_id").collect do |role|
|
||||||
role.attribute_fields.where(:key.ne => 'job_title').asc("_id").each do |attribute_field|
|
role.attribute_fields.where(:key.ne => 'job_title').asc("_id").each do |attribute_field|
|
||||||
role_fields_to_show << {"id"=> attribute_field.id.to_s, "key"=> attribute_field.key, "type"=>"role"} if !attribute_field.to_show.blank?
|
role_fields_to_show << {"id"=> attribute_field.id.to_s,"key"=> attribute_field.key.to_s, "type"=>"role"} if !attribute_field.to_show.blank?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
profile_data = profile_data + member_data(member, role_fields_to_show)
|
profile_data = profile_data + member_data(member, role_fields_to_show)
|
||||||
|
@ -357,7 +346,7 @@ class MembersController < ApplicationController
|
||||||
if field['type'] != 'role'
|
if field['type'] != 'role'
|
||||||
privacy_approved_status = true #Todo: set not role field's default privacy_approved_status
|
privacy_approved_status = true #Todo: set not role field's default privacy_approved_status
|
||||||
else
|
else
|
||||||
case AttributeField.find(field["id"]).privacy_default
|
case (AttributeField.find(field["id"]).privacy_default rescue nil)
|
||||||
when 'public'
|
when 'public'
|
||||||
privacy_approved_status = true
|
privacy_approved_status = true
|
||||||
when 'logged_in'
|
when 'logged_in'
|
||||||
|
@ -381,60 +370,53 @@ class MembersController < ApplicationController
|
||||||
field_data = member.member_profile_field_values.find_by(:key=>field['key']).get_field_value rescue {"value" => " "}
|
field_data = member.member_profile_field_values.find_by(:key=>field['key']).get_field_value rescue {"value" => " "}
|
||||||
end
|
end
|
||||||
when 'role'
|
when 'role'
|
||||||
if !field['id'].blank?
|
av = member.attribute_values.find_by(:attribute_field_id=>field['id']) rescue nil #some role's key has been changed to sort number,so it doesn't work when searching field from using its key
|
||||||
next if !privacy_approved_status
|
|
||||||
av = member.attribute_values.find_by(:attribute_field_id=>field['id'],:key=>field['key']) rescue nil
|
|
||||||
av = member.attribute_values.find_by(:attribute_field_id=>field['id']) rescue nil if av.nil? #some role's key has been changed to sort number,so it doesn't work when searching field from using its key
|
|
||||||
field_data = {"value" => " "}
|
field_data = {"value" => " "}
|
||||||
if !av.nil?
|
if !av.nil?
|
||||||
|
next if !privacy_approved_status
|
||||||
r = av.attribute_field.role rescue nil
|
r = av.attribute_field.role rescue nil
|
||||||
if !r.nil?
|
if !r.nil?
|
||||||
if member.roles.include?(r)
|
if member.roles.include?(r)
|
||||||
field_data = av.get_field_value rescue {"value" => " "}
|
field_data = av.get_field_value(member) rescue {"value" => " "}
|
||||||
else
|
end
|
||||||
field_data = {"value" => " "}
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
field_data = {"value" => " "}
|
avs = member.attribute_values.find_by(:key=>field['key']) rescue []
|
||||||
end
|
|
||||||
else
|
|
||||||
field_data = {"value" => " "}
|
|
||||||
end
|
|
||||||
else
|
|
||||||
avs = member.attribute_values.where(:key=>field['key']) rescue nil
|
|
||||||
field_data = {"value" => " "}
|
|
||||||
avs.each do |av|
|
avs.each do |av|
|
||||||
if !av.nil?
|
if !av.nil?
|
||||||
r = av.attribute_field.role rescue nil
|
r = av.attribute_field.role rescue nil
|
||||||
if !r.nil?
|
if !r.nil? && member.roles.include?(r)
|
||||||
if member.roles.include?(r)
|
field_data = av.get_field_value(member) rescue {"value" => " "}
|
||||||
field_data = av.get_field_value rescue {"value" => " "}
|
|
||||||
break
|
break
|
||||||
else
|
|
||||||
field_data = {"value" => " "}
|
|
||||||
end
|
end
|
||||||
else
|
|
||||||
field_data = {"value" => " "}
|
|
||||||
end
|
end
|
||||||
else
|
end
|
||||||
field_data = {"value" => " "}
|
if avs.blank? && !field['id'].nil?
|
||||||
|
attr_field = AttributeField.find(field['id']) rescue nil
|
||||||
|
if !attr_field.blank? && attr_field.markup.eql?("member_relationship")
|
||||||
|
field_data = {
|
||||||
|
"key" => attr_field.key,
|
||||||
|
"title" => attr_field.title,
|
||||||
|
"value" => get_member_show(attr_field.get_member_relationship(member.id.to_s))
|
||||||
|
}
|
||||||
|
if field_data['value'].blank?
|
||||||
|
field_data['value'] = ' '
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
next if field_data.blank? or field_data['value'].blank? or (OrbitHelper.params[:target_action] == "show" && field_data['value'] == " ")
|
end
|
||||||
|
next if field_data.blank? || field_data['value'].blank? || (OrbitHelper.params[:target_action] == "show" && field_data['value'] == " ")
|
||||||
|
|
||||||
if field['sort_order']
|
if field['sort_order']
|
||||||
field_data['sort_value'] = field_data['val'].blank? ? field_data['value'] : field_data['val']
|
field_data['sort_value'] = field_data['val'].blank? ? field_data['value'] : field_data['val']
|
||||||
if !field_data['sort_value'].is_a?(Hash)
|
if !field_data['sort_value'].is_a?(Hash)
|
||||||
if field_data['sort_value'].is_a?(Integer) || (field_data['sort_value'].is_i? rescue false)
|
if field_data['sort_value'].is_a?(Integer) || (field_data['sort_value'].is_i? rescue false)
|
||||||
field_data['sort_value'] = field_data['sort_value'].to_i rescue field_data['sort_value']
|
field_data['sort_value'] = field_data['sort_value'].to_i rescue field_data['sort_value']
|
||||||
else
|
elsif I18n.locale == :zh_tw
|
||||||
if I18n.locale == :zh_tw
|
|
||||||
field_data['sort_value'] = field_data['sort_value'].strip.encode("Big5") rescue "簡".encode("Big5")
|
field_data['sort_value'] = field_data['sort_value'].strip.encode("Big5") rescue "簡".encode("Big5")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
end
|
||||||
@current_field_value = field_data['value']
|
@current_field_value = field_data['value']
|
||||||
if (@current_field_value.gsub(' ','').strip rescue nil) == ""
|
if (@current_field_value.gsub(' ','').strip rescue nil) == ""
|
||||||
|
@ -465,8 +447,8 @@ class MembersController < ApplicationController
|
||||||
field_data['value'] = (field_data['value'].length > field['max_length']) ? field_data['value'][0..field['max_length']]+'...' : field_data['value']
|
field_data['value'] = (field_data['value'].length > field['max_length']) ? field_data['value'][0..field['max_length']]+'...' : field_data['value']
|
||||||
end
|
end
|
||||||
|
|
||||||
field_data['title_class'] = "member-data-title-"+field['key'].underscore.gsub('_','-')
|
field_data['title_class'] = "member-data-title-"+field['key'].to_s.underscore.gsub('_','-')
|
||||||
field_data['value_class'] = "member-data-value-"+field['key'].underscore.gsub('_','-')
|
field_data['value_class'] = "member-data-value-"+field['key'].to_s.underscore.gsub('_','-')
|
||||||
if !field_data['title'].blank? && !field_data['value'].blank?
|
if !field_data['title'].blank? && !field_data['value'].blank?
|
||||||
profile_data.push(field_data)
|
profile_data.push(field_data)
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
class PageSet
|
||||||
|
include Mongoid::Document
|
||||||
|
include Mongoid::Timestamps
|
||||||
|
belongs_to :site
|
||||||
|
field :auto_convert_flag, type: Boolean, :default => false
|
||||||
|
end
|
|
@ -4,7 +4,8 @@ class Site
|
||||||
include Slug
|
include Slug
|
||||||
|
|
||||||
DEBUG = false
|
DEBUG = false
|
||||||
|
has_many :page_sets, :autosave => true, :dependent => :destroy
|
||||||
|
accepts_nested_attributes_for :page_sets, :allow_destroy => true
|
||||||
field :title, as: :slug_title, type: String, localize: true
|
field :title, as: :slug_title, type: String, localize: true
|
||||||
field :school, type: String
|
field :school, type: String
|
||||||
field :department, type: String
|
field :department, type: String
|
||||||
|
@ -59,12 +60,45 @@ class Site
|
||||||
field :home_link_1, :type => String, :default=>"/"
|
field :home_link_1, :type => String, :default=>"/"
|
||||||
field :site_title, :type => Hash, :default=>{:zh_tw=>"主頁",:en=>"home_page"}
|
field :site_title, :type => Hash, :default=>{:zh_tw=>"主頁",:en=>"home_page"}
|
||||||
field :site_title_1, :type => Hash, :default=>{:zh_tw=>"主頁",:en=>"home_page"}
|
field :site_title_1, :type => Hash, :default=>{:zh_tw=>"主頁",:en=>"home_page"}
|
||||||
|
field :is_hidden_orbit_bar , type: Boolean, :default => false
|
||||||
|
field :orbit_bar_background_color , type: String, :default => ""
|
||||||
|
field :orbit_bar_text_color , type: String, :default => ""
|
||||||
|
field :orbit_bar_submenu_background_color , type: String, :default => ""
|
||||||
|
field :orbit_bar_submenu_text_color , type: String, :default => ""
|
||||||
|
field :orbit_bar_animation_time , type: String, :default => "0.3s"
|
||||||
mount_uploader :default_image, ImageUploader
|
mount_uploader :default_image, ImageUploader
|
||||||
mount_uploader :site_logo, ImageUploader
|
mount_uploader :site_logo, ImageUploader
|
||||||
mount_uploader :site_logo_1, ImageUploader
|
mount_uploader :site_logo_1, ImageUploader
|
||||||
mount_uploader :favicon, ImageUploader
|
mount_uploader :favicon, ImageUploader
|
||||||
mount_uploader :mobile_icon, ImageUploader
|
mount_uploader :mobile_icon, ImageUploader
|
||||||
|
after_initialize do
|
||||||
|
if !self.new_record?
|
||||||
|
if self.is_hidden_orbit_bar.nil?
|
||||||
|
self.is_hidden_orbit_bar = false
|
||||||
|
self.save
|
||||||
|
end
|
||||||
|
if self.orbit_bar_background_color.nil?
|
||||||
|
self.orbit_bar_background_color = ""
|
||||||
|
self.save
|
||||||
|
end
|
||||||
|
if self.orbit_bar_text_color.nil?
|
||||||
|
self.orbit_bar_text_color = ""
|
||||||
|
self.save
|
||||||
|
end
|
||||||
|
if self.orbit_bar_submenu_background_color.nil?
|
||||||
|
self.orbit_bar_submenu_background_color = ""
|
||||||
|
self.save
|
||||||
|
end
|
||||||
|
if self.orbit_bar_submenu_text_color.nil?
|
||||||
|
self.orbit_bar_submenu_text_color = ""
|
||||||
|
self.save
|
||||||
|
end
|
||||||
|
if self.orbit_bar_animation_time.nil?
|
||||||
|
self.orbit_bar_animation_time = "0.3s"
|
||||||
|
self.save
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
def register_site(url,university,department,email,country)
|
def register_site(url,university,department,email,country)
|
||||||
api_key = STORE_CONFIG[:store_settings]["api_key"]
|
api_key = STORE_CONFIG[:store_settings]["api_key"]
|
||||||
self.generate_site_token
|
self.generate_site_token
|
||||||
|
|
Loading…
Reference in New Issue