new ui add setting to show in the member frontend

This commit is contained in:
Spen 2014-01-03 15:49:19 +08:00 committed by saurabhbhatia
parent ca8c895ac8
commit e4cc6d543b
15 changed files with 116 additions and 75 deletions

View File

@ -112,6 +112,7 @@ function setData(l, type, ol) {
_title_translations: ["title_translations_" +l, fields+"["+l+"][title_translations]"], _title_translations: ["title_translations_" +l, fields+"["+l+"][title_translations]"],
_to_delete: ["to_delete_" +l, fields+"["+l+"][to_delete]"], _to_delete: ["to_delete_" +l, fields+"["+l+"][to_delete]"],
_to_search: ["to_search_" +l, fields+"["+l+"][to_search]"], _to_search: ["to_search_" +l, fields+"["+l+"][to_search]"],
_to_show: ["to_show_" +l, fields+"["+l+"][to_show]"],
}; };
return data; return data;
} }

View File

@ -9,6 +9,7 @@ class Attribute
field :title, localize: true field :title, localize: true
field :to_search, :type => Boolean, :default => false field :to_search, :type => Boolean, :default => false
field :to_show,:type=> Boolean,:default => true
has_many :attribute_fields, :autosave => true, :dependent => :destroy has_many :attribute_fields, :autosave => true, :dependent => :destroy
accepts_nested_attributes_for :attribute_fields, :allow_destroy => true accepts_nested_attributes_for :attribute_fields, :allow_destroy => true

View File

@ -13,6 +13,7 @@ class AttributeField
field :to_delete,:type=> Boolean,:default => false field :to_delete,:type=> Boolean,:default => false
field :to_search,:type=> Boolean,:default => false field :to_search,:type=> Boolean,:default => false
field :to_show,:type=> Boolean,:default => true
field :typeA,:type=> Hash,:default=>{:cross_lang=>false} field :typeA,:type=> Hash,:default=>{:cross_lang=>false}
field :typeB,:type=> Hash,:default=>{} field :typeB,:type=> Hash,:default=>{}

View File

@ -57,7 +57,7 @@
<div id="attributes-area" class="input-area"> <div id="attributes-area" class="input-area">
<%= render :partial=>"shared/attribute_field/attribute_field",:collection=>@attribute.attribute_fields%> <%= render :partial=>"shared/attribute_field/attribute_field",:collection=>@attribute.attribute_fields.asc("_id")%>
</div> </div>

View File

@ -35,6 +35,17 @@
</label> </label>
</div> </div>
</div> </div>
<div class="control-group">
<label class="control-label muted" for=""><%= t(:to_show) %></label>
<div class="controls">
<label class="radio inline">
<%= radio_button("#{@field_name}[attribute_fields][#{@af_counter}]", "to_show", "true",:checked => (attribute_field.to_show == true ? true : false), :data=>{:type=>"search_true"}) %><%= t(:yes_)%>
</label>
<label class="radio inline">
<%= radio_button("#{@field_name}[attribute_fields][#{@af_counter}]", "to_show", "false",:checked => (attribute_field.to_show == false ? true : false), :data=>{:type=>"search_false"}) %><%= t(:no_)%>
</label>
</div>
</div>
<div class="control-group"> <div class="control-group">
<label class="control-label muted" for=""><%= t(:type)%></label> <label class="control-label muted" for=""><%= t(:type)%></label>
<div class="controls"> <div class="controls">

View File

@ -48,6 +48,17 @@
</label> </label>
</div> </div>
</div> </div>
<div class="control-group">
<label class="control-label muted" for=""><%= t(:to_show) %></label>
<div class="controls">
<label class="radio inline">
<input type="radio" data-type="search_true" id="${_to_show[0]+'_true'}" name="${_to_show[1]}" value="true" checked=""> <%= t(:yes_)%>
</label>
<label class="radio inline">
<input type="radio" data-type="search_false" id="${_to_show[0]+'_false'}" name="${_to_show[1]}" value="false"> <%= t(:no_)%>
</label>
</div>
</div>
<div class="control-group"> <div class="control-group">
<label class="control-label muted" for=""><%= t(:type)%></label> <label class="control-label muted" for=""><%= t(:type)%></label>
<div class="controls"> <div class="controls">

View File

@ -35,6 +35,17 @@
</label> </label>
</div> </div>
</div> </div>
<div class="control-group">
<label class="control-label muted" for=""><%= t(:to_show) %></label>
<div class="controls">
<label class="radio inline">
<%= radio_button("info[attribute_fields][#{@af_counter}]", "to_show", "true",:checked => (attribute_field.to_show == true ? true : false), :data=>{:type=>"search_true"}) %><%= t(:yes_)%>
</label>
<label class="radio inline">
<%= radio_button("info[attribute_fields][#{@af_counter}]", "to_show", "false",:checked => (attribute_field.to_show == false ? true : false), :data=>{:type=>"search_false"}) %><%= t(:no_)%>
</label>
</div>
</div>
<div class="control-group"> <div class="control-group">
<label class="control-label muted" for=""><%= t(:type)%></label> <label class="control-label muted" for=""><%= t(:type)%></label>
<div class="controls"> <div class="controls">

