From e4cc6d543bb7c5cd0e6d4721ec779570787fb829 Mon Sep 17 00:00:00 2001 From: Spen Date: Fri, 3 Jan 2014 15:49:19 +0800 Subject: [PATCH] new ui add setting to show in the member frontend --- .../javascripts/lib/member/role-forms.js | 1 + app/models/user/attribute.rb | 1 + app/models/user/attribute_field.rb | 1 + app/views/admin/attributes/edit.html.erb | 2 +- .../admin/roles/_attribute_field.html.erb | 11 +++++ app/views/js/_support_member_form_js.erb | 11 +++++ .../attribute_field/_attribute_field.html.erb | 11 +++++ config/locales/en.yml | 1 + config/locales/zh_tw.yml | 1 + .../front_end/member_lists_controller.rb | 2 +- .../member_lists/_show_roles.html.erb | 28 ++--------- .../front_end/member_lists/show.html.erb | 38 ++++++++++----- .../member_staff_lists_controller.rb | 8 +++- .../member_staff_lists/_show_roles.html.erb | 28 ++--------- .../member_staff_lists/show.html.erb | 47 ++++++++++++++----- 15 files changed, 116 insertions(+), 75 deletions(-) diff --git a/app/assets/javascripts/lib/member/role-forms.js b/app/assets/javascripts/lib/member/role-forms.js index e9449642..2de84cd0 100644 --- a/app/assets/javascripts/lib/member/role-forms.js +++ b/app/assets/javascripts/lib/member/role-forms.js @@ -112,6 +112,7 @@ function setData(l, type, ol) { _title_translations: ["title_translations_" +l, fields+"["+l+"][title_translations]"], _to_delete: ["to_delete_" +l, fields+"["+l+"][to_delete]"], _to_search: ["to_search_" +l, fields+"["+l+"][to_search]"], + _to_show: ["to_show_" +l, fields+"["+l+"][to_show]"], }; return data; } diff --git a/app/models/user/attribute.rb b/app/models/user/attribute.rb index a1367c9f..bb3ca152 100644 --- a/app/models/user/attribute.rb +++ b/app/models/user/attribute.rb @@ -9,6 +9,7 @@ class Attribute field :title, localize: true field :to_search, :type => Boolean, :default => false + field :to_show,:type=> Boolean,:default => true has_many :attribute_fields, :autosave => true, :dependent => :destroy accepts_nested_attributes_for :attribute_fields, :allow_destroy => true diff --git a/app/models/user/attribute_field.rb b/app/models/user/attribute_field.rb index 0a6c4ac3..a3960883 100644 --- a/app/models/user/attribute_field.rb +++ b/app/models/user/attribute_field.rb @@ -13,6 +13,7 @@ class AttributeField field :to_delete,: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 :typeB,:type=> Hash,:default=>{} diff --git a/app/views/admin/attributes/edit.html.erb b/app/views/admin/attributes/edit.html.erb index c5e2b9a8..576cb865 100644 --- a/app/views/admin/attributes/edit.html.erb +++ b/app/views/admin/attributes/edit.html.erb @@ -57,7 +57,7 @@
- <%= render :partial=>"shared/attribute_field/attribute_field",:collection=>@attribute.attribute_fields%> + <%= render :partial=>"shared/attribute_field/attribute_field",:collection=>@attribute.attribute_fields.asc("_id")%>
diff --git a/app/views/admin/roles/_attribute_field.html.erb b/app/views/admin/roles/_attribute_field.html.erb index 87fdc3f1..411fca74 100644 --- a/app/views/admin/roles/_attribute_field.html.erb +++ b/app/views/admin/roles/_attribute_field.html.erb @@ -35,6 +35,17 @@ +
+ +
+ + +
+
diff --git a/app/views/js/_support_member_form_js.erb b/app/views/js/_support_member_form_js.erb index 549a63e6..e86ceb7b 100644 --- a/app/views/js/_support_member_form_js.erb +++ b/app/views/js/_support_member_form_js.erb @@ -48,6 +48,17 @@
+
+ +
+ + +
+
diff --git a/app/views/shared/attribute_field/_attribute_field.html.erb b/app/views/shared/attribute_field/_attribute_field.html.erb index 87387482..7c54af38 100644 --- a/app/views/shared/attribute_field/_attribute_field.html.erb +++ b/app/views/shared/attribute_field/_attribute_field.html.erb @@ -35,6 +35,17 @@
+
+ +
+ + +
+
diff --git a/config/locales/en.yml b/config/locales/en.yml index 044991f7..187d6df4 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -510,6 +510,7 @@ en: themes: Themes title: Title to_search: Set as Search Key + to_show: Display in frontend top: Top total_visitors: Total Visitors traffic: Traffic diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml index c1c7a8bd..f9c0f8f4 100644 --- a/config/locales/zh_tw.yml +++ b/config/locales/zh_tw.yml @@ -512,6 +512,7 @@ zh_tw: themes: 主題 title: 標題 to_search: 加入搜尋條件 + to_show: 是否顯示於前台 top: 置頂 is_top: 置頂 total_visitors: 總計造訪人次 diff --git a/vendor/built_in_modules/member/app/controllers/panel/member/front_end/member_lists_controller.rb b/vendor/built_in_modules/member/app/controllers/panel/member/front_end/member_lists_controller.rb index 8984a1e2..22d7457a 100644 --- a/vendor/built_in_modules/member/app/controllers/panel/member/front_end/member_lists_controller.rb +++ b/vendor/built_in_modules/member/app/controllers/panel/member/front_end/member_lists_controller.rb @@ -66,7 +66,7 @@ class Panel::Member::FrontEnd::MemberListsController < OrbitWidgetController 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" 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 diff --git a/vendor/built_in_modules/member/app/views/panel/member/front_end/member_lists/_show_roles.html.erb b/vendor/built_in_modules/member/app/views/panel/member/front_end/member_lists/_show_roles.html.erb index 7d8219a6..597eae43 100644 --- a/vendor/built_in_modules/member/app/views/panel/member/front_end/member_lists/_show_roles.html.erb +++ b/vendor/built_in_modules/member/app/views/panel/member/front_end/member_lists/_show_roles.html.erb @@ -1,28 +1,5 @@ - <% - @status = @member.role_statuses.where(:role_id=>show_roles.id) - if !@status.blank? - %> - - <%= t('status')%> - <%= show_attribute_value(@member.role_statuses.where(:role_id=>show_roles.id).map{|t|t.title.to_s}.join(',')) rescue '' %> - - - <% end -%> - - <% - @category = @member.role_categorys.where(:role_id=>show_roles.id) - - if !@category.blank? - %> - - <%= t('category')%> - <%= show_attribute_value(@member.role_categorys.where(:role_id=>show_roles.id).map{|t|t.title.to_s}.join(',')) rescue '' %> - - - <% end -%> - - <% show_roles.attribute_fields.where(:disabled=>false).asc(:_id).each do |rf| %> + <% show_roles.attribute_fields.where(:disabled=>false, :to_show.ne => false).asc(:_id).each do |rf| %> <% if !@member.get_attribute_value(rf).blank? @@ -34,7 +11,8 @@ @rodata = nil 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' + %> diff --git a/vendor/built_in_modules/member/app/views/panel/member/front_end/member_lists/show.html.erb b/vendor/built_in_modules/member/app/views/panel/member/front_end/member_lists/show.html.erb index b9a18cae..1fd954b1 100644 --- a/vendor/built_in_modules/member/app/views/panel/member/front_end/member_lists/show.html.erb +++ b/vendor/built_in_modules/member/app/views/panel/member/front_end/member_lists/show.html.erb @@ -2,6 +2,32 @@
+ + <% @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? + %> + + + + + + <% 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 + %> + + + + + <% end -%> + @@ -10,22 +36,12 @@ - <% if !@member.sid.blank? %> - - - - - <% end %> <% if !@member.office_tel.blank? %> <% end %> - - - - <% @profile_data.each do |item| %> <% if !item[:value].blank? %> @@ -36,7 +52,7 @@ <% end -%> <% end -%> - <%= render :partial=> "show_roles",:collection=>@member.roles.where(:disabled=>false).asc(:created_at) %> + <%= render :partial=> "show_roles",:collection=>@member_role %>
<%= t('category')%><%= show_attribute_value(@member.role_categorys.where(:role_id=>@member_role[0]['_id']).map{|t|t.title.to_s}.join(',')) rescue '' %>
<%= @job_title_field.title %><%= @job_title %>
<%= t('users.name')%> <%= @member.name%><%= t('users.email')%> <%= @member.email %>
<%= t('users.sid')%><%= @member.sid%>
<%= t('users.office_tel')%> <%= @member.office_tel%>
<%= t('users.sex')%><%= t("users.#{@member.sex}") %>
diff --git a/vendor/built_in_modules/member_staff/app/controllers/panel/member_staff/front_end/member_staff_lists_controller.rb b/vendor/built_in_modules/member_staff/app/controllers/panel/member_staff/front_end/member_staff_lists_controller.rb index ad4e849d..09045720 100644 --- a/vendor/built_in_modules/member_staff/app/controllers/panel/member_staff/front_end/member_staff_lists_controller.rb +++ b/vendor/built_in_modules/member_staff/app/controllers/panel/member_staff/front_end/member_staff_lists_controller.rb @@ -52,7 +52,13 @@ class Panel::MemberStaff::FrontEnd::MemberStaffListsController < OrbitWidgetCont def show @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 diff --git a/vendor/built_in_modules/member_staff/app/views/panel/member_staff/front_end/member_staff_lists/_show_roles.html.erb b/vendor/built_in_modules/member_staff/app/views/panel/member_staff/front_end/member_staff_lists/_show_roles.html.erb index 7d8219a6..597eae43 100644 --- a/vendor/built_in_modules/member_staff/app/views/panel/member_staff/front_end/member_staff_lists/_show_roles.html.erb +++ b/vendor/built_in_modules/member_staff/app/views/panel/member_staff/front_end/member_staff_lists/_show_roles.html.erb @@ -1,28 +1,5 @@ - <% - @status = @member.role_statuses.where(:role_id=>show_roles.id) - if !@status.blank? - %> - - <%= t('status')%> - <%= show_attribute_value(@member.role_statuses.where(:role_id=>show_roles.id).map{|t|t.title.to_s}.join(',')) rescue '' %> - - - <% end -%> - - <% - @category = @member.role_categorys.where(:role_id=>show_roles.id) - - if !@category.blank? - %> - - <%= t('category')%> - <%= show_attribute_value(@member.role_categorys.where(:role_id=>show_roles.id).map{|t|t.title.to_s}.join(',')) rescue '' %> - - - <% end -%> - - <% show_roles.attribute_fields.where(:disabled=>false).asc(:_id).each do |rf| %> + <% show_roles.attribute_fields.where(:disabled=>false, :to_show.ne => false).asc(:_id).each do |rf| %> <% if !@member.get_attribute_value(rf).blank? @@ -34,7 +11,8 @@ @rodata = nil 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' + %> diff --git a/vendor/built_in_modules/member_staff/app/views/panel/member_staff/front_end/member_staff_lists/show.html.erb b/vendor/built_in_modules/member_staff/app/views/panel/member_staff/front_end/member_staff_lists/show.html.erb index 69dcc084..e11a6587 100644 --- a/vendor/built_in_modules/member_staff/app/views/panel/member_staff/front_end/member_staff_lists/show.html.erb +++ b/vendor/built_in_modules/member_staff/app/views/panel/member_staff/front_end/member_staff_lists/show.html.erb @@ -2,6 +2,32 @@
+ + <% @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? + %> + + + + + + <% 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 + %> + + + + + <% end -%> + @@ -10,24 +36,23 @@ - <% if !@member.sid.blank? %> - - - - - <% end %> <% if !@member.office_tel.blank? %> <% end %> - - - - - <%= render :partial=> "show_roles",:collection=>@member.roles.where(:disabled=>false).asc(:created_at) %> + <% @profile_data.each do |item| %> + <% if !item[:value].blank? %> + + + + + <% end -%> + <% end -%> + + <%= render :partial=> "show_roles",:collection=>@member_role %>
<%= t('category')%><%= show_attribute_value(@member.role_categorys.where(:role_id=>@member_role[0]['_id']).map{|t|t.title.to_s}.join(',')) rescue '' %>
<%= @job_title_field.title %><%= @job_title %>
<%= t('users.name')%> <%= @member.name%><%= t('users.email')%> <%= @member.email %>
<%= t('users.sid')%><%= @member.sid%>
<%= t('users.office_tel')%> <%= @member.office_tel%>
<%= t('users.sex')%><%= t("users.#{@member.sex}") %>
<%= item[:name] %><%= show_attribute_value(item[:value]) %>