fix serval bugs on sidebar.
This commit is contained in:
parent
bd743a0ca5
commit
858e942da2
|
@ -63,11 +63,31 @@ class ModuleApp
|
||||||
end
|
end
|
||||||
|
|
||||||
def is_manager?(user)
|
def is_manager?(user)
|
||||||
managing_users.include?(user)
|
if user.nil?
|
||||||
|
return false
|
||||||
|
else
|
||||||
|
m_users = managing_users
|
||||||
|
if m_users.blank?
|
||||||
|
false
|
||||||
|
else
|
||||||
|
m_users.include?(user)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def is_sub_manager?(user)
|
def is_sub_manager?(user)
|
||||||
sub_managing_users.include?(user) || is_manager?(user)
|
if user.nil?
|
||||||
|
return false
|
||||||
|
else # when user is guest
|
||||||
|
s_m_users = sub_managing_users
|
||||||
|
result = false
|
||||||
|
if s_m_users.blank?
|
||||||
|
result = false
|
||||||
|
else
|
||||||
|
result = s_m_users.include?(user)
|
||||||
|
end
|
||||||
|
result || is_manager?(user)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def managing_users
|
def managing_users
|
||||||
|
|
|
@ -25,7 +25,7 @@ protected
|
||||||
else
|
else
|
||||||
(eval(available_for_in_sym).include? @current_user rescue false)
|
(eval(available_for_in_sym).include? @current_user rescue false)
|
||||||
end # of case
|
end # of case
|
||||||
return true if result || @current_user.admin?
|
return true if result || (@current_user.admin? rescue false)
|
||||||
end # of collect
|
end # of collect
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,10 +8,11 @@ module Renderer
|
||||||
|
|
||||||
protected
|
protected
|
||||||
def active_for_app_auth?
|
def active_for_app_auth?
|
||||||
if @module_app.nil?
|
module_app = get_module_app
|
||||||
|
if module_app.nil?
|
||||||
false
|
false
|
||||||
else
|
else
|
||||||
@module_app.id.to_s == @params[:module_app_id] ? true : false
|
module_app.id.to_s == @params[:module_app_id] ? true : false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ module SideBarRenderer
|
||||||
def display? #控制sidebar 要不要算圖
|
def display? #控制sidebar 要不要算圖
|
||||||
if is_manager? || is_admin? #如果是系統管理員 或 是模組管理員
|
if is_manager? || is_admin? #如果是系統管理員 或 是模組管理員
|
||||||
true
|
true
|
||||||
elsif (@current_module_app.open rescue false) # 如果app 被設定成 開放
|
elsif (@current_module_app.open rescue true) # 如果app 被設定成 開放
|
||||||
true
|
true
|
||||||
elsif is_member? #如果app 是封閉 那至少需要是 member
|
elsif is_member? #如果app 是封閉 那至少需要是 member
|
||||||
true
|
true
|
||||||
|
|
|
@ -35,12 +35,12 @@ module AdBanner
|
||||||
side_bar do
|
side_bar do
|
||||||
head_label_i18n 'admin.ad_banner',:icon_class=>"icons-landscape"
|
head_label_i18n 'admin.ad_banner',:icon_class=>"icons-landscape"
|
||||||
available_for [:admin,:guest,:manager,:sub_manager]
|
available_for [:admin,:guest,:manager,:sub_manager]
|
||||||
active_for_controllers ({:private=>['ad_banners', 'ad_images']})
|
active_for_controllers ({:public=>['admin/ad_banners', 'admin/ad_images']})
|
||||||
|
|
||||||
head_link_path "admin_ad_banners_path"
|
head_link_path "admin_ad_banners_path"
|
||||||
|
|
||||||
context_link 'module_authorization',
|
context_link 'module_authorization',
|
||||||
:link_path=>"admin_module_app_manager_auth_proc_path(ModuleApp.first(conditions: {key: 'ad_banner'}))",
|
:link_path=>"admin_module_app_manager_auth_proc_path(ModuleApp.first(conditions: {title: 'AdBanner'}))",
|
||||||
:priority=>6,
|
:priority=>6,
|
||||||
:active_for_app_auth => 'ad_banners',
|
:active_for_app_auth => 'ad_banners',
|
||||||
:available_for => [:admin]
|
:available_for => [:admin]
|
||||||
|
|
|
@ -28,7 +28,7 @@ module Archive
|
||||||
side_bar do
|
side_bar do
|
||||||
head_label_i18n 'miss_module_i18n.archive',:icon_class=>"icons-archive"
|
head_label_i18n 'miss_module_i18n.archive',:icon_class=>"icons-archive"
|
||||||
available_for [:admin,:guest,:manager,:sub_manager]
|
available_for [:admin,:guest,:manager,:sub_manager]
|
||||||
active_for_controllers ({:private=>['archive_file_categorys'],:public=>['panel/archive/back_end/tags']})
|
active_for_controllers ({:private=>['archive_file_categorys','archive_files'],:public=>['panel/archive/back_end/tags']})
|
||||||
active_for_object_auth ['BulletinCategory']
|
active_for_object_auth ['BulletinCategory']
|
||||||
|
|
||||||
head_link_path "panel_archive_back_end_archive_files_path"
|
head_link_path "panel_archive_back_end_archive_files_path"
|
||||||
|
@ -36,13 +36,13 @@ module Archive
|
||||||
context_link 'miss_module_i18n._archive.all',
|
context_link 'miss_module_i18n._archive.all',
|
||||||
:link_path=>"panel_archive_back_end_archive_files_path" ,
|
:link_path=>"panel_archive_back_end_archive_files_path" ,
|
||||||
:priority=>1,
|
:priority=>1,
|
||||||
:active_for_action=>{:archive_file=>:index},
|
:active_for_action=>{:archive_files=>:index},
|
||||||
:available_for => [:all]
|
:available_for => [:all]
|
||||||
|
|
||||||
context_link 'add',
|
context_link 'add',
|
||||||
:link_path=>"new_panel_archive_back_end_archive_file_path" ,
|
:link_path=>"new_panel_archive_back_end_archive_file_path" ,
|
||||||
:priority=>2,
|
:priority=>2,
|
||||||
:active_for_action=>{:archive_file=>:new},
|
:active_for_action=>{:archive_files=>:new},
|
||||||
:available_for => [:admin]
|
:available_for => [:admin]
|
||||||
|
|
||||||
context_link 'categories',
|
context_link 'categories',
|
||||||
|
|
|
@ -50,7 +50,7 @@ module Gallery
|
||||||
:available_for => [:manager]
|
:available_for => [:manager]
|
||||||
|
|
||||||
context_link 'module_authorization',
|
context_link 'module_authorization',
|
||||||
:link_path=>"admin_module_app_manager_auth_proc_path(ModuleApp.first(conditions: {key: 'gallery'}))",
|
:link_path=>"admin_module_app_manager_auth_proc_path(ModuleApp.first(conditions: {title: 'Gallery'}))",
|
||||||
:priority=>6,
|
:priority=>6,
|
||||||
:active_for_app_auth => 'gallery',
|
:active_for_app_auth => 'gallery',
|
||||||
:available_for => [:admin]
|
:available_for => [:admin]
|
||||||
|
|
|
@ -24,7 +24,7 @@ module PageContent
|
||||||
head_link_path "panel_page_content_back_end_page_contexts_path"
|
head_link_path "panel_page_content_back_end_page_contexts_path"
|
||||||
|
|
||||||
context_link 'module_authorization',
|
context_link 'module_authorization',
|
||||||
:link_path=>"admin_module_app_manager_auth_proc_path(ModuleApp.first(conditions: {key: 'page_content'}))",
|
:link_path=>"admin_module_app_manager_auth_proc_path(ModuleApp.first(conditions: {title: 'PageContent'}))",
|
||||||
:priority=>1,
|
:priority=>1,
|
||||||
:active_for_app_auth => 'PageContext',
|
:active_for_app_auth => 'PageContext',
|
||||||
:available_for => [:admin]
|
:available_for => [:admin]
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
<ul class="nav nav-pills hide">
|
<ul class="nav nav-pills hide">
|
||||||
<li><%= link_to t(:edit), edit_panel_web_resource_back_end_web_link_category_path(web_link_category), :remote => true %></li>
|
<li><%= link_to t(:edit), edit_panel_web_resource_back_end_web_link_category_path(web_link_category), :remote => true %></li>
|
||||||
<li><%= link_to show_toggle_archive_btn(web_link_category), panel_web_resource_back_end_web_link_category_path(web_link_category), :confirm => t(:sure?), :method => :delete, :remote => true ,:class=> "archive_toggle"%></li>
|
<li><%= link_to show_toggle_archive_btn(web_link_category), panel_web_resource_back_end_web_link_category_path(web_link_category), :confirm => t(:sure?), :method => :delete, :remote => true ,:class=> "archive_toggle"%></li>
|
||||||
<li><%= show_web_link_permission_link web_link_category %></li>
|
<li><%#= show_web_link_permission_link web_link_category %></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
|
|
@ -36,19 +36,19 @@ module WebResource
|
||||||
context_link 'list_',
|
context_link 'list_',
|
||||||
:link_path=>"panel_web_resource_back_end_web_links_path" ,
|
:link_path=>"panel_web_resource_back_end_web_links_path" ,
|
||||||
:priority=>1,
|
:priority=>1,
|
||||||
:active_for_action=>{:bulletins=>:index},
|
:active_for_action=>{:web_links=>:index},
|
||||||
:available_for => [:all]
|
:available_for => [:all]
|
||||||
|
|
||||||
context_link 'link',
|
context_link 'link',
|
||||||
:link_path=>"new_panel_web_resource_back_end_web_link_path" ,
|
:link_path=>"new_panel_web_resource_back_end_web_link_path" ,
|
||||||
:priority=>2,
|
:priority=>2,
|
||||||
:active_for_action=>{:bulletins=>:new},
|
:active_for_action=>{:web_links=>:new},
|
||||||
:available_for => [:sub_manager]
|
:available_for => [:sub_manager]
|
||||||
|
|
||||||
context_link 'categories',
|
context_link 'categories',
|
||||||
:link_path=>"panel_web_resource_back_end_web_link_categorys_path" ,
|
:link_path=>"panel_web_resource_back_end_web_link_categorys_path" ,
|
||||||
:priority=>3,
|
:priority=>3,
|
||||||
:active_for_action=>{:bulletin_categorys=>:index},
|
:active_for_action=>{:web_link_categorys=>:index},
|
||||||
:available_for => [:manager]
|
:available_for => [:manager]
|
||||||
|
|
||||||
context_link 'tags',
|
context_link 'tags',
|
||||||
|
@ -58,7 +58,7 @@ module WebResource
|
||||||
:available_for => [:manager]
|
:available_for => [:manager]
|
||||||
|
|
||||||
context_link 'module_authorization',
|
context_link 'module_authorization',
|
||||||
:link_path=>"admin_module_app_manager_auth_proc_path(ModuleApp.first(conditions: {key: 'web_resource'}))",
|
:link_path=>"admin_module_app_manager_auth_proc_path(ModuleApp.first(conditions: {title: 'WebResource'}))",
|
||||||
:priority=>6,
|
:priority=>6,
|
||||||
:active_for_app_auth => 'web_resource',
|
:active_for_app_auth => 'web_resource',
|
||||||
:available_for => [:admin]
|
:available_for => [:admin]
|
||||||
|
|
Reference in New Issue