##// END OF EJS Templates
Fixed version field on issue view page now links to the corresponding version in the roadmap....
Jean-Philippe Lang -
r559:2dbb3978184e
parent child
Show More
@@ -1,159 +1,161
1 1 # redMine - project management software
2 2 # Copyright (C) 2006-2007 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 IssuesController < ApplicationController
19 19 layout 'base', :except => :export_pdf
20 20 before_filter :find_project, :authorize
21 21
22 22 cache_sweeper :issue_sweeper, :only => [ :edit, :change_status, :destroy ]
23 23
24 helper :projects
25 include ProjectsHelper
24 26 helper :custom_fields
25 27 include CustomFieldsHelper
26 28 helper :ifpdf
27 29 include IfpdfHelper
28 30 helper :issue_relations
29 31 include IssueRelationsHelper
30 32 helper :watchers
31 33 include WatchersHelper
32 34 helper :attachments
33 35 include AttachmentsHelper
34 36
35 37 def show
36 38 @status_options = @issue.status.find_new_statuses_allowed_to(logged_in_user.role_for_project(@project), @issue.tracker) if logged_in_user
37 39 @custom_values = @issue.custom_values.find(:all, :include => :custom_field)
38 40 @journals_count = @issue.journals.count
39 41 @journals = @issue.journals.find(:all, :include => [:user, :details], :limit => 15, :order => "#{Journal.table_name}.created_on desc")
40 42 end
41 43
42 44 def history
43 45 @journals = @issue.journals.find(:all, :include => [:user, :details], :order => "#{Journal.table_name}.created_on desc")
44 46 @journals_count = @journals.length
45 47 end
46 48
47 49 def export_pdf
48 50 @custom_values = @issue.custom_values.find(:all, :include => :custom_field)
49 51 @options_for_rfpdf ||= {}
50 52 @options_for_rfpdf[:file_name] = "#{@project.name}_#{@issue.id}.pdf"
51 53 end
52 54
53 55 def edit
54 56 @priorities = Enumeration::get_values('IPRI')
55 57 if request.get?
56 58 @custom_values = @project.custom_fields_for_issues(@issue.tracker).collect { |x| @issue.custom_values.find_by_custom_field_id(x.id) || CustomValue.new(:custom_field => x, :customized => @issue) }
57 59 else
58 60 begin
59 61 @issue.init_journal(self.logged_in_user)
60 62 # Retrieve custom fields and values
61 63 @custom_values = @project.custom_fields_for_issues(@issue.tracker).collect { |x| CustomValue.new(:custom_field => x, :customized => @issue, :value => params["custom_fields"][x.id.to_s]) }
62 64 @issue.custom_values = @custom_values
63 65 @issue.attributes = params[:issue]
64 66 if @issue.save
65 67 flash[:notice] = l(:notice_successful_update)
66 68 redirect_to :action => 'show', :id => @issue
67 69 end
68 70 rescue ActiveRecord::StaleObjectError
69 71 # Optimistic locking exception
70 72 flash[:notice] = l(:notice_locking_conflict)
71 73 end
72 74 end
73 75 end
74 76
75 77 def add_note
76 78 unless params[:notes].empty?
77 79 journal = @issue.init_journal(self.logged_in_user, params[:notes])
78 80 if @issue.save
79 81 flash[:notice] = l(:notice_successful_update)
80 82 Mailer.deliver_issue_edit(journal) if Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled?
81 83 redirect_to :action => 'show', :id => @issue
82 84 return
83 85 end
84 86 end
85 87 show
86 88 render :action => 'show'
87 89 end
88 90
89 91 def change_status
90 92 @status_options = @issue.status.find_new_statuses_allowed_to(logged_in_user.role_for_project(@project), @issue.tracker) if logged_in_user
91 93 @new_status = IssueStatus.find(params[:new_status_id])
92 94 if params[:confirm]
93 95 begin
94 96 journal = @issue.init_journal(self.logged_in_user, params[:notes])
95 97 @issue.status = @new_status
96 98 if @issue.update_attributes(params[:issue])
97 99 # Save attachments
98 100 params[:attachments].each { |file|
99 101 next unless file.size > 0
100 102 a = Attachment.create(:container => @issue, :file => file, :author => logged_in_user)
101 103 journal.details << JournalDetail.new(:property => 'attachment',
102 104 :prop_key => a.id,
103 105 :value => a.filename) unless a.new_record?
104 106 } if params[:attachments] and params[:attachments].is_a? Array
105 107
106 108 flash[:notice] = l(:notice_successful_update)
107 109 Mailer.deliver_issue_edit(journal) if Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled?
108 110 redirect_to :action => 'show', :id => @issue
109 111 end
110 112 rescue ActiveRecord::StaleObjectError
111 113 # Optimistic locking exception
112 114 flash[:notice] = l(:notice_locking_conflict)
113 115 end
114 116 end
115 117 @assignable_to = @project.members.find(:all, :include => :user).collect{ |m| m.user }
116 118 end
117 119
118 120 def destroy
119 121 @issue.destroy
120 122 redirect_to :controller => 'projects', :action => 'list_issues', :id => @project
121 123 end
122 124
123 125 def add_attachment
124 126 # Save the attachments
125 127 @attachments = []
126 128 journal = @issue.init_journal(self.logged_in_user)
127 129 params[:attachments].each { |file|
128 130 next unless file.size > 0
129 131 a = Attachment.create(:container => @issue, :file => file, :author => logged_in_user)
130 132 @attachments << a unless a.new_record?
131 133 journal.details << JournalDetail.new(:property => 'attachment',
132 134 :prop_key => a.id,
133 135 :value => a.filename) unless a.new_record?
134 136 } if params[:attachments] and params[:attachments].is_a? Array
135 137 journal.save if journal.details.any?
136 138 Mailer.deliver_attachments_add(@attachments) if !@attachments.empty? and Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled?
137 139 redirect_to :action => 'show', :id => @issue
138 140 end
139 141
140 142 def destroy_attachment
141 143 a = @issue.attachments.find(params[:attachment_id])
142 144 a.destroy
143 145 journal = @issue.init_journal(self.logged_in_user)
144 146 journal.details << JournalDetail.new(:property => 'attachment',
145 147 :prop_key => a.id,
146 148 :old_value => a.filename)
147 149 journal.save
148 150 redirect_to :action => 'show', :id => @issue
149 151 end
150 152
151 153 private
152 154 def find_project
153 155 @issue = Issue.find(params[:id], :include => [:project, :tracker, :status, :author, :priority, :category])
154 156 @project = @issue.project
155 157 @html_title = "#{@project.name} - #{@issue.tracker.name} ##{@issue.id}"
156 158 rescue ActiveRecord::RecordNotFound
157 159 render_404
158 160 end
159 161 end
@@ -1,115 +1,115
1 1 <div class="contextual">
2 2 <%= l(:label_export_to) %><%= link_to 'PDF', {:action => 'export_pdf', :id => @issue}, :class => 'icon icon-pdf' %>
3 3 </div>
4 4
5 5 <h2><%= @issue.tracker.name %> #<%= @issue.id %> - <%=h @issue.subject %></h2>
6 6
7 7 <div class="box">
8 8 <table width="100%">
9 9 <tr>
10 10 <td style="width:15%"><b><%=l(:field_status)%> :</b></td><td style="width:35%"><%= @issue.status.name %></td>
11 11 <td style="width:15%"><b><%=l(:field_priority)%> :</b></td><td style="width:35%"><%= @issue.priority.name %></td>
12 12 </tr>
13 13 <tr>
14 14 <td><b><%=l(:field_assigned_to)%> :</b></td><td><%= @issue.assigned_to ? link_to_user(@issue.assigned_to) : "-" %></td>
15 15 <td><b><%=l(:field_category)%> :</b></td><td><%=h @issue.category ? @issue.category.name : "-" %></td>
16 16 </tr>
17 17 <tr>
18 18 <td><b><%=l(:field_author)%> :</b></td><td><%= link_to_user @issue.author %></td>
19 19 <td><b><%=l(:field_start_date)%> :</b></td><td><%= format_date(@issue.start_date) %></td>
20 20 </tr>
21 21 <tr>
22 22 <td><b><%=l(:field_created_on)%> :</b></td><td><%= format_date(@issue.created_on) %></td>
23 23 <td><b><%=l(:field_due_date)%> :</b></td><td><%= format_date(@issue.due_date) %></td>
24 24 </tr>
25 25 <tr>
26 26 <td><b><%=l(:field_updated_on)%> :</b></td><td><%= format_date(@issue.updated_on) %></td>
27 27 <td><b><%=l(:field_done_ratio)%> :</b></td><td><%= @issue.done_ratio %> %</td>
28 28 </tr>
29 29 <tr>
30 <td><b><%=l(:field_fixed_version)%> :</b></td><td><%= @issue.fixed_version ? @issue.fixed_version.name : "-" %></td>
30 <td><b><%=l(:field_fixed_version)%> :</b></td><td><%= @issue.fixed_version ? link_to_version(@issue.fixed_version) : "-" %></td>
31 31 <td><b><%=l(:label_spent_time)%> :</b></td>
32 32 <td><%= @issue.spent_hours > 0 ? (link_to lwr(:label_f_hour, @issue.spent_hours), {:controller => 'timelog', :action => 'details', :issue_id => @issue}, :class => 'icon icon-time') : "-" %></td>
33 33 </tr>
34 34 <tr>
35 35 <% n = 0
36 36 for custom_value in @custom_values %>
37 37 <td><b><%= custom_value.custom_field.name %> :</b></td><td><%= h(show_value(custom_value)) %></td>
38 38 <% n = n + 1
39 39 if (n > 1)
40 40 n = 0 %>
41 41 </tr><tr>
42 42 <%end
43 43 end %>
44 44 </tr>
45 45 </table>
46 46 <hr />
47 47
48 48 <% if @issue.changesets.any? %>
49 49 <div style="float:right;">
50 50 <em><%= l(:label_revision_plural) %>: <%= @issue.changesets.collect{|changeset| link_to(changeset.revision, :controller => 'repositories', :action => 'revision', :id => @project, :rev => changeset.revision)}.join(", ") %></em>
51 51 </div>
52 52 <% end %>
53 53
54 54 <b><%=l(:field_description)%> :</b><br /><br />
55 55 <%= textilizable @issue.description, :attachments => @issue.attachments %>
56 56 <br />
57 57
58 58 <div class="contextual">
59 59 <%= link_to_if_authorized l(:button_edit), {:controller => 'issues', :action => 'edit', :id => @issue}, :class => 'icon icon-edit' %>
60 60 <%= link_to_if_authorized l(:button_log_time), {:controller => 'timelog', :action => 'edit', :issue_id => @issue}, :class => 'icon icon-time' %>
61 61 <%= watcher_tag(@issue, @logged_in_user) %>
62 62 <%= link_to_if_authorized l(:button_move), {:controller => 'projects', :action => 'move_issues', :id => @project, "issue_ids[]" => @issue.id }, :class => 'icon icon-move' %>
63 63 <%= link_to_if_authorized l(:button_delete), {:controller => 'issues', :action => 'destroy', :id => @issue}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %>
64 64 </div>
65 65
66 66 <% if authorize_for('issues', 'change_status') and @status_options and !@status_options.empty? %>
67 67 <% form_tag({:controller => 'issues', :action => 'change_status', :id => @issue}) do %>
68 68 <%=l(:label_change_status)%> :
69 69 <select name="new_status_id">
70 70 <%= options_from_collection_for_select @status_options, "id", "name" %>
71 71 </select>
72 72 <%= submit_tag l(:button_change) %>
73 73 <% end %>
74 74 <% end %>
75 75 &nbsp;
76 76 </div>
77 77
78 78 <% if authorize_for('issue_relations', 'new') || @issue.relations.any? %>
79 79 <div id="relations" class="box">
80 80 <%= render :partial => 'relations' %>
81 81 </div>
82 82 <% end %>
83 83
84 84 <div id="history" class="box">
85 85 <h3><%=l(:label_history)%>
86 86 <% if @journals_count > @journals.length %>(<%= l(:label_last_changes, @journals.length) %>)<% end %></h3>
87 87 <%= render :partial => 'history', :locals => { :journals => @journals } %>
88 88 <% if @journals_count > @journals.length %>
89 89 <p><center><small><%= link_to l(:label_change_view_all), :action => 'history', :id => @issue %></small></center></p>
90 90 <% end %>
91 91 </div>
92 92
93 93 <div class="box">
94 94 <h3><%=l(:label_attachment_plural)%></h3>
95 95 <%= link_to_attachments @issue.attachments, :delete_url => (authorize_for('issues', 'destroy_attachment') ? {:controller => 'issues', :action => 'destroy_attachment', :id => @issue} : nil) %>
96 96
97 97 <% if authorize_for('issues', 'add_attachment') %>
98 98 <p><%= toggle_link l(:label_attachment_new), "add_attachment_form" %></p>
99 99 <% form_tag({ :controller => 'issues', :action => 'add_attachment', :id => @issue }, :multipart => true, :class => "tabular", :id => "add_attachment_form", :style => "display:none;") do %>
100 100 <%= render :partial => 'attachments/form' %>
101 101 <%= submit_tag l(:button_add) %>
102 102 <% end %>
103 103 <% end %>
104 104 </div>
105 105
106 106 <% if authorize_for('issues', 'add_note') %>
107 107 <div class="box">
108 108 <h3><%= l(:label_add_note) %></h3>
109 109 <% form_tag({:controller => 'issues', :action => 'add_note', :id => @issue}, :class => "tabular" ) do %>
110 110 <p><label for="notes"><%=l(:field_notes)%></label>
111 111 <%= text_area_tag 'notes', '', :cols => 60, :rows => 10, :class => 'wiki-edit' %></p>
112 112 <%= submit_tag l(:button_add) %>
113 113 <% end %>
114 114 </div>
115 115 <% end %>
General Comments 0
You need to be logged in to leave comments. Login now