@@ -1,105 +1,108 | |||||
1 | # redMine - project management software |
|
1 | # redMine - project management software | |
2 | # Copyright (C) 2006 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006 Jean-Philippe Lang | |
3 | # |
|
3 | # | |
4 | # This program is free software; you can redistribute it and/or |
|
4 | # This program is free software; you can redistribute it and/or | |
5 | # modify it under the terms of the GNU General Public License |
|
5 | # modify it under the terms of the GNU General Public License | |
6 | # as published by the Free Software Foundation; either version 2 |
|
6 | # as published by the Free Software Foundation; either version 2 | |
7 | # of the License, or (at your option) any later version. |
|
7 | # of the License, or (at your option) any later version. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU General Public License |
|
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software |
|
15 | # along with this program; if not, write to the Free Software | |
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 |
|
17 | |||
18 | class VersionsController < ApplicationController |
|
18 | class VersionsController < ApplicationController | |
19 | menu_item :roadmap |
|
19 | menu_item :roadmap | |
20 | model_object Version |
|
20 | model_object Version | |
21 | before_filter :find_model_object, :except => [:new, :close_completed] |
|
21 | before_filter :find_model_object, :except => [:new, :close_completed] | |
22 | before_filter :find_project_from_association, :except => [:new, :close_completed] |
|
22 | before_filter :find_project_from_association, :except => [:new, :close_completed] | |
23 | before_filter :find_project, :only => [:new, :close_completed] |
|
23 | before_filter :find_project, :only => [:new, :close_completed] | |
24 | before_filter :authorize |
|
24 | before_filter :authorize | |
25 |
|
25 | |||
26 | helper :custom_fields |
|
26 | helper :custom_fields | |
27 | helper :projects |
|
27 | helper :projects | |
28 |
|
28 | |||
29 | def show |
|
29 | def show | |
|
30 | @issues = @version.fixed_issues.find(:all, | |||
|
31 | :include => [:status, :tracker, :priority], | |||
|
32 | :order => "#{Tracker.table_name}.position, #{Issue.table_name}.id") | |||
30 | end |
|
33 | end | |
31 |
|
34 | |||
32 | def new |
|
35 | def new | |
33 | @version = @project.versions.build |
|
36 | @version = @project.versions.build | |
34 | if params[:version] |
|
37 | if params[:version] | |
35 | attributes = params[:version].dup |
|
38 | attributes = params[:version].dup | |
36 | attributes.delete('sharing') unless attributes.nil? || @version.allowed_sharings.include?(attributes['sharing']) |
|
39 | attributes.delete('sharing') unless attributes.nil? || @version.allowed_sharings.include?(attributes['sharing']) | |
37 | @version.attributes = attributes |
|
40 | @version.attributes = attributes | |
38 | end |
|
41 | end | |
39 | if request.post? |
|
42 | if request.post? | |
40 | if @version.save |
|
43 | if @version.save | |
41 | respond_to do |format| |
|
44 | respond_to do |format| | |
42 | format.html do |
|
45 | format.html do | |
43 | flash[:notice] = l(:notice_successful_create) |
|
46 | flash[:notice] = l(:notice_successful_create) | |
44 | redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project |
|
47 | redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project | |
45 | end |
|
48 | end | |
46 | format.js do |
|
49 | format.js do | |
47 | # IE doesn't support the replace_html rjs method for select box options |
|
50 | # IE doesn't support the replace_html rjs method for select box options | |
48 | render(:update) {|page| page.replace "issue_fixed_version_id", |
|
51 | render(:update) {|page| page.replace "issue_fixed_version_id", | |
49 | content_tag('select', '<option></option>' + version_options_for_select(@project.shared_versions.open, @version), :id => 'issue_fixed_version_id', :name => 'issue[fixed_version_id]') |
|
52 | content_tag('select', '<option></option>' + version_options_for_select(@project.shared_versions.open, @version), :id => 'issue_fixed_version_id', :name => 'issue[fixed_version_id]') | |
50 | } |
|
53 | } | |
51 | end |
|
54 | end | |
52 | end |
|
55 | end | |
53 | else |
|
56 | else | |
54 | respond_to do |format| |
|
57 | respond_to do |format| | |
55 | format.html |
|
58 | format.html | |
56 | format.js do |
|
59 | format.js do | |
57 | render(:update) {|page| page.alert(@version.errors.full_messages.join('\n')) } |
|
60 | render(:update) {|page| page.alert(@version.errors.full_messages.join('\n')) } | |
58 | end |
|
61 | end | |
59 | end |
|
62 | end | |
60 | end |
|
63 | end | |
61 | end |
|
64 | end | |
62 | end |
|
65 | end | |
63 |
|
66 | |||
64 | def edit |
|
67 | def edit | |
65 | if request.post? && params[:version] |
|
68 | if request.post? && params[:version] | |
66 | attributes = params[:version].dup |
|
69 | attributes = params[:version].dup | |
67 | attributes.delete('sharing') unless @version.allowed_sharings.include?(attributes['sharing']) |
|
70 | attributes.delete('sharing') unless @version.allowed_sharings.include?(attributes['sharing']) | |
68 | if @version.update_attributes(attributes) |
|
71 | if @version.update_attributes(attributes) | |
69 | flash[:notice] = l(:notice_successful_update) |
|
72 | flash[:notice] = l(:notice_successful_update) | |
70 | redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project |
|
73 | redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project | |
71 | end |
|
74 | end | |
72 | end |
|
75 | end | |
73 | end |
|
76 | end | |
74 |
|
77 | |||
75 | def close_completed |
|
78 | def close_completed | |
76 | if request.post? |
|
79 | if request.post? | |
77 | @project.close_completed_versions |
|
80 | @project.close_completed_versions | |
78 | end |
|
81 | end | |
79 | redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project |
|
82 | redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project | |
80 | end |
|
83 | end | |
81 |
|
84 | |||
82 | def destroy |
|
85 | def destroy | |
83 | if @version.fixed_issues.empty? |
|
86 | if @version.fixed_issues.empty? | |
84 | @version.destroy |
|
87 | @version.destroy | |
85 | redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project |
|
88 | redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project | |
86 | else |
|
89 | else | |
87 | flash[:error] = l(:notice_unable_delete_version) |
|
90 | flash[:error] = l(:notice_unable_delete_version) | |
88 | redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project |
|
91 | redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project | |
89 | end |
|
92 | end | |
90 | end |
|
93 | end | |
91 |
|
94 | |||
92 | def status_by |
|
95 | def status_by | |
93 | respond_to do |format| |
|
96 | respond_to do |format| | |
94 | format.html { render :action => 'show' } |
|
97 | format.html { render :action => 'show' } | |
95 | format.js { render(:update) {|page| page.replace_html 'status_by', render_issue_status_by(@version, params[:status_by])} } |
|
98 | format.js { render(:update) {|page| page.replace_html 'status_by', render_issue_status_by(@version, params[:status_by])} } | |
96 | end |
|
99 | end | |
97 | end |
|
100 | end | |
98 |
|
101 | |||
99 | private |
|
102 | private | |
100 | def find_project |
|
103 | def find_project | |
101 | @project = Project.find(params[:project_id]) |
|
104 | @project = Project.find(params[:project_id]) | |
102 | rescue ActiveRecord::RecordNotFound |
|
105 | rescue ActiveRecord::RecordNotFound | |
103 | render_404 |
|
106 | render_404 | |
104 | end |
|
107 | end | |
105 | end |
|
108 | end |
@@ -1,51 +1,48 | |||||
1 | <div class="contextual"> |
|
1 | <div class="contextual"> | |
2 | <%= link_to_if_authorized l(:button_edit), {:controller => 'versions', :action => 'edit', :id => @version}, :class => 'icon icon-edit' %> |
|
2 | <%= link_to_if_authorized l(:button_edit), {:controller => 'versions', :action => 'edit', :id => @version}, :class => 'icon icon-edit' %> | |
3 | <%= call_hook(:view_versions_show_contextual, { :version => @version, :project => @project }) %> |
|
3 | <%= call_hook(:view_versions_show_contextual, { :version => @version, :project => @project }) %> | |
4 | </div> |
|
4 | </div> | |
5 |
|
5 | |||
6 | <h2><%= h(@version.name) %></h2> |
|
6 | <h2><%= h(@version.name) %></h2> | |
7 |
|
7 | |||
8 | <div id="version-summary"> |
|
8 | <div id="version-summary"> | |
9 | <% if @version.estimated_hours > 0 || User.current.allowed_to?(:view_time_entries, @project) %> |
|
9 | <% if @version.estimated_hours > 0 || User.current.allowed_to?(:view_time_entries, @project) %> | |
10 | <fieldset><legend><%= l(:label_time_tracking) %></legend> |
|
10 | <fieldset><legend><%= l(:label_time_tracking) %></legend> | |
11 | <table> |
|
11 | <table> | |
12 | <tr> |
|
12 | <tr> | |
13 | <td width="130px" align="right"><%= l(:field_estimated_hours) %></td> |
|
13 | <td width="130px" align="right"><%= l(:field_estimated_hours) %></td> | |
14 | <td width="240px" class="total-hours"width="130px" align="right"><%= html_hours(l_hours(@version.estimated_hours)) %></td> |
|
14 | <td width="240px" class="total-hours"width="130px" align="right"><%= html_hours(l_hours(@version.estimated_hours)) %></td> | |
15 | </tr> |
|
15 | </tr> | |
16 | <% if User.current.allowed_to?(:view_time_entries, @project) %> |
|
16 | <% if User.current.allowed_to?(:view_time_entries, @project) %> | |
17 | <tr> |
|
17 | <tr> | |
18 | <td width="130px" align="right"><%= l(:label_spent_time) %></td> |
|
18 | <td width="130px" align="right"><%= l(:label_spent_time) %></td> | |
19 | <td width="240px" class="total-hours"><%= html_hours(l_hours(@version.spent_hours)) %></td> |
|
19 | <td width="240px" class="total-hours"><%= html_hours(l_hours(@version.spent_hours)) %></td> | |
20 | </tr> |
|
20 | </tr> | |
21 | <% end %> |
|
21 | <% end %> | |
22 | </table> |
|
22 | </table> | |
23 | </fieldset> |
|
23 | </fieldset> | |
24 | <% end %> |
|
24 | <% end %> | |
25 |
|
25 | |||
26 | <div id="status_by"> |
|
26 | <div id="status_by"> | |
27 | <%= render_issue_status_by(@version, params[:status_by]) if @version.fixed_issues.count > 0 %> |
|
27 | <%= render_issue_status_by(@version, params[:status_by]) if @version.fixed_issues.count > 0 %> | |
28 | </div> |
|
28 | </div> | |
29 | </div> |
|
29 | </div> | |
30 |
|
30 | |||
31 | <div id="roadmap"> |
|
31 | <div id="roadmap"> | |
32 | <%= render :partial => 'versions/overview', :locals => {:version => @version} %> |
|
32 | <%= render :partial => 'versions/overview', :locals => {:version => @version} %> | |
33 | <%= render(:partial => "wiki/content", :locals => {:content => @version.wiki_page.content}) if @version.wiki_page %> |
|
33 | <%= render(:partial => "wiki/content", :locals => {:content => @version.wiki_page.content}) if @version.wiki_page %> | |
34 |
|
34 | |||
35 | <% issues = @version.fixed_issues.find(:all, |
|
35 | <% if @issues.present? %> | |
36 | :include => [:status, :tracker, :priority], |
|
|||
37 | :order => "#{Tracker.table_name}.position, #{Issue.table_name}.id") %> |
|
|||
38 | <% if issues.size > 0 %> |
|
|||
39 | <fieldset class="related-issues"><legend><%= l(:label_related_issues) %></legend> |
|
36 | <fieldset class="related-issues"><legend><%= l(:label_related_issues) %></legend> | |
40 | <ul> |
|
37 | <ul> | |
41 | <% issues.each do |issue| -%> |
|
38 | <% @issues.each do |issue| -%> | |
42 | <li><%= link_to_issue(issue) %></li> |
|
39 | <li><%= link_to_issue(issue) %></li> | |
43 | <% end -%> |
|
40 | <% end -%> | |
44 | </ul> |
|
41 | </ul> | |
45 | </fieldset> |
|
42 | </fieldset> | |
46 | <% end %> |
|
43 | <% end %> | |
47 | </div> |
|
44 | </div> | |
48 |
|
45 | |||
49 | <%= call_hook :view_versions_show_bottom, :version => @version %> |
|
46 | <%= call_hook :view_versions_show_bottom, :version => @version %> | |
50 |
|
47 | |||
51 | <% html_title @version.name %> |
|
48 | <% html_title @version.name %> |
General Comments 0
You need to be logged in to leave comments.
Login now