Added version details view accessible from the roadmap.

git-svn-id: http://redmine.rubyforge.org/svn/trunk@955 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2007-12-07 10:26:07 +00:00
parent 355289fa67
commit 3c44aac1f5
31 changed files with 208 additions and 43 deletions

View File

@ -21,6 +21,9 @@ class VersionsController < ApplicationController
cache_sweeper :version_sweeper, :only => [ :edit, :destroy ] cache_sweeper :version_sweeper, :only => [ :edit, :destroy ]
def show
end
def edit def edit
if request.post? and @version.update_attributes(params[:version]) if request.post? and @version.update_attributes(params[:version])
flash[:notice] = l(:notice_successful_update) flash[:notice] = l(:notice_successful_update)
@ -49,6 +52,13 @@ class VersionsController < ApplicationController
flash[:notice] = l(:notice_successful_delete) flash[:notice] = l(:notice_successful_delete)
redirect_to :controller => 'projects', :action => 'list_files', :id => @project redirect_to :controller => 'projects', :action => 'list_files', :id => @project
end end
def status_by
respond_to do |format|
format.html { render :action => 'show' }
format.js { render(:update) {|page| page.replace_html 'status_by', render_issue_status_by(@version, params[:status_by])} }
end
end
private private
def find_project def find_project

View File

@ -16,4 +16,32 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
module VersionsHelper module VersionsHelper
STATUS_BY_CRITERIAS = %w(category tracker priority author assigned_to)
def render_issue_status_by(version, criteria)
criteria ||= 'category'
raise 'Unknown criteria' unless STATUS_BY_CRITERIAS.include?(criteria)
h = Hash.new {|k,v| k[v] = [0, 0]}
begin
# Total issue count
Issue.count(:group => criteria,
:conditions => ["#{Issue.table_name}.fixed_version_id = ?", version.id]).each {|c,s| h[c][0] = s}
# Open issues count
Issue.count(:group => criteria,
:include => :status,
:conditions => ["#{Issue.table_name}.fixed_version_id = ? AND #{IssueStatus.table_name}.is_closed = ?", version.id, false]).each {|c,s| h[c][1] = s}
rescue ActiveRecord::RecordNotFound
# When grouping by an association, Rails throws this exception if there's no result (bug)
end
counts = h.keys.compact.sort.collect {|k| {:group => k, :total => h[k][0], :open => h[k][1], :closed => (h[k][0] - h[k][1])}}
max = counts.collect {|c| c[:total]}.max
render :partial => 'issue_counts', :locals => {:version => version, :criteria => criteria, :counts => counts, :max => max}
end
def status_by_options_for_select(value)
options_for_select(STATUS_BY_CRITERIAS.collect {|criteria| [l("field_#{criteria}".to_sym), criteria]}, value)
end
end end

View File

@ -35,5 +35,9 @@ class IssueCategory < ActiveRecord::Base
destroy_without_reassign destroy_without_reassign
end end
def <=>(category)
name <=> category.name
end
def to_s; name end def to_s; name end
end end

View File

@ -29,6 +29,10 @@ class Tracker < ActiveRecord::Base
def to_s; name end def to_s; name end
def <=>(tracker)
name <=> tracker.name
end
def self.all def self.all
find(:all, :order => 'position') find(:all, :order => 'position')
end end

View File

