-
-
Save edavis10/103506 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def menu_item_class(selected=false) | |
if selected | |
'alt-selected' | |
else | |
'' | |
end | |
end | |
# Renders the global menu as an unordered list | |
# Returns a string containing the HTML for the global menu | |
def render_global_menu | |
returning '' do |menu| | |
menu << "<ul>\n" | |
# Global issues link | |
## Add 'alt-selected'-class to the 'a'-element if on global level (!= :controller == issues && != :action == index && != :project_id == nil) | |
issues_selected = params[:controller] == 'issues' && params[:action] == 'index' && params[:project_id].nil? | |
menu << content_tag(:li, link_to(l(:label_issue_view_all), { :controller => 'issues', :id => nil } :class => menu_item_class(issues_selected))) | |
# Global activity link | |
## Add 'alt-selected'-class to the 'a'-element if on global level (!= :controller == projects && != :action == activity && != :id == nil) | |
activity_selected = params[:controller] == 'projects' && params[:action] == 'activity' && params[:id].nil? | |
menu << content_tag(:li, link_to(l(:label_overall_activity), { :controller => 'projects', :action => 'activity', :id => nil }, :class => menu_item_class(activity_selected))) | |
# Global calendar link | |
## Add 'alt-selected'-class to the 'a'-element if on global level (!= :controller == issues && != :action == calendar && != :project_id == nil) | |
if User.current.allowed_to?(:view_calendar, @project, :global => true) | |
calendar_selected = params[:controller] == 'issues' && params[:action] == 'calendar' && params[:project_id].nil? | |
menu << content_tag(:li, link_to(l(:label_calendar), { :controller => 'issues', :action => 'calendar', :project_id => nil }, :class => menu_item_class(calendar_selected))) | |
end | |
# Global gantt link | |
## Add 'alt-selected'-class to the 'a'-element if on global level (!= :controller == issues && != :action == gantt && != :project_id == nil) | |
if User.current.allowed_to?(:view_gantt, @project, :global => true) | |
gnatt_selected = params[:controller] == 'issues' && params[:action] == 'gantt' && params[:project_id].nil? | |
menu << content_tag(:li, link_to(l(:label_gantt), { :controller => 'issues', :action => 'gantt', :project_id => nil }, :class => menu_item_class(gnatt_selected))) | |
end | |
menu << "</ul>\n" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment