From 355289fa677f6a9a26e252e640861497a34cada6 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Wed, 5 Dec 2007 19:21:25 +0000 Subject: Roadmap progress bars now differentiate the progress due to closed issues from the open issues progress (2 different colors). git-svn-id: http://redmine.rubyforge.org/svn/trunk@954 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/helpers/application_helper.rb | 10 +++++++--- app/models/version.rb | 8 ++++++++ app/views/projects/roadmap.rhtml | 2 +- 3 files changed, 16 insertions(+), 4 deletions(-) (limited to 'app') diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index f4746c627..37c8b1c9b 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -319,13 +319,17 @@ module ApplicationHelper link_to_function(l(:button_uncheck_all), "checkAll('#{form_name}', false)") end - def progress_bar(pct, options={}) + def progress_bar(pcts, options={}) + pcts = [pcts, pcts] unless pcts.is_a?(Array) + pcts[1] = pcts[1] - pcts[0] + pcts << (100 - pcts[1] - pcts[0]) width = options[:width] || '100px;' legend = options[:legend] || '' content_tag('table', content_tag('tr', - (pct > 0 ? content_tag('td', '', :width => "#{pct.floor}%;", :class => 'closed') : '') + - (pct < 100 ? content_tag('td', '', :width => "#{100-pct.floor}%;", :class => 'open') : '') + (pcts[0] > 0 ? content_tag('td', '', :width => "#{pcts[0].floor}%;", :class => 'closed') : '') + + (pcts[1] > 0 ? content_tag('td', '', :width => "#{pcts[1].floor}%;", :class => 'done') : '') + + (pcts[2] > 0 ? content_tag('td', '', :width => "#{pcts[2].floor}%;", :class => 'todo') : '') ), :class => 'progress', :style => "width: #{width};") + content_tag('p', legend, :class => 'pourcent') end diff --git a/app/models/version.rb b/app/models/version.rb index 0547dbabc..266346c7b 100644 --- a/app/models/version.rb +++ b/app/models/version.rb @@ -49,6 +49,14 @@ class Version < ActiveRecord::Base end end + def closed_pourcent + if fixed_issues.count == 0 + 0 + else + closed_issues_count * 100.0 / fixed_issues.count + end + end + # Returns true if the version is overdue: due date reached and some open issues def overdue? effective_date && (effective_date < Date.today) && (open_issues_count > 0) diff --git a/app/views/projects/roadmap.rhtml b/app/views/projects/roadmap.rhtml index c2f3cbf34..7c3544a53 100644 --- a/app/views/projects/roadmap.rhtml +++ b/app/views/projects/roadmap.rhtml @@ -16,7 +16,7 @@

<%=h version.description %>

<% if version.fixed_issues.count > 0 %> - <%= progress_bar(version.completed_pourcent, :width => '40em', :legend => ('%0.0f%' % version.completed_pourcent)) %> + <%= progress_bar([version.closed_pourcent, version.completed_pourcent], :width => '40em', :legend => ('%0.0f%' % version.completed_pourcent)) %>

<%= link_to(version.closed_issues_count, :controller => 'issues', :action => 'index', :project_id => @project, :status_id => 'c', :fixed_version_id => version, :set_filter => 1) %> <%= lwr(:label_closed_issues, version.closed_issues_count) %> -- cgit v1.2.3