@ -5,48 +5,28 @@
<% end %> <% end %>
<% @versions.each do |version| %> <% @versions.each do |version| %>
<a name="<%= version.name %>"><h3 class="icon22 icon22-package"><%= version.name %></h3></a> <%= tag 'a', :name => version.name %>
<% if version.completed? %> <h3 class="icon22 icon22-package"><%= link_to h(version.name), :controller => 'versions', :action => 'show', :id => version %></h3>
<p><%= format_date(version.effective_date) %></p> <%= render :partial => 'versions/overview', :locals => {:version => version} %>
<% elsif version.overdue? %> <%= render(:partial => "wiki/content", :locals => {:content => version.wiki_page.content}) if version.wiki_page %>
<p><strong><%= l(:label_roadmap_overdue, distance_of_time_in_words(Time.now, version.effective_date)) %> (<%= format_date(version.effective_date) %>)</strong></p>
<% elsif version.effective_date %> <% issues = version.fixed_issues.find(:all,
<p><strong><%=l(:label_roadmap_due_in)%> <%= distance_of_time_in_words Time.now, version.effective_date %> (<%= format_date(version.effective_date) %>)</strong></p> :include => [:status, :tracker],
<% end %> :conditions => ["tracker_id in (#{@selected_tracker_ids.join(',')})"],
<p><%=h version.description %></p> :order => "#{Tracker.table_name}.position") unless @selected_tracker_ids.empty?
issues ||= []
<% if version.fixed_issues.count > 0 %> %>
<%= progress_bar([version.closed_pourcent, version.completed_pourcent], :width => '40em', :legend => ('%0.0f%' % version.completed_pourcent)) %> <ul>
<p class="progress-info"> <% if issues.size > 0 %>
<%= link_to(version.closed_issues_count, :controller => 'issues', :action => 'index', :project_id => @project, :status_id => 'c', :fixed_version_id => version, :set_filter => 1) %> <% issues.each do |issue| %>
<%= lwr(:label_closed_issues, version.closed_issues_count) %> <li>
(<%= '%0.0f' % (version.closed_issues_count.to_f / version.fixed_issues.count * 100) %>%) <%= link = link_to_issue(issue)
&#160; issue.status.is_closed? ? content_tag("del", link) : link %>: <%=h issue.subject %>
<%= link_to(version.open_issues_count, :controller => 'issues', :action => 'index', :project_id => @project, :status_id => 'o', :fixed_version_id => version, :set_filter => 1) %> <%= content_tag "em", "(#{l(:label_closed_issues)})" if issue.status.is_closed? %>
<%= lwr(:label_open_issues, version.open_issues_count)%> </li>
(<%= '%0.0f' % (version.open_issues_count.to_f / version.fixed_issues.count * 100) %>%) <% end %>
</p> <% end %>
<%= render(:partial => "wiki/content", :locals => {:content => version.wiki_page.content}) if version.wiki_page %> </ul>
<% issues = version.fixed_issues.find(:all,
:include => [:status, :tracker],
:conditions => ["tracker_id in (#{@selected_tracker_ids.join(',')})"],
:order => "#{Tracker.table_name}.position") unless @selected_tracker_ids.empty?
issues ||= []
%>
<ul>
<% if issues.size > 0 %>
<% issues.each do |issue| %>
<li>
<%= link = link_to_issue(issue)
issue.status.is_closed? ? content_tag("del", link) : link %>: <%=h issue.subject %>
<%= content_tag "em", "(#{l(:label_closed_issues)})" if issue.status.is_closed? %>
</li>
<% end %>
<% end %>
</ul>
<% else %>
<p><em><%= l(:label_roadmap_no_issues) %></em></p>
<% end %>
<% end %> <% end %>
<% content_for :sidebar do %> <% content_for :sidebar do %>
@ -66,3 +46,5 @@
<%= link_to version.name, :anchor => version.name %><br /> <%= link_to version.name, :anchor => version.name %><br />
<% end %> <% end %>
<% end %> <% end %>
<% set_html_title l(:label_roadmap) %>

View File

@ -11,7 +11,7 @@
<tbody> <tbody>
<% for version in @project.versions.sort %> <% for version in @project.versions.sort %>
<tr class="<%= cycle 'odd', 'even' %>"> <tr class="<%= cycle 'odd', 'even' %>">
<td><%=h version.name %></td> <td><%= link_to h(version.name), :controller => 'versions', :action => 'show', :id => version %></td>
<td align="center"><%= format_date(version.effective_date) %></td> <td align="center"><%= format_date(version.effective_date) %></td>
<td><%=h version.description %></td> <td><%=h version.description %></td>
<td><%= link_to(version.wiki_page_title, :controller => 'wiki', :page => Wiki.titleize(version.wiki_page_title)) unless version.wiki_page_title.blank? || @project.wiki.nil? %></td> <td><%= link_to(version.wiki_page_title, :controller => 'wiki', :page => Wiki.titleize(version.wiki_page_title)) unless version.wiki_page_title.blank? || @project.wiki.nil? %></td>

View File

