Bladeren bron

Pluggable admin menu (patch #2031 by Yuki Sonoda with slight changes).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2022 e93f8b46-1217-0410-a6f0-8f06a7374b81
tags/0.8.0-RC1
Jean-Philippe Lang 15 jaren geleden
bovenliggende
commit
d771847078
3 gewijzigde bestanden met toevoegingen van 25 en 3 verwijderingen
  1. 6
    0
      app/views/admin/index.rhtml
  2. 4
    0
      lib/redmine.rb
  3. 15
    3
      lib/redmine/menu_manager.rb

+ 6
- 0
app/views/admin/index.rhtml Bestand weergeven

<%= link_to l(:label_settings), :controller => 'settings' %> <%= link_to l(:label_settings), :controller => 'settings' %>
</p> </p>


<% menu_items_for(:admin_menu) do |item, caption, url, selected| -%>
<%= content_tag 'p',
link_to(h(caption), item.url, item.html_options),
:class => ["icon22", "icon22-#{item.name}"].join(' ') %>
<% end -%>

<p class="icon22 icon22-info"> <p class="icon22 icon22-info">
<%= link_to l(:label_information_plural), :controller => 'admin', :action => 'info' %> <%= link_to l(:label_information_plural), :controller => 'admin', :action => 'info' %>
</p> </p>

+ 4
- 0
lib/redmine.rb Bestand weergeven

# Empty # Empty
end end


Redmine::MenuManager.map :admin_menu do |menu|
# Empty
end

Redmine::MenuManager.map :project_menu do |menu| Redmine::MenuManager.map :project_menu do |menu|
menu.push :overview, { :controller => 'projects', :action => 'show' } menu.push :overview, { :controller => 'projects', :action => 'show' }
menu.push :activity, { :controller => 'projects', :action => 'activity' } menu.push :activity, { :controller => 'projects', :action => 'activity' }

+ 15
- 3
lib/redmine/menu_manager.rb Bestand weergeven

def render_menu(menu, project=nil) def render_menu(menu, project=nil)
links = [] links = []
menu_items_for(menu, project) do |item, caption, url, selected|
links << content_tag('li',
link_to(h(caption), url, (selected ? item.html_options.merge(:class => 'selected') : item.html_options)))
end
links.empty? ? nil : content_tag('ul', links.join("\n"))
end

def menu_items_for(menu, project=nil)
items = []
Redmine::MenuManager.allowed_items(menu, User.current, project).each do |item| Redmine::MenuManager.allowed_items(menu, User.current, project).each do |item|
unless item.condition && !item.condition.call(project) unless item.condition && !item.condition.call(project)
url = case item.url url = case item.url
end end
caption = item.caption(project) caption = item.caption(project)
caption = l(caption) if caption.is_a?(Symbol) caption = l(caption) if caption.is_a?(Symbol)
links << content_tag('li',
link_to(h(caption), url, (current_menu_item == item.name ? item.html_options.merge(:class => 'selected') : item.html_options)))
if block_given?
yield item, caption, url, (current_menu_item == item.name)
else
items << [item, caption, url, (current_menu_item == item.name)]
end
end end
end end
links.empty? ? nil : content_tag('ul', links.join("\n"))
return block_given? ? nil : items
end end
end end

Laden…
Annuleren
Opslaan