@@ -1,159 +1,159 | |||
|
1 | 1 | # redMine - project management software |
|
2 | 2 | # Copyright (C) 2006 Jean-Philippe Lang |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
|
6 | 6 | # as published by the Free Software Foundation; either version 2 |
|
7 | 7 | # of the License, or (at your option) any later version. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU General Public License |
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | class VersionsController < ApplicationController |
|
19 | 19 | menu_item :roadmap |
|
20 | 20 | model_object Version |
|
21 | 21 | before_filter :find_model_object, :except => [:index, :new, :create, :close_completed] |
|
22 | 22 | before_filter :find_project_from_association, :except => [:index, :new, :create, :close_completed] |
|
23 | 23 | before_filter :find_project, :only => [:index, :new, :create, :close_completed] |
|
24 | 24 | before_filter :authorize |
|
25 | 25 | |
|
26 | 26 | helper :custom_fields |
|
27 | 27 | helper :projects |
|
28 | 28 | |
|
29 | 29 | def index |
|
30 | 30 | @trackers = @project.trackers.find(:all, :order => 'position') |
|
31 | 31 | retrieve_selected_tracker_ids(@trackers, @trackers.select {|t| t.is_in_roadmap?}) |
|
32 | 32 | @with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1') |
|
33 | 33 | project_ids = @with_subprojects ? @project.self_and_descendants.collect(&:id) : [@project.id] |
|
34 | 34 | |
|
35 | 35 | @versions = @project.shared_versions || [] |
|
36 | 36 | @versions += @project.rolled_up_versions.visible if @with_subprojects |
|
37 | 37 | @versions = @versions.uniq.sort |
|
38 | 38 | @versions.reject! {|version| version.closed? || version.completed? } unless params[:completed] |
|
39 | 39 | |
|
40 | 40 | @issues_by_version = {} |
|
41 | 41 | unless @selected_tracker_ids.empty? |
|
42 | 42 | @versions.each do |version| |
|
43 | 43 | issues = version.fixed_issues.visible.find(:all, |
|
44 | 44 | :include => [:project, :status, :tracker, :priority], |
|
45 | 45 | :conditions => {:tracker_id => @selected_tracker_ids, :project_id => project_ids}, |
|
46 | 46 | :order => "#{Project.table_name}.lft, #{Tracker.table_name}.position, #{Issue.table_name}.id") |
|
47 | 47 | @issues_by_version[version] = issues |
|
48 | 48 | end |
|
49 | 49 | end |
|
50 | 50 | @versions.reject! {|version| !project_ids.include?(version.project_id) && @issues_by_version[version].blank?} |
|
51 | 51 | end |
|
52 | 52 | |
|
53 | 53 | def show |
|
54 | 54 | @issues = @version.fixed_issues.visible.find(:all, |
|
55 | 55 | :include => [:status, :tracker, :priority], |
|
56 | 56 | :order => "#{Tracker.table_name}.position, #{Issue.table_name}.id") |
|
57 | 57 | end |
|
58 | 58 | |
|
59 | 59 | def new |
|
60 | 60 | @version = @project.versions.build |
|
61 | 61 | if params[:version] |
|
62 | 62 | attributes = params[:version].dup |
|
63 | 63 | attributes.delete('sharing') unless attributes.nil? || @version.allowed_sharings.include?(attributes['sharing']) |
|
64 | 64 | @version.attributes = attributes |
|
65 | 65 | end |
|
66 | 66 | end |
|
67 | 67 | |
|
68 | 68 | def create |
|
69 | 69 | # TODO: refactor with code above in #new |
|
70 | 70 | @version = @project.versions.build |
|
71 | 71 | if params[:version] |
|
72 | 72 | attributes = params[:version].dup |
|
73 | 73 | attributes.delete('sharing') unless attributes.nil? || @version.allowed_sharings.include?(attributes['sharing']) |
|
74 | 74 | @version.attributes = attributes |
|
75 | 75 | end |
|
76 | 76 | |
|
77 | 77 | if request.post? |
|
78 | 78 | if @version.save |
|
79 | 79 | respond_to do |format| |
|
80 | 80 | format.html do |
|
81 | 81 | flash[:notice] = l(:notice_successful_create) |
|
82 |
redirect_t |
|
|
82 | redirect_back_or_default :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project | |
|
83 | 83 | end |
|
84 | 84 | format.js do |
|
85 | 85 | # IE doesn't support the replace_html rjs method for select box options |
|
86 | 86 | render(:update) {|page| page.replace "issue_fixed_version_id", |
|
87 | 87 | content_tag('select', '<option></option>' + version_options_for_select(@project.shared_versions.open, @version), :id => 'issue_fixed_version_id', :name => 'issue[fixed_version_id]') |
|
88 | 88 | } |
|
89 | 89 | end |
|
90 | 90 | end |
|
91 | 91 | else |
|
92 | 92 | respond_to do |format| |
|
93 | 93 | format.html { render :action => 'new' } |
|
94 | 94 | format.js do |
|
95 | 95 | render(:update) {|page| page.alert(@version.errors.full_messages.join('\n')) } |
|
96 | 96 | end |
|
97 | 97 | end |
|
98 | 98 | end |
|
99 | 99 | end |
|
100 | 100 | end |
|
101 | 101 | |
|
102 | 102 | def edit |
|
103 | 103 | end |
|
104 | 104 | |
|
105 | 105 | def update |
|
106 | 106 | if request.put? && params[:version] |
|
107 | 107 | attributes = params[:version].dup |
|
108 | 108 | attributes.delete('sharing') unless @version.allowed_sharings.include?(attributes['sharing']) |
|
109 | 109 | if @version.update_attributes(attributes) |
|
110 | 110 | flash[:notice] = l(:notice_successful_update) |
|
111 |
redirect_t |
|
|
111 | redirect_back_or_default :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project | |
|
112 | 112 | else |
|
113 | 113 | respond_to do |format| |
|
114 | 114 | format.html { render :action => 'edit' } |
|
115 | 115 | end |
|
116 | 116 | end |
|
117 | 117 | end |
|
118 | 118 | end |
|
119 | 119 | |
|
120 | 120 | def close_completed |
|
121 | 121 | if request.put? |
|
122 | 122 | @project.close_completed_versions |
|
123 | 123 | end |
|
124 | 124 | redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project |
|
125 | 125 | end |
|
126 | 126 | |
|
127 | 127 | def destroy |
|
128 | 128 | if @version.fixed_issues.empty? |
|
129 | 129 | @version.destroy |
|
130 |
redirect_t |
|
|
130 | redirect_back_or_default :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project | |
|
131 | 131 | else |
|
132 | 132 | flash[:error] = l(:notice_unable_delete_version) |
|
133 | 133 | redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project |
|
134 | 134 | end |
|
135 | 135 | end |
|
136 | 136 | |
|
137 | 137 | def status_by |
|
138 | 138 | respond_to do |format| |
|
139 | 139 | format.html { render :action => 'show' } |
|
140 | 140 | format.js { render(:update) {|page| page.replace_html 'status_by', render_issue_status_by(@version, params[:status_by])} } |
|
141 | 141 | end |
|
142 | 142 | end |
|
143 | 143 | |
|
144 | 144 | private |
|
145 | 145 | def find_project |
|
146 | 146 | @project = Project.find(params[:project_id]) |
|
147 | 147 | rescue ActiveRecord::RecordNotFound |
|
148 | 148 | render_404 |
|
149 | 149 | end |
|
150 | 150 | |
|
151 | 151 | def retrieve_selected_tracker_ids(selectable_trackers, default_trackers=nil) |
|
152 | 152 | if ids = params[:tracker_ids] |
|
153 | 153 | @selected_tracker_ids = (ids.is_a? Array) ? ids.collect { |id| id.to_i.to_s } : ids.split('/').collect { |id| id.to_i.to_s } |
|
154 | 154 | else |
|
155 | 155 | @selected_tracker_ids = (default_trackers || selectable_trackers).collect {|t| t.id.to_s } |
|
156 | 156 | end |
|
157 | 157 | end |
|
158 | 158 | |
|
159 | 159 | end |
@@ -1,15 +1,16 | |||
|
1 | <%= back_url_hidden_field_tag %> | |
|
1 | 2 | <%= error_messages_for 'version' %> |
|
2 | 3 | |
|
3 | 4 | <div class="box"> |
|
4 | 5 | <p><%= f.text_field :name, :size => 60, :required => true %></p> |
|
5 | 6 | <p><%= f.text_field :description, :size => 60 %></p> |
|
6 | 7 | <p><%= f.select :status, Version::VERSION_STATUSES.collect {|s| [l("version_status_#{s}"), s]} %></p> |
|
7 | 8 | <p><%= f.text_field :wiki_page_title, :label => :label_wiki_page, :size => 60, :disabled => @project.wiki.nil? %></p> |
|
8 | 9 | <p><%= f.text_field :effective_date, :size => 10 %><%= calendar_for('version_effective_date') %></p> |
|
9 | 10 | <p><%= f.select :sharing, @version.allowed_sharings.collect {|v| [format_version_sharing(v), v]} %></p> |
|
10 | 11 | |
|
11 | 12 | <% @version.custom_field_values.each do |value| %> |
|
12 | 13 | <p><%= custom_field_tag_with_label :version, value %></p> |
|
13 | 14 | <% end %> |
|
14 | 15 | |
|
15 | 16 | </div> |
@@ -1,54 +1,58 | |||
|
1 | <div class="contextual"> | |
|
2 | <%= link_to l(:label_version_new), {:controller => 'versions', :action => 'new'}, :class => 'icon icon-add' if User.current.allowed_to?(:manage_versions, @project) %> | |
|
3 | </div> | |
|
4 | ||
|
1 | 5 | <h2><%=l(:label_roadmap)%></h2> |
|
2 | 6 | |
|
3 | 7 | <% if @versions.empty? %> |
|
4 | 8 | <p class="nodata"><%= l(:label_no_data) %></p> |
|
5 | 9 | <% else %> |
|
6 | 10 | <div id="roadmap"> |
|
7 | 11 | <% @versions.each do |version| %> |
|
8 | 12 | <h3 class="version"><%= tag 'a', :name => version.name %><%= link_to_version version %></h3> |
|
9 | 13 | <%= render :partial => 'versions/overview', :locals => {:version => version} %> |
|
10 | 14 | <%= render(:partial => "wiki/content", :locals => {:content => version.wiki_page.content}) if version.wiki_page %> |
|
11 | 15 | |
|
12 | 16 | <% if (issues = @issues_by_version[version]) && issues.size > 0 %> |
|
13 | 17 | <% form_tag({}) do -%> |
|
14 | 18 | <table class="list related-issues"> |
|
15 | 19 | <caption><%= l(:label_related_issues) %></caption> |
|
16 | 20 | <%- issues.each do |issue| -%> |
|
17 | 21 | <tr class="hascontextmenu"> |
|
18 | 22 | <td class="checkbox"><%= check_box_tag 'ids[]', issue.id %></td> |
|
19 | 23 | <td><%= link_to_issue(issue, :project => (@project != issue.project)) %></td> |
|
20 | 24 | </tr> |
|
21 | 25 | <%- end -%> |
|
22 | 26 | </table> |
|
23 | 27 | <% end %> |
|
24 | 28 | <% end %> |
|
25 | 29 | <%= call_hook :view_projects_roadmap_version_bottom, :version => version %> |
|
26 | 30 | <% end %> |
|
27 | 31 | </div> |
|
28 | 32 | <% end %> |
|
29 | 33 | |
|
30 | 34 | <% content_for :sidebar do %> |
|
31 | 35 | <% form_tag({}, :method => :get) do %> |
|
32 | 36 | <h3><%= l(:label_roadmap) %></h3> |
|
33 | 37 | <% @trackers.each do |tracker| %> |
|
34 | 38 | <label><%= check_box_tag "tracker_ids[]", tracker.id, (@selected_tracker_ids.include? tracker.id.to_s), :id => nil %> |
|
35 | 39 | <%=h tracker.name %></label><br /> |
|
36 | 40 | <% end %> |
|
37 | 41 | <br /> |
|
38 | 42 | <label for="completed"><%= check_box_tag "completed", 1, params[:completed] %> <%= l(:label_show_completed_versions) %></label> |
|
39 | 43 | <% if @project.descendants.active.any? %> |
|
40 | 44 | <%= hidden_field_tag 'with_subprojects', 0 %> |
|
41 | 45 | <br /><label><%= check_box_tag 'with_subprojects', 1, @with_subprojects %> <%=l(:label_subproject_plural)%></label> |
|
42 | 46 | <% end %> |
|
43 | 47 | <p><%= submit_tag l(:button_apply), :class => 'button-small', :name => nil %></p> |
|
44 | 48 | <% end %> |
|
45 | 49 | |
|
46 | 50 | <h3><%= l(:label_version_plural) %></h3> |
|
47 | 51 | <% @versions.each do |version| %> |
|
48 | 52 | <%= link_to format_version_name(version), "##{version.name}" %><br /> |
|
49 | 53 | <% end %> |
|
50 | 54 | <% end %> |
|
51 | 55 | |
|
52 | 56 | <% html_title(l(:label_roadmap)) %> |
|
53 | 57 | |
|
54 | 58 | <%= context_menu issues_context_menu_path %> |
@@ -1,54 +1,56 | |||
|
1 | 1 | <div class="contextual"> |
|
2 | 2 | <%= link_to_if_authorized l(:button_edit), {:controller => 'versions', :action => 'edit', :id => @version}, :class => 'icon icon-edit' %> |
|
3 | 3 | <%= link_to_if_authorized(l(:button_edit_associated_wikipage, :page_title => @version.wiki_page_title), {:controller => 'wiki', :action => 'edit', :project_id => @version.project, :id => Wiki.titleize(@version.wiki_page_title)}, :class => 'icon icon-edit') unless @version.wiki_page_title.blank? || @version.project.wiki.nil? %> |
|
4 | <%= link_to_if_authorized l(:button_delete), {:controller => 'versions', :action => 'destroy', :id => @version, :back_url => url_for(:controller => 'versions', :action => 'index', :project_id => @version.project)}, | |
|
5 | :confirm => l(:text_are_you_sure), :method => :delete, :class => 'icon icon-del' %> | |
|
4 | 6 | <%= call_hook(:view_versions_show_contextual, { :version => @version, :project => @project }) %> |
|
5 | 7 | </div> |
|
6 | 8 | |
|
7 | 9 | <h2><%= h(@version.name) %></h2> |
|
8 | 10 | |
|
9 | 11 | <div id="roadmap"> |
|
10 | 12 | <%= render :partial => 'versions/overview', :locals => {:version => @version} %> |
|
11 | 13 | <%= render(:partial => "wiki/content", :locals => {:content => @version.wiki_page.content}) if @version.wiki_page %> |
|
12 | 14 | |
|
13 | 15 | <div id="version-summary"> |
|
14 | 16 | <% if @version.estimated_hours > 0 || User.current.allowed_to?(:view_time_entries, @project) %> |
|
15 | 17 | <fieldset><legend><%= l(:label_time_tracking) %></legend> |
|
16 | 18 | <table> |
|
17 | 19 | <tr> |
|
18 | 20 | <td width="130px" align="right"><%= l(:field_estimated_hours) %></td> |
|
19 | 21 | <td width="240px" class="total-hours"width="130px" align="right"><%= html_hours(l_hours(@version.estimated_hours)) %></td> |
|
20 | 22 | </tr> |
|
21 | 23 | <% if User.current.allowed_to?(:view_time_entries, @project) %> |
|
22 | 24 | <tr> |
|
23 | 25 | <td width="130px" align="right"><%= l(:label_spent_time) %></td> |
|
24 | 26 | <td width="240px" class="total-hours"><%= html_hours(l_hours(@version.spent_hours)) %></td> |
|
25 | 27 | </tr> |
|
26 | 28 | <% end %> |
|
27 | 29 | </table> |
|
28 | 30 | </fieldset> |
|
29 | 31 | <% end %> |
|
30 | 32 | |
|
31 | 33 | <div id="status_by"> |
|
32 | 34 | <%= render_issue_status_by(@version, params[:status_by]) if @version.fixed_issues.count > 0 %> |
|
33 | 35 | </div> |
|
34 | 36 | </div> |
|
35 | 37 | |
|
36 | 38 | <% if @issues.present? %> |
|
37 | 39 | <% form_tag({}) do -%> |
|
38 | 40 | <table class="list related-issues"> |
|
39 | 41 | <caption><%= l(:label_related_issues) %></caption> |
|
40 | 42 | <%- @issues.each do |issue| -%> |
|
41 | 43 | <tr class="hascontextmenu"> |
|
42 | 44 | <td class="checkbox"><%= check_box_tag 'ids[]', issue.id %></td> |
|
43 | 45 | <td><%= link_to_issue(issue, :project => (@project != issue.project)) %></td> |
|
44 | 46 | </tr> |
|
45 | 47 | <% end %> |
|
46 | 48 | </table> |
|
47 | 49 | <% end %> |
|
48 | 50 | <%= context_menu issues_context_menu_path %> |
|
49 | 51 | <% end %> |
|
50 | 52 | </div> |
|
51 | 53 | |
|
52 | 54 | <%= call_hook :view_versions_show_bottom, :version => @version %> |
|
53 | 55 | |
|
54 | 56 | <% html_title @version.name %> |
General Comments 0
You need to be logged in to leave comments.
Login now