Merge pull request #3114 from NobodysNightmare/feature/remove_reporting_details

remove details on spent time from project overview
pull/3045/merge
Florian Kraft 9 years ago
commit 32a6d8fa8e
  1. 4
      app/controllers/projects_controller.rb
  2. 14
      app/views/projects/show.html.erb
  3. 7
      config/initializers/menus.rb
  4. 6
      lib/redmine/menu_manager/mapper.rb
  5. 6
      lib/redmine/menu_manager/menu_item.rb
  6. 13
      lib/redmine/plugin.rb

@ -117,10 +117,6 @@ class ProjectsController < ApplicationController
include: [:project, :status, :type],
conditions: cond)
if User.current.allowed_to?(:view_time_entries, @project)
@total_hours = TimeEntry.visible.sum(:hours, include: :project, conditions: cond).to_f
end
respond_to do |format|
format.html
end

@ -89,20 +89,6 @@ See doc/COPYRIGHT.rdoc for more details.
</div>
</div>
<% content_for :sidebar do %>
<% if @total_hours.present? %>
<h3><%= l(:label_spent_time) %></h3>
<p><span class="icon5 icon-time"><%= l_hours(@total_hours) %></span></p>
<p>
<%= link_to(l(:label_details), {:controller => '/timelog', :action => 'index', :project_id => @project}) %> |
<%= link_to(l(:label_report), project_time_entries_report_path(@project)) %>
<% if authorize_for('timelog', 'new') %>
| <%= link_to l(:button_log_time), {:controller => '/timelog', :action => 'new', :project_id => @project} %>
<% end %>
</p>
<% end %>
<%= call_hook(:view_projects_show_sidebar_bottom, :project => @project) %>
<% end %>
<% content_for :header_tags do %>
<%= auto_discovery_link_tag(:atom, {:controller => '/activities', :action => 'index', :id => @project, :format => 'atom', :key => User.current.rss_key}) %>
<% end %>

@ -236,6 +236,13 @@ Redmine::MenuManager.map :project_menu do |menu|
if: Proc.new { |p| p.repository && !p.repository.new_record? },
html: { class: 'icon2 icon-open-folder' }
menu.push :time_entries,
{ controller: '/timelog', action: 'index' },
param: :project_id,
if: -> (project) { User.current.allowed_to?(:view_time_entries, project) },
caption: :label_time_sheet_menu,
html: { class: 'icon2 icon-stats' }
menu.push :reportings,
{ controller: '/reportings', action: 'index' },
param: :project_id,

@ -97,6 +97,12 @@ class Redmine::MenuManager::Mapper
end
end
def add_condition(name, condition)
if found = find(name)
found.add_condition(condition)
end
end
# Checks if a menu item exists
def exists?(name)
@menu_items.any? { |node| node.name == name }

@ -75,4 +75,10 @@ class Redmine::MenuManager::MenuItem < Redmine::MenuManager::TreeNode
@html_options
end
end
def add_condition(new_condition)
raise ArgumentError, 'Condition needs to be callable' unless new_condition.respond_to?(:call)
old_condition = @condition
@condition = -> (project) { old_condition.call(project) && new_condition.call(project) }
end
end

@ -263,8 +263,19 @@ module Redmine #:nodoc:
# Removes +item+ from the given +menu+.
def delete_menu_item(menu_name, item)
hide_menu_item(menu_name, item)
end
# N.B.: I could not find any usages of :delete_menu_item in my locally available plugins
deprecate delete_menu_item: 'Use :hide_menu_item instead'
# Allows to hide an existing +item+ in a menu.
#
# +hide_if+ parameter can be a lambda accepting a project, the item will only be hidden if
# the condition evaluates to true.
def hide_menu_item(menu_name, item, hide_if: -> (*) { true })
Redmine::MenuManager.map(menu_name) do |menu|
menu.delete(item)
menu.add_condition(item, -> (project) { !hide_if.call(project) })
end
end

Loading…
Cancel
Save