View File

@ -510,6 +510,7 @@ en:
themes: Themes themes: Themes
title: Title title: Title
to_search: Set as Search Key to_search: Set as Search Key
to_show: Display in frontend
top: Top top: Top
total_visitors: Total Visitors total_visitors: Total Visitors
traffic: Traffic traffic: Traffic

View File

@ -512,6 +512,7 @@ zh_tw:
themes: 主題 themes: 主題
title: 標題 title: 標題
to_search: 加入搜尋條件 to_search: 加入搜尋條件
to_show: 是否顯示於前台
top: 置頂 top: 置頂
is_top: 置頂 is_top: 置頂
total_visitors: 總計造訪人次 total_visitors: 總計造訪人次

View File

@ -66,7 +66,7 @@ class Panel::Member::FrontEnd::MemberListsController < OrbitWidgetController
attribute_values = @member.attribute_values.asc("_id") attribute_values = @member.attribute_values.asc("_id")
attribute_values.each{|att_val| attribute_values.each{|att_val|
@profile_data.push({:name => att_val.attribute_field.title,:value =>att_val.get_value_by_locale(I18n.locale.to_s)}) if att_val.attribute_field.attribute.key=="profile" rescue false @profile_data.push({:name => att_val.attribute_field.title,:value =>att_val.get_value_by_locale(I18n.locale.to_s)}) if att_val.attribute_field.attribute.key=="profile" and att_val.attribute_field.to_show != false rescue false
} }
end end

View File

@ -1,28 +1,5 @@
<%
@status = @member.role_statuses.where(:role_id=>show_roles.id)
if !@status.blank? <% show_roles.attribute_fields.where(:disabled=>false, :to_show.ne => false).asc(:_id).each do |rf| %>
%>
<tr>
<td><%= t('status')%></td>
<td><%= show_attribute_value(@member.role_statuses.where(:role_id=>show_roles.id).map{|t|t.title.to_s}.join(',')) rescue '' %></td>
</tr>
<% end -%>
<%
@category = @member.role_categorys.where(:role_id=>show_roles.id)
if !@category.blank?
%>
<tr>
<td><%= t('category')%></td>
<td><%= show_attribute_value(@member.role_categorys.where(:role_id=>show_roles.id).map{|t|t.title.to_s}.join(',')) rescue '' %></td>
</tr>
<% end -%>
<% show_roles.attribute_fields.where(:disabled=>false).asc(:_id).each do |rf| %>
<% <%
if !@member.get_attribute_value(rf).blank? if !@member.get_attribute_value(rf).blank?
@ -34,7 +11,8 @@
@rodata = nil @rodata = nil
end end
if !@rodata.blank? and !@member.get_attribute_value(rf).get_value_by_locale(I18n.locale).blank? if !@rodata.blank? and !@member.get_attribute_value(rf).get_value_by_locale(I18n.locale).blank? and rf.key != 'job_title'
%> %>
<tr> <tr>

View File

@ -2,6 +2,32 @@
<div class="member-data"> <div class="member-data">
<table> <table>
<tbody> <tbody>
<% @job_title_field = User.get_member_list_attribute_field("teacher","job_title") %>
<%
@member_role = @member.roles.where(:key=>"teacher", :disabled=>false)
@category = @member.role_categorys.where(:role_id=>@member_role[0]['_id'])
if !@category.blank?
%>
<tr>
<td><%= t('category')%></td>
<td><%= show_attribute_value(@member.role_categorys.where(:role_id=>@member_role[0]['_id']).map{|t|t.title.to_s}.join(',')) rescue '' %></td>
</tr>
<% end -%>
<%
@job_title = show_attribute_value(User.get_member_list_attribute_value(@member.id,@job_title_field.id).get_value_by_locale(I18n.locale))
if @job_title != 'NoData' and !@job_title.blank? and @job_title_field.to_show == true
%>
<tr>
<td><%= @job_title_field.title %></td>
<td><%= @job_title %></td>
</tr>
<% end -%>
<tr> <tr>
<td><%= t('users.name')%></td> <td><%= t('users.name')%></td>
<td><%= @member.name%></td> <td><%= @member.name%></td>
@ -10,22 +36,12 @@
<td><%= t('users.email')%></td> <td><%= t('users.email')%></td>
<td><a href="mailto:<%= @member.email %>"><%= @member.email %></a></td> <td><a href="mailto:<%= @member.email %>"><%= @member.email %></a></td>
</tr> </tr>
<% if !@member.sid.blank? %>
<tr>
<td><%= t('users.sid')%></td>
<td><%= @member.sid%></td>
</tr>
<% end %>
<% if !@member.office_tel.blank? %> <% if !@member.office_tel.blank? %>
<tr> <tr>
<td><%= t('users.office_tel')%></td> <td><%= t('users.office_tel')%></td>
<td><%= @member.office_tel%></td> <td><%= @member.office_tel%></td>
</tr> </tr>
<% end %> <% end %>
<tr>
<td><%= t('users.sex')%></td>
<td><%= t("users.#{@member.sex}") %></td>
</tr>
<% @profile_data.each do |item| %> <% @profile_data.each do |item| %>
<% if !item[:value].blank? %> <% if !item[:value].blank? %>
@ -36,7 +52,7 @@
<% end -%> <% end -%>
<% end -%> <% end -%>
<%= render :partial=> "show_roles",:collection=>@member.roles.where(:disabled=>false).asc(:created_at) %> <%= render :partial=> "show_roles",:collection=>@member_role %>
</tbody> </tbody>
</table> </table>