@ -0,0 +1,35 @@
<form id="status_by_form">
<fieldset>
<legend>
<%= l(:label_issues_by,
select_tag('status_by',
status_by_options_for_select(criteria),
:id => 'status_by_select',
:onchange => remote_function(:url => { :action => :status_by, :id => version },
:with => "Form.serialize('status_by_form')"))) %>
</legend>
<% if counts.empty? %>
<p><em><%= l(:label_no_data) %></em></p>
<% else %>
<table>
<% counts.each do |count| %>
<tr>
<td width="130px" align="right" >
<%= link_to count[:group], {:controller => 'issues',
:action => 'index',
:project_id => version.project,
:set_filter => 1,
:fixed_version_id => version,
"#{criteria}_id" => count[:group]} %>
</td>
<td width="240px">
<%= progress_bar((count[:closed].to_f / count[:total])*100,
:legend => "#{count[:closed]}/#{count[:total]}",
:width => "#{(count[:total].to_f / max * 200).floor}px;") %>
</td>
</tr>
<% end %>
</table>
<% end %>
</fieldset>
</form>

View File

@ -0,0 +1,24 @@
<% if version.completed? %>
<p><%= format_date(version.effective_date) %></p>
<% elsif version.overdue? %>
<p><strong><%= l(:label_roadmap_overdue, distance_of_time_in_words(Time.now, version.effective_date)) %> (<%= format_date(version.effective_date) %>)</strong></p>
<% elsif version.effective_date %>
<p><strong><%=l(:label_roadmap_due_in)%> <%= distance_of_time_in_words Time.now, version.effective_date %> (<%= format_date(version.effective_date) %>)</strong></p>
<% end %>
<p><%=h version.description %></p>
<% if version.fixed_issues.count > 0 %>
<%= progress_bar([version.closed_pourcent, version.completed_pourcent], :width => '40em', :legend => ('%0.0f%' % version.completed_pourcent)) %>
<p class="progress-info">
<%= link_to(version.closed_issues_count, :controller => 'issues', :action => 'index', :project_id => version.project, :status_id => 'c', :fixed_version_id => version, :set_filter => 1) %>
<%= lwr(:label_closed_issues, version.closed_issues_count) %>
(<%= '%0.0f' % (version.closed_issues_count.to_f / version.fixed_issues.count * 100) %>%)
&#160;
<%= link_to(version.open_issues_count, :controller => 'issues', :action => 'index', :project_id => version.project, :status_id => 'o', :fixed_version_id => version, :set_filter => 1) %>
<%= lwr(:label_open_issues, version.open_issues_count)%>
(<%= '%0.0f' % (version.open_issues_count.to_f / version.fixed_issues.count * 100) %>%)
</p>
<% else %>
<p><em><%= l(:label_roadmap_no_issues) %></em></p>
<% end %>

View File

@ -0,0 +1,14 @@
<div class="contextual">
<%= link_to_if_authorized l(:button_edit), {:controller => 'versions', :action => 'edit', :id => @version}, :class => 'icon icon-edit' %>
</div>
<h2><%= h(@version.name) %></h2>
<div id="status_by" style="float:right;">
<%= render_issue_status_by(@version, params[:status_by]) if @version.fixed_issues.count > 0 %>
</div>
<%= render :partial => 'versions/overview', :locals => {:version => @version} %>
<%= render(:partial => "wiki/content", :locals => {:content => @version.wiki_page.content}) if @version.wiki_page %>
<% set_html_title h(@version.name) %>

View File

@ -548,3 +548,4 @@ field_time_zone: Time zone
text_caracters_minimum: Must be at least %d characters long. text_caracters_minimum: Must be at least %d characters long.
setting_bcc_recipients: Blind carbon copy recipients (bcc) setting_bcc_recipients: Blind carbon copy recipients (bcc)
button_annotate: Annotate button_annotate: Annotate
label_issues_by: Issues by %s

View File

@ -548,3 +548,4 @@ field_time_zone: Time zone
text_caracters_minimum: Must be at least %d characters long. text_caracters_minimum: Must be at least %d characters long.
setting_bcc_recipients: Blind carbon copy recipients (bcc) setting_bcc_recipients: Blind carbon copy recipients (bcc)
button_annotate: Annotate button_annotate: Annotate
label_issues_by: Issues by %s

View File

@ -548,3 +548,4 @@ field_time_zone: Zeitzone
text_caracters_minimum: Muss mindestens %d Zeichen lang sein. text_caracters_minimum: Muss mindestens %d Zeichen lang sein.
setting_bcc_recipients: Blind carbon copy recipients (bcc) setting_bcc_recipients: Blind carbon copy recipients (bcc)
button_annotate: Annotate button_annotate: Annotate
label_issues_by: Issues by %s

