From 4f484599b75eeff80fe81521901fada400f4a6c5 Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Wed, 23 May 2012 13:00:51 +0800 Subject: [PATCH] Clean up code , cache other auths. Fix sidebar --- .../module_apps_new_interface_controller.rb | 2 +- app/helpers/application_helper.rb | 2 +- .../_privilege_user.html.erb | 25 ------------------- .../setting.html.erb | 2 +- .../_privilege_user.html.erb | 20 --------------- .../setting.html.erb | 4 +-- app/views/layouts/_side_bar.html.erb | 2 +- .../layouts/_users_checkbox_ary.html.erb | 3 +++ app/views/shared/_privilege_user.html.erb | 16 ++++++++++++ .../back_end/approvals_controller.rb | 2 +- .../approvals/_privilege_user.html.erb | 25 ------------------- .../back_end/approvals/setting.html.erb | 2 +- .../back_end/approvals/setting.js.erb | 2 +- .../back_end/news_approvals_controller.rb | 2 +- .../news_approvals/_privilege_user.html.erb | 25 ------------------- .../back_end/news_approvals/setting.html.erb | 2 +- .../back_end/news_approvals/setting.js.erb | 2 +- 17 files changed, 31 insertions(+), 107 deletions(-) delete mode 100644 app/views/admin/module_apps_new_interface/_privilege_user.html.erb delete mode 100644 app/views/admin/object_auths_new_interface/_privilege_user.html.erb create mode 100644 app/views/layouts/_users_checkbox_ary.html.erb create mode 100644 app/views/shared/_privilege_user.html.erb delete mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/approvals/_privilege_user.html.erb delete mode 100644 vendor/built_in_modules/news/app/views/panel/news/back_end/news_approvals/_privilege_user.html.erb diff --git a/app/controllers/admin/module_apps_new_interface_controller.rb b/app/controllers/admin/module_apps_new_interface_controller.rb index 57767d5f..f8770ab3 100644 --- a/app/controllers/admin/module_apps_new_interface_controller.rb +++ b/app/controllers/admin/module_apps_new_interface_controller.rb @@ -6,7 +6,7 @@ class Admin::ModuleAppsNewInterfaceController < OrbitBackendController layout "new_admin" def setting - @sys_users = User.all(conditions: {admin: false}) + @sys_users = User.all(conditions: {admin: false}).includes(:avatar) @module_app = ModuleApp.find(params[:module_app_id]) @options_from_collection_for_select_bulletin_categorys = [@module_app].collect{|ma| [ma.title,ma.id] } # if params.has_key? :category diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index e5d5e374..0ed5a1bd 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,7 +1,7 @@ module ApplicationHelper FLASH_NOTICE_KEYS = [:error, :notice, :warning] - + def colorize_in_use_locale(locale) @site_in_use_locales.include?(locale)? 'green' : 'red' end diff --git a/app/views/admin/module_apps_new_interface/_privilege_user.html.erb b/app/views/admin/module_apps_new_interface/_privilege_user.html.erb deleted file mode 100644 index 90f5cb65..00000000 --- a/app/views/admin/module_apps_new_interface/_privilege_user.html.erb +++ /dev/null @@ -1,25 +0,0 @@ -<%= content_tag :div ,:id => "users_checkbox_ary",:class => 'clear' do -%> - <% @sys_users.each do |sys_user| -%> - -
- - <% sys_user.sub_roles.each do |sr| %> - - <% end %> - <%= content_tag :div,:data=>{'original-title'=>t('announcement.bulletin.approval_setting_window_title'),:content => "#{sys_user.sub_roles.collect{|sr| sr.i18n_variable[I18n.locale]}.join(',')}"},:class=>"checkbox clear" do %> -
-
-
- <% if sys_user.avatar? %> - <%= image_tag(sys_user.avatar.thumb.url,:class => "member-img") %> - <% else %> - <%= image_tag "person.png",:class => "member-img" %> - <% end %> -
- <%= label_tag "lab-user-#{sys_user.id}", (sys_user.name rescue ''),:class=>"member-name",:id=>nil -%> - <%= check_box_tag "[users][#{sys_user.id}]", 'true',users.include?(sys_user),:class => "check" -%> - <%end -%> -
- - <% end -%> -<% end -%> \ No newline at end of file diff --git a/app/views/admin/module_apps_new_interface/setting.html.erb b/app/views/admin/module_apps_new_interface/setting.html.erb index 7d1179f0..d3d769b0 100644 --- a/app/views/admin/module_apps_new_interface/setting.html.erb +++ b/app/views/admin/module_apps_new_interface/setting.html.erb @@ -26,7 +26,7 @@
<%= content_tag :div do -%> <% form_tag admin_module_app_manager_auth_proc_path do %> - <%= render :partial => "privilege_user", :locals => {:users => @users_array} %> + <%= render :partial => "layouts/users_checkbox_ary" %>
<%= submit_tag "Update", :class => 'btn btn-primary' %>
diff --git a/app/views/admin/object_auths_new_interface/_privilege_user.html.erb b/app/views/admin/object_auths_new_interface/_privilege_user.html.erb deleted file mode 100644 index 5d5f6e7f..00000000 --- a/app/views/admin/object_auths_new_interface/_privilege_user.html.erb +++ /dev/null @@ -1,20 +0,0 @@ -<%= content_tag :div ,:id => "users_checkbox_ary",:class => 'clear' do %> - <% @sys_users.each do |sys_user| %> -
- - <%= content_tag :div,:data=>{'original-title'=>t('announcement.bulletin.approval_setting_window_title'),:content => sys_user.cache_dept[I18n.locale.to_s]},:class=>"checkbox clear" do %> -
-
-
- <% if sys_user.avatar? %> - <%= image_tag(sys_user.avatar.thumb.url,:class => "member-img") %> - <% else %> - <%= image_tag "person.png",:class => "member-img" %> - <% end %> -
- <%= label_tag "lab-user-#{sys_user.id}", (sys_user.name rescue ''),:class=>"member-name",:id=>nil -%> - <%= check_box_tag "[users][#{sys_user.id}]", 'true',users.include?(sys_user),:class => "check" -%> - <%end %> -
- <% end %> -<% end %> \ No newline at end of file diff --git a/app/views/admin/object_auths_new_interface/setting.html.erb b/app/views/admin/object_auths_new_interface/setting.html.erb index f5d17370..e66330c7 100644 --- a/app/views/admin/object_auths_new_interface/setting.html.erb +++ b/app/views/admin/object_auths_new_interface/setting.html.erb @@ -27,8 +27,8 @@
<%= content_tag :div do -%> <% form_tag admin_object_auth_ob_auth_path do %> - <%= render :partial => "privilege_user", :locals => {:users => @users_array} %> -
+ <%= render :partial => "layouts/users_checkbox_ary" %> +
<%= submit_tag "Update", :class => 'btn btn-primary' %>
<% end -%> diff --git a/app/views/layouts/_side_bar.html.erb b/app/views/layouts/_side_bar.html.erb index c5719fce..73b5191a 100644 --- a/app/views/layouts/_side_bar.html.erb +++ b/app/views/layouts/_side_bar.html.erb @@ -7,7 +7,7 @@ <%= content_tag :li, :class => (active_for_controllers('bulletins', '/panel/announcement/back_end/tags', 'bulletin_categorys', 'approvals') || active_for_app_auth('Announcement') || active_for_ob_auths_object("BulletinCategory") ) do -%> <%= link_to content_tag(:i, nil, :class => 'icons-announcement') + t('admin.announcement'), panel_announcement_back_end_bulletins_path %> - <%= content_tag :ul, :class => ("nav nav-list " + visible_for_controllers('bulletins', '/panel/announcement/back_end/tags', 'bulletin_categorys', 'approvals')) do -%> + <%= content_tag :ul, :class => ("nav nav-list " + (visible_for_controllers('bulletins', '/panel/announcement/back_end/tags', 'bulletin_categorys', 'approvals')||active_for_ob_auths_object("BulletinCategory"))) do -%> <%= content_tag :li, link_to(t('announcement.all_articles'), panel_announcement_back_end_bulletins_path), :class => active_for_action('bulletins', 'index') %> <%= content_tag :li, link_to(t('announcement.add_new'), new_panel_announcement_back_end_bulletin_path), :class => active_for_action('bulletins', 'new') %> <%= content_tag :li, link_to(t('announcement.categories'), panel_announcement_back_end_bulletin_categorys_path), :class =>( active_for_action('bulletin_categorys', 'index') || active_for_ob_auths_object("BulletinCategory") ) %> diff --git a/app/views/layouts/_users_checkbox_ary.html.erb b/app/views/layouts/_users_checkbox_ary.html.erb new file mode 100644 index 00000000..92cf8242 --- /dev/null +++ b/app/views/layouts/_users_checkbox_ary.html.erb @@ -0,0 +1,3 @@ +<%= content_tag :div ,:id => "users_checkbox_ary",:class => 'clear' do %> + <%= render :partial => "shared/privilege_user",:collection =>@sys_users,:as=>:user ,:locals =>{ :chosen_users=> @users_array } %> +<%end -%> \ No newline at end of file diff --git a/app/views/shared/_privilege_user.html.erb b/app/views/shared/_privilege_user.html.erb new file mode 100644 index 00000000..9d49be35 --- /dev/null +++ b/app/views/shared/_privilege_user.html.erb @@ -0,0 +1,16 @@ +
+ + <%= content_tag :div,:data=>{'original-title'=>t('announcement.bulletin.approval_setting_window_title'),:content => user.cache_dept[I18n.locale.to_s]},:class=>"checkbox clear" do %> +
+
+
+ <% if user.avatar? %> + <%= image_tag(user.avatar.thumb.url,:class => "member-img") %> + <% else %> + <%= image_tag "person.png",:class => "member-img" %> + <% end %> +
+ <%= label_tag "lab-user-#{user.id}", (user.name rescue ''),:class=>"member-name",:id=>nil -%> + <%= check_box_tag "[users][#{user.id}]", 'true',chosen_users.include?(user),:class => "check" -%> + <%end %> +
diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/approvals_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/approvals_controller.rb index 22c3a6dd..a41c27ac 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/approvals_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/approvals_controller.rb @@ -12,7 +12,7 @@ class Panel::Announcement::BackEnd::ApprovalsController < OrbitBackendControlle # end def setting - @sys_users = User.all(conditions: {admin: false}) + @sys_users = User.all(conditions: {admin: false}).includes(:avatar) @bulletin_categorys = BulletinCategory.all @options_from_collection_for_select_bulletin_categorys = @bulletin_categorys.collect{|bc| [bc.i18n_variable[I18n.locale],bc.id] } if params.has_key? :category diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/approvals/_privilege_user.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/approvals/_privilege_user.html.erb deleted file mode 100644 index 90f5cb65..00000000 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/approvals/_privilege_user.html.erb +++ /dev/null @@ -1,25 +0,0 @@ -<%= content_tag :div ,:id => "users_checkbox_ary",:class => 'clear' do -%> - <% @sys_users.each do |sys_user| -%> - -
- - <% sys_user.sub_roles.each do |sr| %> - - <% end %> - <%= content_tag :div,:data=>{'original-title'=>t('announcement.bulletin.approval_setting_window_title'),:content => "#{sys_user.sub_roles.collect{|sr| sr.i18n_variable[I18n.locale]}.join(',')}"},:class=>"checkbox clear" do %> -
-
-
- <% if sys_user.avatar? %> - <%= image_tag(sys_user.avatar.thumb.url,:class => "member-img") %> - <% else %> - <%= image_tag "person.png",:class => "member-img" %> - <% end %> -
- <%= label_tag "lab-user-#{sys_user.id}", (sys_user.name rescue ''),:class=>"member-name",:id=>nil -%> - <%= check_box_tag "[users][#{sys_user.id}]", 'true',users.include?(sys_user),:class => "check" -%> - <%end -%> -
- - <% end -%> -<% end -%> \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/approvals/setting.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/approvals/setting.html.erb index 57d3105b..4dfa549e 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/approvals/setting.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/approvals/setting.html.erb @@ -24,7 +24,7 @@
<%= content_tag :div do -%> <% form_tag panel_announcement_back_end_approval_setting_path do %> - <%= render :partial => "privilege_user", :locals => {:users => @users_array} %> + <%= render :partial => "layouts/users_checkbox_ary" %>
<%= submit_tag "Update", :class => 'btn btn-primary' %>
diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/approvals/setting.js.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/approvals/setting.js.erb index 0ca148da..7eb41c72 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/approvals/setting.js.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/approvals/setting.js.erb @@ -1,2 +1,2 @@ -$("#users_checkbox_ary").replaceWith('<%= escape_javascript(render :partial => "privilege_user", :locals => {:users => @users_array})%>'); +$("#users_checkbox_ary").replaceWith('<%= escape_javascript(render :partial=> "layouts/users_checkbox_ary" )%>'); permissionCheckbox(); \ No newline at end of file diff --git a/vendor/built_in_modules/news/app/controllers/panel/news/back_end/news_approvals_controller.rb b/vendor/built_in_modules/news/app/controllers/panel/news/back_end/news_approvals_controller.rb index 3eb3e9c0..0f10fe91 100644 --- a/vendor/built_in_modules/news/app/controllers/panel/news/back_end/news_approvals_controller.rb +++ b/vendor/built_in_modules/news/app/controllers/panel/news/back_end/news_approvals_controller.rb @@ -12,7 +12,7 @@ class Panel::News::BackEnd::NewsApprovalsController < OrbitBackendController end def setting - @sys_users = User.all(conditions: {admin: false}) + @sys_users = User.all(conditions: {admin: false}).includes(:avatar) @news_bulletin_categorys = NewsBulletinCategory.all @options_from_collection_for_select_news_bulletin_categorys = @news_bulletin_categorys.collect{|bc| [bc.i18n_variable[I18n.locale],bc.id] } if params.has_key? :news_category diff --git a/vendor/built_in_modules/news/app/views/panel/news/back_end/news_approvals/_privilege_user.html.erb b/vendor/built_in_modules/news/app/views/panel/news/back_end/news_approvals/_privilege_user.html.erb deleted file mode 100644 index 60c5a782..00000000 --- a/vendor/built_in_modules/news/app/views/panel/news/back_end/news_approvals/_privilege_user.html.erb +++ /dev/null @@ -1,25 +0,0 @@ -<%= content_tag :div ,:id => "users_checkbox_ary",:class => 'clear' do -%> - <% @sys_users.each do |user| -%> - -
- - <% user.sub_roles.each do |sr| %> - - <% end %> - <%= content_tag :div,:data=>{'original-title'=>t('news.news_bulletin.approval_setting_window_title'),:content => "#{user.sub_roles.collect{|sr| sr.i18n_variable[I18n.locale]}.join(',')}"},:class=>"checkbox clear" do %> -
-
-
- <% if user.avatar? %> - <%= image_tag(user.avatar.thumb.url,:class => "member-img") %> - <% else %> - <%= image_tag "person.png",:class => "member-img" %> - <% end %> -
- <%= label_tag "lab-user-#{user.id}", (user.name rescue ''),:class=>"member-name",:id=>nil -%> - <%= check_box_tag "[users][#{user.id}]", 'true',users.include?(user),:class => "check" -%> - <%end -%> -
- - <% end -%> -<% end -%> \ No newline at end of file diff --git a/vendor/built_in_modules/news/app/views/panel/news/back_end/news_approvals/setting.html.erb b/vendor/built_in_modules/news/app/views/panel/news/back_end/news_approvals/setting.html.erb index 298e21eb..c8e9c314 100644 --- a/vendor/built_in_modules/news/app/views/panel/news/back_end/news_approvals/setting.html.erb +++ b/vendor/built_in_modules/news/app/views/panel/news/back_end/news_approvals/setting.html.erb @@ -24,7 +24,7 @@
<%= content_tag :div do -%> <% form_tag panel_news_back_end_approval_setting_path do %> - <%= render :partial => "privilege_user", :locals => {:users => @users_array} %> + <%= render :partial => "layouts/users_checkbox_ary" %>
<%= submit_tag "Update", :class => 'btn btn-primary' %>
diff --git a/vendor/built_in_modules/news/app/views/panel/news/back_end/news_approvals/setting.js.erb b/vendor/built_in_modules/news/app/views/panel/news/back_end/news_approvals/setting.js.erb index 0ca148da..7eb41c72 100644 --- a/vendor/built_in_modules/news/app/views/panel/news/back_end/news_approvals/setting.js.erb +++ b/vendor/built_in_modules/news/app/views/panel/news/back_end/news_approvals/setting.js.erb @@ -1,2 +1,2 @@ -$("#users_checkbox_ary").replaceWith('<%= escape_javascript(render :partial => "privilege_user", :locals => {:users => @users_array})%>'); +$("#users_checkbox_ary").replaceWith('<%= escape_javascript(render :partial=> "layouts/users_checkbox_ary" )%>'); permissionCheckbox(); \ No newline at end of file