View File

@ -52,7 +52,13 @@ class Panel::MemberStaff::FrontEnd::MemberStaffListsController < OrbitWidgetCont
def show def show
@member = User.find(params[:id]) @member = User.find(params[:id])
# get_categorys
@profile_data = []
attribute_values = @member.attribute_values.asc("_id")
attribute_values.each{|att_val|
@profile_data.push({:name => att_val.attribute_field.title,:value =>att_val.get_value_by_locale(I18n.locale.to_s)}) if att_val.attribute_field.attribute.key=="profile" and att_val.attribute_field.to_show != false rescue false
}
end end

View File

@ -1,28 +1,5 @@
<%
@status = @member.role_statuses.where(:role_id=>show_roles.id)
if !@status.blank? <% show_roles.attribute_fields.where(:disabled=>false, :to_show.ne => false).asc(:_id).each do |rf| %>
%>
<tr>
<td><%= t('status')%></td>
<td><%= show_attribute_value(@member.role_statuses.where(:role_id=>show_roles.id).map{|t|t.title.to_s}.join(',')) rescue '' %></td>
</tr>
<% end -%>
<%
@category = @member.role_categorys.where(:role_id=>show_roles.id)
if !@category.blank?
%>
<tr>
<td><%= t('category')%></td>
<td><%= show_attribute_value(@member.role_categorys.where(:role_id=>show_roles.id).map{|t|t.title.to_s}.join(',')) rescue '' %></td>
</tr>
<% end -%>
<% show_roles.attribute_fields.where(:disabled=>false).asc(:_id).each do |rf| %>
<% <%
if !@member.get_attribute_value(rf).blank? if !@member.get_attribute_value(rf).blank?
@ -34,7 +11,8 @@
@rodata = nil @rodata = nil
end end
if !@rodata.blank? and !@member.get_attribute_value(rf).get_value_by_locale(I18n.locale).blank? if !@rodata.blank? and !@member.get_attribute_value(rf).get_value_by_locale(I18n.locale).blank? and rf.key != 'job_title'
%> %>
<tr> <tr>

View File

@ -2,6 +2,32 @@
<div class="member-data"> <div class="member-data">
<table> <table>
<tbody> <tbody>
<% @job_title_field = User.get_member_list_attribute_field("staff","job_title") %>
<%
@member_role = @member.roles.where(:key=>"staff", :disabled=>false)
@category = @member.role_categorys.where(:role_id=>@member_role[0]['_id'])
if !@category.blank?
%>
<tr>
<td><%= t('category')%></td>
<td><%= show_attribute_value(@member.role_categorys.where(:role_id=>@member_role[0]['_id']).map{|t|t.title.to_s}.join(',')) rescue '' %></td>
</tr>
<% end -%>
<%
@job_title = show_attribute_value(User.get_member_list_attribute_value(@member.id,@job_title_field.id).get_value_by_locale(I18n.locale))
if @job_title != 'NoData' and !@job_title.blank? and @job_title_field.to_show == true
%>
<tr>
<td><%= @job_title_field.title %></td>
<td><%= @job_title %></td>
</tr>
<% end -%>
<tr> <tr>
<td><%= t('users.name')%></td> <td><%= t('users.name')%></td>
<td><%= @member.name%></td> <td><%= @member.name%></td>
@ -10,24 +36,23 @@
<td><%= t('users.email')%></td> <td><%= t('users.email')%></td>
<td><a href="mailto:<%= @member.email %>"><%= @member.email %></a></td> <td><a href="mailto:<%= @member.email %>"><%= @member.email %></a></td>
</tr> </tr>
<% if !@member.sid.blank? %>
<tr>
<td><%= t('users.sid')%></td>
<td><%= @member.sid%></td>
</tr>
<% end %>
<% if !@member.office_tel.blank? %> <% if !@member.office_tel.blank? %>
<tr> <tr>
<td><%= t('users.office_tel')%></td> <td><%= t('users.office_tel')%></td>
<td><%= @member.office_tel%></td> <td><%= @member.office_tel%></td>
</tr> </tr>
<% end %> <% end %>
<tr>
<td><%= t('users.sex')%></td>
<td><%= t("users.#{@member.sex}") %></td>
</tr>
<%= render :partial=> "show_roles",:collection=>@member.roles.where(:disabled=>false).asc(:created_at) %> <% @profile_data.each do |item| %>
<% if !item[:value].blank? %>
<tr>
<td><%= item[:name] %></td>
<td><%= show_attribute_value(item[:value]) %></td>
</tr>
<% end -%>
<% end -%>
<%= render :partial=> "show_roles",:collection=>@member_role %>
</tbody> </tbody>
</table> </table>