View File

@ -210,6 +210,7 @@ label_issue: Issue
label_issue_new: New issue label_issue_new: New issue
label_issue_plural: Issues label_issue_plural: Issues
label_issue_view_all: View all issues label_issue_view_all: View all issues
label_issues_by: Issues by %s
label_document: Document label_document: Document
label_document_new: New document label_document_new: New document
label_document_plural: Documents label_document_plural: Documents

View File

@ -551,3 +551,4 @@ notice_account_pending: "Su cuenta ha sido creada y está pendiende de la aproba
setting_time_format: Formato de hora setting_time_format: Formato de hora
setting_bcc_recipients: Blind carbon copy recipients (bcc) setting_bcc_recipients: Blind carbon copy recipients (bcc)
button_annotate: Annotate button_annotate: Annotate
label_issues_by: Issues by %s

View File

@ -210,6 +210,7 @@ label_issue: Demande
label_issue_new: Nouvelle demande label_issue_new: Nouvelle demande
label_issue_plural: Demandes label_issue_plural: Demandes
label_issue_view_all: Voir toutes les demandes label_issue_view_all: Voir toutes les demandes
label_issues_by: Demandes par %s
label_document: Document label_document: Document
label_document_new: Nouveau document label_document_new: Nouveau document
label_document_plural: Documents label_document_plural: Documents

View File

@ -548,3 +548,4 @@ field_time_zone: Time zone
text_caracters_minimum: Must be at least %d characters long. text_caracters_minimum: Must be at least %d characters long.
setting_bcc_recipients: Blind carbon copy recipients (bcc) setting_bcc_recipients: Blind carbon copy recipients (bcc)
button_annotate: Annotate button_annotate: Annotate
label_issues_by: Issues by %s

View File

@ -548,3 +548,4 @@ field_time_zone: Time zone
text_caracters_minimum: Must be at least %d characters long. text_caracters_minimum: Must be at least %d characters long.
setting_bcc_recipients: Blind carbon copy recipients (bcc) setting_bcc_recipients: Blind carbon copy recipients (bcc)
button_annotate: Annotate button_annotate: Annotate
label_issues_by: Issues by %s

View File

@ -549,3 +549,4 @@ field_time_zone: Time zone
text_caracters_minimum: Must be at least %d characters long. text_caracters_minimum: Must be at least %d characters long.
setting_bcc_recipients: Blind carbon copy recipients (bcc) setting_bcc_recipients: Blind carbon copy recipients (bcc)
button_annotate: Annotate button_annotate: Annotate
label_issues_by: Issues by %s

View File

@ -548,3 +548,4 @@ field_time_zone: Time zone
text_caracters_minimum: Must be at least %d characters long. text_caracters_minimum: Must be at least %d characters long.
setting_bcc_recipients: Blind carbon copy recipients (bcc) setting_bcc_recipients: Blind carbon copy recipients (bcc)
button_annotate: Annotate button_annotate: Annotate
label_issues_by: Issues by %s

View File

@ -549,3 +549,4 @@ field_time_zone: Time zone
text_caracters_minimum: Must be at least %d characters long. text_caracters_minimum: Must be at least %d characters long.
setting_bcc_recipients: Blind carbon copy recipients (bcc) setting_bcc_recipients: Blind carbon copy recipients (bcc)
button_annotate: Annotate button_annotate: Annotate
label_issues_by: Issues by %s

View File

@ -548,3 +548,4 @@ field_time_zone: Strefa czasowa
text_caracters_minimum: Must be at least %d characters long. text_caracters_minimum: Must be at least %d characters long.
setting_bcc_recipients: Blind carbon copy recipients (bcc) setting_bcc_recipients: Blind carbon copy recipients (bcc)
button_annotate: Annotate button_annotate: Annotate
label_issues_by: Issues by %s

View File

@ -548,3 +548,4 @@ field_time_zone: Time zone
text_caracters_minimum: Must be at least %d characters long. text_caracters_minimum: Must be at least %d characters long.
setting_bcc_recipients: Blind carbon copy recipients (bcc) setting_bcc_recipients: Blind carbon copy recipients (bcc)
button_annotate: Annotate button_annotate: Annotate
label_issues_by: Issues by %s

View File

