43 lines
1.3 KiB
Ruby
43 lines
1.3 KiB
Ruby
|
module SideBarRenderer
|
||
|
include Renderer
|
||
|
include AdminHelper
|
||
|
|
||
|
def render(request,params,user)
|
||
|
@request = request
|
||
|
@params = params
|
||
|
@current_user = user
|
||
|
if display?
|
||
|
content_tag :li, :class => (module_sidebar_active? ? 'active' : nil) do
|
||
|
buf = link_to( content_tag(:i, nil, :class => @icon_class ) + content_tag(:span, I18n.t( @head_label )), eval(@head_link))
|
||
|
buf << content_tag( :ul, :class => ("nav nav-list active") )do # visible_for_controllers('bulletins', '/panel/announcement/back_end/tags', 'bulletin_categorys', 'approvals')||active_for_ob_auths_object("BulletinCategory"))
|
||
|
@context_links.sort_by! {| obj | obj.priority}.collect do |link|
|
||
|
link.render(request,params)
|
||
|
end.join.html_safe
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
|
||
|
protected
|
||
|
|
||
|
def display? #控制sidebar 要不要算圖
|
||
|
if is_manager? || is_admin? #如果是系統管理員 或 是模組管理員
|
||
|
true
|
||
|
elsif (@module_app.open rescue false) # 如果app 被設定成 開放
|
||
|
true
|
||
|
elsif is_member? #如果app 是封閉 那至少需要是 member
|
||
|
true
|
||
|
else
|
||
|
false
|
||
|
end
|
||
|
end
|
||
|
|
||
|
def module_sidebar_active?
|
||
|
active_for_controller? or active_for_app_auth? or active_for_ob_auths?
|
||
|
end
|
||
|
|
||
|
def active_for_controller?
|
||
|
@active_for_controllers.include? controller
|
||
|
end
|
||
|
|
||
|
end
|