@ -548,3 +548,4 @@ field_time_zone: Time zone
text_caracters_minimum: Must be at least %d characters long. text_caracters_minimum: Must be at least %d characters long.
setting_bcc_recipients: Blind carbon copy recipients (bcc) setting_bcc_recipients: Blind carbon copy recipients (bcc)
button_annotate: Annotate button_annotate: Annotate
label_issues_by: Issues by %s

View File

@ -548,3 +548,4 @@ field_time_zone: Time zone
text_caracters_minimum: Must be at least %d characters long. text_caracters_minimum: Must be at least %d characters long.
setting_bcc_recipients: Blind carbon copy recipients (bcc) setting_bcc_recipients: Blind carbon copy recipients (bcc)
button_annotate: Annotate button_annotate: Annotate
label_issues_by: Issues by %s

View File

@ -548,3 +548,4 @@ field_time_zone: Часовой пояс
text_caracters_minimum: Must be at least %d characters long. text_caracters_minimum: Must be at least %d characters long.
setting_bcc_recipients: Blind carbon copy recipients (bcc) setting_bcc_recipients: Blind carbon copy recipients (bcc)
button_annotate: Annotate button_annotate: Annotate
label_issues_by: Issues by %s

View File

@ -549,3 +549,4 @@ field_time_zone: Time zone
text_caracters_minimum: Must be at least %d characters long. text_caracters_minimum: Must be at least %d characters long.
setting_bcc_recipients: Blind carbon copy recipients (bcc) setting_bcc_recipients: Blind carbon copy recipients (bcc)
button_annotate: Annotate button_annotate: Annotate
label_issues_by: Issues by %s

View File

@ -549,3 +549,4 @@ field_time_zone: Time zone
text_caracters_minimum: Must be at least %d characters long. text_caracters_minimum: Must be at least %d characters long.
setting_bcc_recipients: Blind carbon copy recipients (bcc) setting_bcc_recipients: Blind carbon copy recipients (bcc)
button_annotate: Annotate button_annotate: Annotate
label_issues_by: Issues by %s

View File

@ -551,3 +551,4 @@ field_time_zone: Time zone
text_caracters_minimum: Must be at least %d characters long. text_caracters_minimum: Must be at least %d characters long.
setting_bcc_recipients: Blind carbon copy recipients (bcc) setting_bcc_recipients: Blind carbon copy recipients (bcc)
button_annotate: Annotate button_annotate: Annotate
label_issues_by: Issues by %s

View File

@ -27,6 +27,7 @@ Redmine::AccessControl.map do |map|
# Issues # Issues
map.permission :view_issues, {:projects => [:changelog, :roadmap], map.permission :view_issues, {:projects => [:changelog, :roadmap],
:issues => [:index, :changes, :show, :context_menu], :issues => [:index, :changes, :show, :context_menu],
:versions => [:show, :status_by],
:queries => :index, :queries => :index,
:reports => :issue_report}, :public => true :reports => :issue_report}, :public => true
map.permission :add_issues, {:projects => :add_issue} map.permission :add_issues, {:projects => :add_issue}

View File

@ -267,6 +267,8 @@ table.progress td.open { background: #FFF none repeat scroll 0%; }
p.pourcent {font-size: 80%;} p.pourcent {font-size: 80%;}
p.progress-info {clear: left; font-style: italic; font-size: 80%;} p.progress-info {clear: left; font-style: italic; font-size: 80%;}
div#status_by { margin-left: 16px; margin-bottom: 16px; }
/***** Tabs *****/ /***** Tabs *****/
#content .tabs{height: 2.6em;} #content .tabs{height: 2.6em;}
#content .tabs ul{margin:0;} #content .tabs ul{margin:0;}

View File

@ -0,0 +1,42 @@
# redMine - project management software
# Copyright (C) 2006-2007 Jean-Philippe Lang
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require File.dirname(__FILE__) + '/../test_helper'
require 'versions_controller'
# Re-raise errors caught by the controller.
class VersionsController; def rescue_action(e) raise e end; end
class VersionsControllerTest < Test::Unit::TestCase
fixtures :projects, :versions, :users, :roles, :members, :enabled_modules
def setup
@controller = VersionsController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
User.current = nil
end
def test_show
get :show, :id => 2
assert_response :success
assert_template 'show'
assert_not_nil assigns(:version)
assert_tag :tag => 'h2', :content => /1.0/
end
end