##// END OF EJS Templates
Show visible spent time link for users allowed to view time entries (#20661)....
Jean-Philippe Lang -
r15910:cb985627e2a0
parent child
Show More
@@ -1,587 +1,592
1 # Redmine - project management software
1 # Redmine - project management software
2 # Copyright (C) 2006-2016 Jean-Philippe Lang
2 # Copyright (C) 2006-2016 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 IssuesController < ApplicationController
18 class IssuesController < ApplicationController
19 default_search_scope :issues
19 default_search_scope :issues
20
20
21 before_action :find_issue, :only => [:show, :edit, :update]
21 before_action :find_issue, :only => [:show, :edit, :update]
22 before_action :find_issues, :only => [:bulk_edit, :bulk_update, :destroy]
22 before_action :find_issues, :only => [:bulk_edit, :bulk_update, :destroy]
23 before_action :authorize, :except => [:index, :new, :create]
23 before_action :authorize, :except => [:index, :new, :create]
24 before_action :find_optional_project, :only => [:index, :new, :create]
24 before_action :find_optional_project, :only => [:index, :new, :create]
25 before_action :build_new_issue_from_params, :only => [:new, :create]
25 before_action :build_new_issue_from_params, :only => [:new, :create]
26 accept_rss_auth :index, :show
26 accept_rss_auth :index, :show
27 accept_api_auth :index, :show, :create, :update, :destroy
27 accept_api_auth :index, :show, :create, :update, :destroy
28
28
29 rescue_from Query::StatementInvalid, :with => :query_statement_invalid
29 rescue_from Query::StatementInvalid, :with => :query_statement_invalid
30
30
31 helper :journals
31 helper :journals
32 helper :projects
32 helper :projects
33 helper :custom_fields
33 helper :custom_fields
34 helper :issue_relations
34 helper :issue_relations
35 helper :watchers
35 helper :watchers
36 helper :attachments
36 helper :attachments
37 helper :queries
37 helper :queries
38 include QueriesHelper
38 include QueriesHelper
39 helper :repositories
39 helper :repositories
40 helper :sort
40 helper :sort
41 include SortHelper
41 include SortHelper
42 helper :timelog
42 helper :timelog
43
43
44 def index
44 def index
45 retrieve_query
45 retrieve_query
46 sort_init(@query.sort_criteria.empty? ? [['id', 'desc']] : @query.sort_criteria)
46 sort_init(@query.sort_criteria.empty? ? [['id', 'desc']] : @query.sort_criteria)
47 sort_update(@query.sortable_columns)
47 sort_update(@query.sortable_columns)
48 @query.sort_criteria = sort_criteria.to_a
48 @query.sort_criteria = sort_criteria.to_a
49
49
50 if @query.valid?
50 if @query.valid?
51 case params[:format]
51 case params[:format]
52 when 'csv', 'pdf'
52 when 'csv', 'pdf'
53 @limit = Setting.issues_export_limit.to_i
53 @limit = Setting.issues_export_limit.to_i
54 if params[:columns] == 'all'
54 if params[:columns] == 'all'
55 @query.column_names = @query.available_inline_columns.map(&:name)
55 @query.column_names = @query.available_inline_columns.map(&:name)
56 end
56 end
57 when 'atom'
57 when 'atom'
58 @limit = Setting.feeds_limit.to_i
58 @limit = Setting.feeds_limit.to_i
59 when 'xml', 'json'
59 when 'xml', 'json'
60 @offset, @limit = api_offset_and_limit
60 @offset, @limit = api_offset_and_limit
61 @query.column_names = %w(author)
61 @query.column_names = %w(author)
62 else
62 else
63 @limit = per_page_option
63 @limit = per_page_option
64 end
64 end
65
65
66 @issue_count = @query.issue_count
66 @issue_count = @query.issue_count
67 @issue_pages = Paginator.new @issue_count, @limit, params['page']
67 @issue_pages = Paginator.new @issue_count, @limit, params['page']
68 @offset ||= @issue_pages.offset
68 @offset ||= @issue_pages.offset
69 @issues = @query.issues(:order => sort_clause,
69 @issues = @query.issues(:order => sort_clause,
70 :offset => @offset,
70 :offset => @offset,
71 :limit => @limit)
71 :limit => @limit)
72 @issue_count_by_group = @query.issue_count_by_group
72 @issue_count_by_group = @query.issue_count_by_group
73
73
74 respond_to do |format|
74 respond_to do |format|
75 format.html { render :template => 'issues/index', :layout => !request.xhr? }
75 format.html { render :template => 'issues/index', :layout => !request.xhr? }
76 format.api {
76 format.api {
77 Issue.load_visible_relations(@issues) if include_in_api_response?('relations')
77 Issue.load_visible_relations(@issues) if include_in_api_response?('relations')
78 }
78 }
79 format.atom { render_feed(@issues, :title => "#{@project || Setting.app_title}: #{l(:label_issue_plural)}") }
79 format.atom { render_feed(@issues, :title => "#{@project || Setting.app_title}: #{l(:label_issue_plural)}") }
80 format.csv { send_data(query_to_csv(@issues, @query, params[:csv]), :type => 'text/csv; header=present', :filename => 'issues.csv') }
80 format.csv { send_data(query_to_csv(@issues, @query, params[:csv]), :type => 'text/csv; header=present', :filename => 'issues.csv') }
81 format.pdf { send_file_headers! :type => 'application/pdf', :filename => 'issues.pdf' }
81 format.pdf { send_file_headers! :type => 'application/pdf', :filename => 'issues.pdf' }
82 end
82 end
83 else
83 else
84 respond_to do |format|
84 respond_to do |format|
85 format.html { render(:template => 'issues/index', :layout => !request.xhr?) }
85 format.html { render(:template => 'issues/index', :layout => !request.xhr?) }
86 format.any(:atom, :csv, :pdf) { head 422 }
86 format.any(:atom, :csv, :pdf) { head 422 }
87 format.api { render_validation_errors(@query) }
87 format.api { render_validation_errors(@query) }
88 end
88 end
89 end
89 end
90 rescue ActiveRecord::RecordNotFound
90 rescue ActiveRecord::RecordNotFound
91 render_404
91 render_404
92 end
92 end
93
93
94 def show
94 def show
95 @journals = @issue.visible_journals_with_index
95 @journals = @issue.visible_journals_with_index
96 @changesets = @issue.changesets.visible.preload(:repository, :user).to_a
96 @changesets = @issue.changesets.visible.preload(:repository, :user).to_a
97 @relations = @issue.relations.select {|r| r.other_issue(@issue) && r.other_issue(@issue).visible? }
97 @relations = @issue.relations.select {|r| r.other_issue(@issue) && r.other_issue(@issue).visible? }
98
98
99 if User.current.wants_comments_in_reverse_order?
99 if User.current.wants_comments_in_reverse_order?
100 @journals.reverse!
100 @journals.reverse!
101 @changesets.reverse!
101 @changesets.reverse!
102 end
102 end
103
103
104 if User.current.allowed_to?(:view_time_entries, @project)
105 Issue.load_visible_spent_hours([@issue])
106 Issue.load_visible_total_spent_hours([@issue])
107 end
108
104 respond_to do |format|
109 respond_to do |format|
105 format.html {
110 format.html {
106 @allowed_statuses = @issue.new_statuses_allowed_to(User.current)
111 @allowed_statuses = @issue.new_statuses_allowed_to(User.current)
107 @priorities = IssuePriority.active
112 @priorities = IssuePriority.active
108 @time_entry = TimeEntry.new(:issue => @issue, :project => @issue.project)
113 @time_entry = TimeEntry.new(:issue => @issue, :project => @issue.project)
109 @relation = IssueRelation.new
114 @relation = IssueRelation.new
110 retrieve_previous_and_next_issue_ids
115 retrieve_previous_and_next_issue_ids
111 render :template => 'issues/show'
116 render :template => 'issues/show'
112 }
117 }
113 format.api
118 format.api
114 format.atom { render :template => 'journals/index', :layout => false, :content_type => 'application/atom+xml' }
119 format.atom { render :template => 'journals/index', :layout => false, :content_type => 'application/atom+xml' }
115 format.pdf {
120 format.pdf {
116 send_file_headers! :type => 'application/pdf', :filename => "#{@project.identifier}-#{@issue.id}.pdf"
121 send_file_headers! :type => 'application/pdf', :filename => "#{@project.identifier}-#{@issue.id}.pdf"
117 }
122 }
118 end
123 end
119 end
124 end
120
125
121 def new
126 def new
122 respond_to do |format|
127 respond_to do |format|
123 format.html { render :action => 'new', :layout => !request.xhr? }
128 format.html { render :action => 'new', :layout => !request.xhr? }
124 format.js
129 format.js
125 end
130 end
126 end
131 end
127
132
128 def create
133 def create
129 unless User.current.allowed_to?(:add_issues, @issue.project, :global => true)
134 unless User.current.allowed_to?(:add_issues, @issue.project, :global => true)
130 raise ::Unauthorized
135 raise ::Unauthorized
131 end
136 end
132 call_hook(:controller_issues_new_before_save, { :params => params, :issue => @issue })
137 call_hook(:controller_issues_new_before_save, { :params => params, :issue => @issue })
133 @issue.save_attachments(params[:attachments] || (params[:issue] && params[:issue][:uploads]))
138 @issue.save_attachments(params[:attachments] || (params[:issue] && params[:issue][:uploads]))
134 if @issue.save
139 if @issue.save
135 call_hook(:controller_issues_new_after_save, { :params => params, :issue => @issue})
140 call_hook(:controller_issues_new_after_save, { :params => params, :issue => @issue})
136 respond_to do |format|
141 respond_to do |format|
137 format.html {
142 format.html {
138 render_attachment_warning_if_needed(@issue)
143 render_attachment_warning_if_needed(@issue)
139 flash[:notice] = l(:notice_issue_successful_create, :id => view_context.link_to("##{@issue.id}", issue_path(@issue), :title => @issue.subject))
144 flash[:notice] = l(:notice_issue_successful_create, :id => view_context.link_to("##{@issue.id}", issue_path(@issue), :title => @issue.subject))
140 redirect_after_create
145 redirect_after_create
141 }
146 }
142 format.api { render :action => 'show', :status => :created, :location => issue_url(@issue) }
147 format.api { render :action => 'show', :status => :created, :location => issue_url(@issue) }
143 end
148 end
144 return
149 return
145 else
150 else
146 respond_to do |format|
151 respond_to do |format|
147 format.html {
152 format.html {
148 if @issue.project.nil?
153 if @issue.project.nil?
149 render_error :status => 422
154 render_error :status => 422
150 else
155 else
151 render :action => 'new'
156 render :action => 'new'
152 end
157 end
153 }
158 }
154 format.api { render_validation_errors(@issue) }
159 format.api { render_validation_errors(@issue) }
155 end
160 end
156 end
161 end
157 end
162 end
158
163
159 def edit
164 def edit
160 return unless update_issue_from_params
165 return unless update_issue_from_params
161
166
162 respond_to do |format|
167 respond_to do |format|
163 format.html { }
168 format.html { }
164 format.js
169 format.js
165 end
170 end
166 end
171 end
167
172
168 def update
173 def update
169 return unless update_issue_from_params
174 return unless update_issue_from_params
170 @issue.save_attachments(params[:attachments] || (params[:issue] && params[:issue][:uploads]))
175 @issue.save_attachments(params[:attachments] || (params[:issue] && params[:issue][:uploads]))
171 saved = false
176 saved = false
172 begin
177 begin
173 saved = save_issue_with_child_records
178 saved = save_issue_with_child_records
174 rescue ActiveRecord::StaleObjectError
179 rescue ActiveRecord::StaleObjectError
175 @conflict = true
180 @conflict = true
176 if params[:last_journal_id]
181 if params[:last_journal_id]
177 @conflict_journals = @issue.journals_after(params[:last_journal_id]).to_a
182 @conflict_journals = @issue.journals_after(params[:last_journal_id]).to_a
178 @conflict_journals.reject!(&:private_notes?) unless User.current.allowed_to?(:view_private_notes, @issue.project)
183 @conflict_journals.reject!(&:private_notes?) unless User.current.allowed_to?(:view_private_notes, @issue.project)
179 end
184 end
180 end
185 end
181
186
182 if saved
187 if saved
183 render_attachment_warning_if_needed(@issue)
188 render_attachment_warning_if_needed(@issue)
184 flash[:notice] = l(:notice_successful_update) unless @issue.current_journal.new_record?
189 flash[:notice] = l(:notice_successful_update) unless @issue.current_journal.new_record?
185
190
186 respond_to do |format|
191 respond_to do |format|
187 format.html { redirect_back_or_default issue_path(@issue, previous_and_next_issue_ids_params) }
192 format.html { redirect_back_or_default issue_path(@issue, previous_and_next_issue_ids_params) }
188 format.api { render_api_ok }
193 format.api { render_api_ok }
189 end
194 end
190 else
195 else
191 respond_to do |format|
196 respond_to do |format|
192 format.html { render :action => 'edit' }
197 format.html { render :action => 'edit' }
193 format.api { render_validation_errors(@issue) }
198 format.api { render_validation_errors(@issue) }
194 end
199 end
195 end
200 end
196 end
201 end
197
202
198 # Bulk edit/copy a set of issues
203 # Bulk edit/copy a set of issues
199 def bulk_edit
204 def bulk_edit
200 @issues.sort!
205 @issues.sort!
201 @copy = params[:copy].present?
206 @copy = params[:copy].present?
202 @notes = params[:notes]
207 @notes = params[:notes]
203
208
204 if @copy
209 if @copy
205 unless User.current.allowed_to?(:copy_issues, @projects)
210 unless User.current.allowed_to?(:copy_issues, @projects)
206 raise ::Unauthorized
211 raise ::Unauthorized
207 end
212 end
208 else
213 else
209 unless @issues.all?(&:attributes_editable?)
214 unless @issues.all?(&:attributes_editable?)
210 raise ::Unauthorized
215 raise ::Unauthorized
211 end
216 end
212 end
217 end
213
218
214 edited_issues = Issue.where(:id => @issues.map(&:id)).to_a
219 edited_issues = Issue.where(:id => @issues.map(&:id)).to_a
215
220
216 @values_by_custom_field = {}
221 @values_by_custom_field = {}
217 edited_issues.each do |issue|
222 edited_issues.each do |issue|
218 issue.custom_field_values.each do |c|
223 issue.custom_field_values.each do |c|
219 if c.value_present?
224 if c.value_present?
220 @values_by_custom_field[c.custom_field] ||= []
225 @values_by_custom_field[c.custom_field] ||= []
221 @values_by_custom_field[c.custom_field] << issue.id
226 @values_by_custom_field[c.custom_field] << issue.id
222 end
227 end
223 end
228 end
224 end
229 end
225
230
226 @allowed_projects = Issue.allowed_target_projects
231 @allowed_projects = Issue.allowed_target_projects
227 if params[:issue]
232 if params[:issue]
228 @target_project = @allowed_projects.detect {|p| p.id.to_s == params[:issue][:project_id].to_s}
233 @target_project = @allowed_projects.detect {|p| p.id.to_s == params[:issue][:project_id].to_s}
229 if @target_project
234 if @target_project
230 target_projects = [@target_project]
235 target_projects = [@target_project]
231 edited_issues.each {|issue| issue.project = @target_project}
236 edited_issues.each {|issue| issue.project = @target_project}
232 end
237 end
233 end
238 end
234 target_projects ||= @projects
239 target_projects ||= @projects
235
240
236 @trackers = target_projects.map {|p| Issue.allowed_target_trackers(p) }.reduce(:&)
241 @trackers = target_projects.map {|p| Issue.allowed_target_trackers(p) }.reduce(:&)
237 if params[:issue]
242 if params[:issue]
238 @target_tracker = @trackers.detect {|t| t.id.to_s == params[:issue][:tracker_id].to_s}
243 @target_tracker = @trackers.detect {|t| t.id.to_s == params[:issue][:tracker_id].to_s}
239 if @target_tracker
244 if @target_tracker
240 edited_issues.each {|issue| issue.tracker = @target_tracker}
245 edited_issues.each {|issue| issue.tracker = @target_tracker}
241 end
246 end
242 end
247 end
243
248
244 if @copy
249 if @copy
245 # Copied issues will get their default statuses
250 # Copied issues will get their default statuses
246 @available_statuses = []
251 @available_statuses = []
247 else
252 else
248 @available_statuses = edited_issues.map(&:new_statuses_allowed_to).reduce(:&)
253 @available_statuses = edited_issues.map(&:new_statuses_allowed_to).reduce(:&)
249 end
254 end
250 if params[:issue]
255 if params[:issue]
251 @target_status = @available_statuses.detect {|t| t.id.to_s == params[:issue][:status_id].to_s}
256 @target_status = @available_statuses.detect {|t| t.id.to_s == params[:issue][:status_id].to_s}
252 if @target_status
257 if @target_status
253 edited_issues.each {|issue| issue.status = @target_status}
258 edited_issues.each {|issue| issue.status = @target_status}
254 end
259 end
255 end
260 end
256
261
257 edited_issues.each do |issue|
262 edited_issues.each do |issue|
258 issue.custom_field_values.each do |c|
263 issue.custom_field_values.each do |c|
259 if c.value_present? && @values_by_custom_field[c.custom_field]
264 if c.value_present? && @values_by_custom_field[c.custom_field]
260 @values_by_custom_field[c.custom_field].delete(issue.id)
265 @values_by_custom_field[c.custom_field].delete(issue.id)
261 end
266 end
262 end
267 end
263 end
268 end
264 @values_by_custom_field.delete_if {|k,v| v.blank?}
269 @values_by_custom_field.delete_if {|k,v| v.blank?}
265
270
266 @custom_fields = edited_issues.map{|i|i.editable_custom_fields}.reduce(:&).select {|field| field.format.bulk_edit_supported}
271 @custom_fields = edited_issues.map{|i|i.editable_custom_fields}.reduce(:&).select {|field| field.format.bulk_edit_supported}
267 @assignables = target_projects.map(&:assignable_users).reduce(:&)
272 @assignables = target_projects.map(&:assignable_users).reduce(:&)
268 @versions = target_projects.map {|p| p.shared_versions.open}.reduce(:&)
273 @versions = target_projects.map {|p| p.shared_versions.open}.reduce(:&)
269 @categories = target_projects.map {|p| p.issue_categories}.reduce(:&)
274 @categories = target_projects.map {|p| p.issue_categories}.reduce(:&)
270 if @copy
275 if @copy
271 @attachments_present = @issues.detect {|i| i.attachments.any?}.present?
276 @attachments_present = @issues.detect {|i| i.attachments.any?}.present?
272 @subtasks_present = @issues.detect {|i| !i.leaf?}.present?
277 @subtasks_present = @issues.detect {|i| !i.leaf?}.present?
273 end
278 end
274
279
275 @safe_attributes = edited_issues.map(&:safe_attribute_names).reduce(:&)
280 @safe_attributes = edited_issues.map(&:safe_attribute_names).reduce(:&)
276
281
277 @issue_params = params[:issue] || {}
282 @issue_params = params[:issue] || {}
278 @issue_params[:custom_field_values] ||= {}
283 @issue_params[:custom_field_values] ||= {}
279 end
284 end
280
285
281 def bulk_update
286 def bulk_update
282 @issues.sort!
287 @issues.sort!
283 @copy = params[:copy].present?
288 @copy = params[:copy].present?
284
289
285 attributes = parse_params_for_bulk_update(params[:issue])
290 attributes = parse_params_for_bulk_update(params[:issue])
286 copy_subtasks = (params[:copy_subtasks] == '1')
291 copy_subtasks = (params[:copy_subtasks] == '1')
287 copy_attachments = (params[:copy_attachments] == '1')
292 copy_attachments = (params[:copy_attachments] == '1')
288
293
289 if @copy
294 if @copy
290 unless User.current.allowed_to?(:copy_issues, @projects)
295 unless User.current.allowed_to?(:copy_issues, @projects)
291 raise ::Unauthorized
296 raise ::Unauthorized
292 end
297 end
293 target_projects = @projects
298 target_projects = @projects
294 if attributes['project_id'].present?
299 if attributes['project_id'].present?
295 target_projects = Project.where(:id => attributes['project_id']).to_a
300 target_projects = Project.where(:id => attributes['project_id']).to_a
296 end
301 end
297 unless User.current.allowed_to?(:add_issues, target_projects)
302 unless User.current.allowed_to?(:add_issues, target_projects)
298 raise ::Unauthorized
303 raise ::Unauthorized
299 end
304 end
300 else
305 else
301 unless @issues.all?(&:attributes_editable?)
306 unless @issues.all?(&:attributes_editable?)
302 raise ::Unauthorized
307 raise ::Unauthorized
303 end
308 end
304 end
309 end
305
310
306 unsaved_issues = []
311 unsaved_issues = []
307 saved_issues = []
312 saved_issues = []
308
313
309 if @copy && copy_subtasks
314 if @copy && copy_subtasks
310 # Descendant issues will be copied with the parent task
315 # Descendant issues will be copied with the parent task
311 # Don't copy them twice
316 # Don't copy them twice
312 @issues.reject! {|issue| @issues.detect {|other| issue.is_descendant_of?(other)}}
317 @issues.reject! {|issue| @issues.detect {|other| issue.is_descendant_of?(other)}}
313 end
318 end
314
319
315 @issues.each do |orig_issue|
320 @issues.each do |orig_issue|
316 orig_issue.reload
321 orig_issue.reload
317 if @copy
322 if @copy
318 issue = orig_issue.copy({},
323 issue = orig_issue.copy({},
319 :attachments => copy_attachments,
324 :attachments => copy_attachments,
320 :subtasks => copy_subtasks,
325 :subtasks => copy_subtasks,
321 :link => link_copy?(params[:link_copy])
326 :link => link_copy?(params[:link_copy])
322 )
327 )
323 else
328 else
324 issue = orig_issue
329 issue = orig_issue
325 end
330 end
326 journal = issue.init_journal(User.current, params[:notes])
331 journal = issue.init_journal(User.current, params[:notes])
327 issue.safe_attributes = attributes
332 issue.safe_attributes = attributes
328 call_hook(:controller_issues_bulk_edit_before_save, { :params => params, :issue => issue })
333 call_hook(:controller_issues_bulk_edit_before_save, { :params => params, :issue => issue })
329 if issue.save
334 if issue.save
330 saved_issues << issue
335 saved_issues << issue
331 else
336 else
332 unsaved_issues << orig_issue
337 unsaved_issues << orig_issue
333 end
338 end
334 end
339 end
335
340
336 if unsaved_issues.empty?
341 if unsaved_issues.empty?
337 flash[:notice] = l(:notice_successful_update) unless saved_issues.empty?
342 flash[:notice] = l(:notice_successful_update) unless saved_issues.empty?
338 if params[:follow]
343 if params[:follow]
339 if @issues.size == 1 && saved_issues.size == 1
344 if @issues.size == 1 && saved_issues.size == 1
340 redirect_to issue_path(saved_issues.first)
345 redirect_to issue_path(saved_issues.first)
341 elsif saved_issues.map(&:project).uniq.size == 1
346 elsif saved_issues.map(&:project).uniq.size == 1
342 redirect_to project_issues_path(saved_issues.map(&:project).first)
347 redirect_to project_issues_path(saved_issues.map(&:project).first)
343 end
348 end
344 else
349 else
345 redirect_back_or_default _project_issues_path(@project)
350 redirect_back_or_default _project_issues_path(@project)
346 end
351 end
347 else
352 else
348 @saved_issues = @issues
353 @saved_issues = @issues
349 @unsaved_issues = unsaved_issues
354 @unsaved_issues = unsaved_issues
350 @issues = Issue.visible.where(:id => @unsaved_issues.map(&:id)).to_a
355 @issues = Issue.visible.where(:id => @unsaved_issues.map(&:id)).to_a
351 bulk_edit
356 bulk_edit
352 render :action => 'bulk_edit'
357 render :action => 'bulk_edit'
353 end
358 end
354 end
359 end
355
360
356 def destroy
361 def destroy
357 raise Unauthorized unless @issues.all?(&:deletable?)
362 raise Unauthorized unless @issues.all?(&:deletable?)
358
363
359 # all issues and their descendants are about to be deleted
364 # all issues and their descendants are about to be deleted
360 issues_and_descendants_ids = Issue.self_and_descendants(@issues).pluck(:id)
365 issues_and_descendants_ids = Issue.self_and_descendants(@issues).pluck(:id)
361 time_entries = TimeEntry.where(:issue_id => issues_and_descendants_ids)
366 time_entries = TimeEntry.where(:issue_id => issues_and_descendants_ids)
362 @hours = time_entries.sum(:hours).to_f
367 @hours = time_entries.sum(:hours).to_f
363
368
364 if @hours > 0
369 if @hours > 0
365 case params[:todo]
370 case params[:todo]
366 when 'destroy'
371 when 'destroy'
367 # nothing to do
372 # nothing to do
368 when 'nullify'
373 when 'nullify'
369 time_entries.update_all(:issue_id => nil)
374 time_entries.update_all(:issue_id => nil)
370 when 'reassign'
375 when 'reassign'
371 reassign_to = @project && @project.issues.find_by_id(params[:reassign_to_id])
376 reassign_to = @project && @project.issues.find_by_id(params[:reassign_to_id])
372 if reassign_to.nil?
377 if reassign_to.nil?
373 flash.now[:error] = l(:error_issue_not_found_in_project)
378 flash.now[:error] = l(:error_issue_not_found_in_project)
374 return
379 return
375 elsif issues_and_descendants_ids.include?(reassign_to.id)
380 elsif issues_and_descendants_ids.include?(reassign_to.id)
376 flash.now[:error] = l(:error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted)
381 flash.now[:error] = l(:error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted)
377 return
382 return
378 else
383 else
379 time_entries.update_all(:issue_id => reassign_to.id, :project_id => reassign_to.project_id)
384 time_entries.update_all(:issue_id => reassign_to.id, :project_id => reassign_to.project_id)
380 end
385 end
381 else
386 else
382 # display the destroy form if it's a user request
387 # display the destroy form if it's a user request
383 return unless api_request?
388 return unless api_request?
384 end
389 end
385 end
390 end
386 @issues.each do |issue|
391 @issues.each do |issue|
387 begin
392 begin
388 issue.reload.destroy
393 issue.reload.destroy
389 rescue ::ActiveRecord::RecordNotFound # raised by #reload if issue no longer exists
394 rescue ::ActiveRecord::RecordNotFound # raised by #reload if issue no longer exists
390 # nothing to do, issue was already deleted (eg. by a parent)
395 # nothing to do, issue was already deleted (eg. by a parent)
391 end
396 end
392 end
397 end
393 respond_to do |format|
398 respond_to do |format|
394 format.html { redirect_back_or_default _project_issues_path(@project) }
399 format.html { redirect_back_or_default _project_issues_path(@project) }
395 format.api { render_api_ok }
400 format.api { render_api_ok }
396 end
401 end
397 end
402 end
398
403
399 # Overrides Redmine::MenuManager::MenuController::ClassMethods for
404 # Overrides Redmine::MenuManager::MenuController::ClassMethods for
400 # when the "New issue" tab is enabled
405 # when the "New issue" tab is enabled
401 def current_menu_item
406 def current_menu_item
402 if Setting.new_item_menu_tab == '1' && [:new, :create].include?(action_name.to_sym)
407 if Setting.new_item_menu_tab == '1' && [:new, :create].include?(action_name.to_sym)
403 :new_issue
408 :new_issue
404 else
409 else
405 super
410 super
406 end
411 end
407 end
412 end
408
413
409 private
414 private
410
415
411 def retrieve_previous_and_next_issue_ids
416 def retrieve_previous_and_next_issue_ids
412 if params[:prev_issue_id].present? || params[:next_issue_id].present?
417 if params[:prev_issue_id].present? || params[:next_issue_id].present?
413 @prev_issue_id = params[:prev_issue_id].presence.try(:to_i)
418 @prev_issue_id = params[:prev_issue_id].presence.try(:to_i)
414 @next_issue_id = params[:next_issue_id].presence.try(:to_i)
419 @next_issue_id = params[:next_issue_id].presence.try(:to_i)
415 @issue_position = params[:issue_position].presence.try(:to_i)
420 @issue_position = params[:issue_position].presence.try(:to_i)
416 @issue_count = params[:issue_count].presence.try(:to_i)
421 @issue_count = params[:issue_count].presence.try(:to_i)
417 else
422 else
418 retrieve_query_from_session
423 retrieve_query_from_session
419 if @query
424 if @query
420 sort_init(@query.sort_criteria.empty? ? [['id', 'desc']] : @query.sort_criteria)
425 sort_init(@query.sort_criteria.empty? ? [['id', 'desc']] : @query.sort_criteria)
421 sort_update(@query.sortable_columns, 'issues_index_sort')
426 sort_update(@query.sortable_columns, 'issues_index_sort')
422 limit = 500
427 limit = 500
423 issue_ids = @query.issue_ids(:order => sort_clause, :limit => (limit + 1))
428 issue_ids = @query.issue_ids(:order => sort_clause, :limit => (limit + 1))
424 if (idx = issue_ids.index(@issue.id)) && idx < limit
429 if (idx = issue_ids.index(@issue.id)) && idx < limit
425 if issue_ids.size < 500
430 if issue_ids.size < 500
426 @issue_position = idx + 1
431 @issue_position = idx + 1
427 @issue_count = issue_ids.size
432 @issue_count = issue_ids.size
428 end
433 end
429 @prev_issue_id = issue_ids[idx - 1] if idx > 0
434 @prev_issue_id = issue_ids[idx - 1] if idx > 0
430 @next_issue_id = issue_ids[idx + 1] if idx < (issue_ids.size - 1)
435 @next_issue_id = issue_ids[idx + 1] if idx < (issue_ids.size - 1)
431 end
436 end
432 end
437 end
433 end
438 end
434 end
439 end
435
440
436 def previous_and_next_issue_ids_params
441 def previous_and_next_issue_ids_params
437 {
442 {
438 :prev_issue_id => params[:prev_issue_id],
443 :prev_issue_id => params[:prev_issue_id],
439 :next_issue_id => params[:next_issue_id],
444 :next_issue_id => params[:next_issue_id],
440 :issue_position => params[:issue_position],
445 :issue_position => params[:issue_position],
441 :issue_count => params[:issue_count]
446 :issue_count => params[:issue_count]
442 }.reject {|k,v| k.blank?}
447 }.reject {|k,v| k.blank?}
443 end
448 end
444
449
445 # Used by #edit and #update to set some common instance variables
450 # Used by #edit and #update to set some common instance variables
446 # from the params
451 # from the params
447 def update_issue_from_params
452 def update_issue_from_params
448 @time_entry = TimeEntry.new(:issue => @issue, :project => @issue.project)
453 @time_entry = TimeEntry.new(:issue => @issue, :project => @issue.project)
449 if params[:time_entry]
454 if params[:time_entry]
450 @time_entry.safe_attributes = params[:time_entry]
455 @time_entry.safe_attributes = params[:time_entry]
451 end
456 end
452
457
453 @issue.init_journal(User.current)
458 @issue.init_journal(User.current)
454
459
455 issue_attributes = params[:issue]
460 issue_attributes = params[:issue]
456 if issue_attributes && params[:conflict_resolution]
461 if issue_attributes && params[:conflict_resolution]
457 case params[:conflict_resolution]
462 case params[:conflict_resolution]
458 when 'overwrite'
463 when 'overwrite'
459 issue_attributes = issue_attributes.dup
464 issue_attributes = issue_attributes.dup
460 issue_attributes.delete(:lock_version)
465 issue_attributes.delete(:lock_version)
461 when 'add_notes'
466 when 'add_notes'
462 issue_attributes = issue_attributes.slice(:notes, :private_notes)
467 issue_attributes = issue_attributes.slice(:notes, :private_notes)
463 when 'cancel'
468 when 'cancel'
464 redirect_to issue_path(@issue)
469 redirect_to issue_path(@issue)
465 return false
470 return false
466 end
471 end
467 end
472 end
468 @issue.safe_attributes = issue_attributes
473 @issue.safe_attributes = issue_attributes
469 @priorities = IssuePriority.active
474 @priorities = IssuePriority.active
470 @allowed_statuses = @issue.new_statuses_allowed_to(User.current)
475 @allowed_statuses = @issue.new_statuses_allowed_to(User.current)
471 true
476 true
472 end
477 end
473
478
474 # Used by #new and #create to build a new issue from the params
479 # Used by #new and #create to build a new issue from the params
475 # The new issue will be copied from an existing one if copy_from parameter is given
480 # The new issue will be copied from an existing one if copy_from parameter is given
476 def build_new_issue_from_params
481 def build_new_issue_from_params
477 @issue = Issue.new
482 @issue = Issue.new
478 if params[:copy_from]
483 if params[:copy_from]
479 begin
484 begin
480 @issue.init_journal(User.current)
485 @issue.init_journal(User.current)
481 @copy_from = Issue.visible.find(params[:copy_from])
486 @copy_from = Issue.visible.find(params[:copy_from])
482 unless User.current.allowed_to?(:copy_issues, @copy_from.project)
487 unless User.current.allowed_to?(:copy_issues, @copy_from.project)
483 raise ::Unauthorized
488 raise ::Unauthorized
484 end
489 end
485 @link_copy = link_copy?(params[:link_copy]) || request.get?
490 @link_copy = link_copy?(params[:link_copy]) || request.get?
486 @copy_attachments = params[:copy_attachments].present? || request.get?
491 @copy_attachments = params[:copy_attachments].present? || request.get?
487 @copy_subtasks = params[:copy_subtasks].present? || request.get?
492 @copy_subtasks = params[:copy_subtasks].present? || request.get?
488 @issue.copy_from(@copy_from, :attachments => @copy_attachments, :subtasks => @copy_subtasks, :link => @link_copy)
493 @issue.copy_from(@copy_from, :attachments => @copy_attachments, :subtasks => @copy_subtasks, :link => @link_copy)
489 @issue.parent_issue_id = @copy_from.parent_id
494 @issue.parent_issue_id = @copy_from.parent_id
490 rescue ActiveRecord::RecordNotFound
495 rescue ActiveRecord::RecordNotFound
491 render_404
496 render_404
492 return
497 return
493 end
498 end
494 end
499 end
495 @issue.project = @project
500 @issue.project = @project
496 if request.get?
501 if request.get?
497 @issue.project ||= @issue.allowed_target_projects.first
502 @issue.project ||= @issue.allowed_target_projects.first
498 end
503 end
499 @issue.author ||= User.current
504 @issue.author ||= User.current
500 @issue.start_date ||= User.current.today if Setting.default_issue_start_date_to_creation_date?
505 @issue.start_date ||= User.current.today if Setting.default_issue_start_date_to_creation_date?
501
506
502 attrs = (params[:issue] || {}).deep_dup
507 attrs = (params[:issue] || {}).deep_dup
503 if action_name == 'new' && params[:was_default_status] == attrs[:status_id]
508 if action_name == 'new' && params[:was_default_status] == attrs[:status_id]
504 attrs.delete(:status_id)
509 attrs.delete(:status_id)
505 end
510 end
506 if action_name == 'new' && params[:form_update_triggered_by] == 'issue_project_id'
511 if action_name == 'new' && params[:form_update_triggered_by] == 'issue_project_id'
507 # Discard submitted version when changing the project on the issue form
512 # Discard submitted version when changing the project on the issue form
508 # so we can use the default version for the new project
513 # so we can use the default version for the new project
509 attrs.delete(:fixed_version_id)
514 attrs.delete(:fixed_version_id)
510 end
515 end
511 @issue.safe_attributes = attrs
516 @issue.safe_attributes = attrs
512
517
513 if @issue.project
518 if @issue.project
514 @issue.tracker ||= @issue.allowed_target_trackers.first
519 @issue.tracker ||= @issue.allowed_target_trackers.first
515 if @issue.tracker.nil?
520 if @issue.tracker.nil?
516 if @issue.project.trackers.any?
521 if @issue.project.trackers.any?
517 # None of the project trackers is allowed to the user
522 # None of the project trackers is allowed to the user
518 render_error :message => l(:error_no_tracker_allowed_for_new_issue_in_project), :status => 403
523 render_error :message => l(:error_no_tracker_allowed_for_new_issue_in_project), :status => 403
519 else
524 else
520 # Project has no trackers
525 # Project has no trackers
521 render_error l(:error_no_tracker_in_project)
526 render_error l(:error_no_tracker_in_project)
522 end
527 end
523 return false
528 return false
524 end
529 end
525 if @issue.status.nil?
530 if @issue.status.nil?
526 render_error l(:error_no_default_issue_status)
531 render_error l(:error_no_default_issue_status)
527 return false
532 return false
528 end
533 end
529 elsif request.get?
534 elsif request.get?
530 render_error :message => l(:error_no_projects_with_tracker_allowed_for_new_issue), :status => 403
535 render_error :message => l(:error_no_projects_with_tracker_allowed_for_new_issue), :status => 403
531 return false
536 return false
532 end
537 end
533
538
534 @priorities = IssuePriority.active
539 @priorities = IssuePriority.active
535 @allowed_statuses = @issue.new_statuses_allowed_to(User.current)
540 @allowed_statuses = @issue.new_statuses_allowed_to(User.current)
536 end
541 end
537
542
538 # Saves @issue and a time_entry from the parameters
543 # Saves @issue and a time_entry from the parameters
539 def save_issue_with_child_records
544 def save_issue_with_child_records
540 Issue.transaction do
545 Issue.transaction do
541 if params[:time_entry] && (params[:time_entry][:hours].present? || params[:time_entry][:comments].present?) && User.current.allowed_to?(:log_time, @issue.project)
546 if params[:time_entry] && (params[:time_entry][:hours].present? || params[:time_entry][:comments].present?) && User.current.allowed_to?(:log_time, @issue.project)
542 time_entry = @time_entry || TimeEntry.new
547 time_entry = @time_entry || TimeEntry.new
543 time_entry.project = @issue.project
548 time_entry.project = @issue.project
544 time_entry.issue = @issue
549 time_entry.issue = @issue
545 time_entry.user = User.current
550 time_entry.user = User.current
546 time_entry.spent_on = User.current.today
551 time_entry.spent_on = User.current.today
547 time_entry.attributes = params[:time_entry]
552 time_entry.attributes = params[:time_entry]
548 @issue.time_entries << time_entry
553 @issue.time_entries << time_entry
549 end
554 end
550
555
551 call_hook(:controller_issues_edit_before_save, { :params => params, :issue => @issue, :time_entry => time_entry, :journal => @issue.current_journal})
556 call_hook(:controller_issues_edit_before_save, { :params => params, :issue => @issue, :time_entry => time_entry, :journal => @issue.current_journal})
552 if @issue.save
557 if @issue.save
553 call_hook(:controller_issues_edit_after_save, { :params => params, :issue => @issue, :time_entry => time_entry, :journal => @issue.current_journal})
558 call_hook(:controller_issues_edit_after_save, { :params => params, :issue => @issue, :time_entry => time_entry, :journal => @issue.current_journal})
554 else
559 else
555 raise ActiveRecord::Rollback
560 raise ActiveRecord::Rollback
556 end
561 end
557 end
562 end
558 end
563 end
559
564
560 # Returns true if the issue copy should be linked
565 # Returns true if the issue copy should be linked
561 # to the original issue
566 # to the original issue
562 def link_copy?(param)
567 def link_copy?(param)
563 case Setting.link_copied_issue
568 case Setting.link_copied_issue
564 when 'yes'
569 when 'yes'
565 true
570 true
566 when 'no'
571 when 'no'
567 false
572 false
568 when 'ask'
573 when 'ask'
569 param == '1'
574 param == '1'
570 end
575 end
571 end
576 end
572
577
573 # Redirects user after a successful issue creation
578 # Redirects user after a successful issue creation
574 def redirect_after_create
579 def redirect_after_create
575 if params[:continue]
580 if params[:continue]
576 attrs = {:tracker_id => @issue.tracker, :parent_issue_id => @issue.parent_issue_id}.reject {|k,v| v.nil?}
581 attrs = {:tracker_id => @issue.tracker, :parent_issue_id => @issue.parent_issue_id}.reject {|k,v| v.nil?}
577 if params[:project_id]
582 if params[:project_id]
578 redirect_to new_project_issue_path(@issue.project, :issue => attrs)
583 redirect_to new_project_issue_path(@issue.project, :issue => attrs)
579 else
584 else
580 attrs.merge! :project_id => @issue.project_id
585 attrs.merge! :project_id => @issue.project_id
581 redirect_to new_issue_path(:issue => attrs)
586 redirect_to new_issue_path(:issue => attrs)
582 end
587 end
583 else
588 else
584 redirect_to issue_path(@issue)
589 redirect_to issue_path(@issue)
585 end
590 end
586 end
591 end
587 end
592 end
@@ -1,164 +1,164
1 <%= render :partial => 'action_menu' %>
1 <%= render :partial => 'action_menu' %>
2
2
3 <h2><%= issue_heading(@issue) %></h2>
3 <h2><%= issue_heading(@issue) %></h2>
4
4
5 <div class="<%= @issue.css_classes %> details">
5 <div class="<%= @issue.css_classes %> details">
6 <% if @prev_issue_id || @next_issue_id %>
6 <% if @prev_issue_id || @next_issue_id %>
7 <div class="next-prev-links contextual">
7 <div class="next-prev-links contextual">
8 <%= link_to_if @prev_issue_id,
8 <%= link_to_if @prev_issue_id,
9 "\xc2\xab #{l(:label_previous)}",
9 "\xc2\xab #{l(:label_previous)}",
10 (@prev_issue_id ? issue_path(@prev_issue_id) : nil),
10 (@prev_issue_id ? issue_path(@prev_issue_id) : nil),
11 :title => "##{@prev_issue_id}",
11 :title => "##{@prev_issue_id}",
12 :accesskey => accesskey(:previous) %> |
12 :accesskey => accesskey(:previous) %> |
13 <% if @issue_position && @issue_count %>
13 <% if @issue_position && @issue_count %>
14 <span class="position"><%= l(:label_item_position, :position => @issue_position, :count => @issue_count) %></span> |
14 <span class="position"><%= l(:label_item_position, :position => @issue_position, :count => @issue_count) %></span> |
15 <% end %>
15 <% end %>
16 <%= link_to_if @next_issue_id,
16 <%= link_to_if @next_issue_id,
17 "#{l(:label_next)} \xc2\xbb",
17 "#{l(:label_next)} \xc2\xbb",
18 (@next_issue_id ? issue_path(@next_issue_id) : nil),
18 (@next_issue_id ? issue_path(@next_issue_id) : nil),
19 :title => "##{@next_issue_id}",
19 :title => "##{@next_issue_id}",
20 :accesskey => accesskey(:next) %>
20 :accesskey => accesskey(:next) %>
21 </div>
21 </div>
22 <% end %>
22 <% end %>
23
23
24 <%= avatar(@issue.author, :size => "50") %>
24 <%= avatar(@issue.author, :size => "50") %>
25
25
26 <div class="subject">
26 <div class="subject">
27 <%= render_issue_subject_with_tree(@issue) %>
27 <%= render_issue_subject_with_tree(@issue) %>
28 </div>
28 </div>
29 <p class="author">
29 <p class="author">
30 <%= authoring @issue.created_on, @issue.author %>.
30 <%= authoring @issue.created_on, @issue.author %>.
31 <% if @issue.created_on != @issue.updated_on %>
31 <% if @issue.created_on != @issue.updated_on %>
32 <%= l(:label_updated_time, time_tag(@issue.updated_on)).html_safe %>.
32 <%= l(:label_updated_time, time_tag(@issue.updated_on)).html_safe %>.
33 <% end %>
33 <% end %>
34 </p>
34 </p>
35
35
36 <div class="attributes">
36 <div class="attributes">
37 <%= issue_fields_rows do |rows|
37 <%= issue_fields_rows do |rows|
38 rows.left l(:field_status), @issue.status.name, :class => 'status'
38 rows.left l(:field_status), @issue.status.name, :class => 'status'
39 rows.left l(:field_priority), @issue.priority.name, :class => 'priority'
39 rows.left l(:field_priority), @issue.priority.name, :class => 'priority'
40
40
41 unless @issue.disabled_core_fields.include?('assigned_to_id')
41 unless @issue.disabled_core_fields.include?('assigned_to_id')
42 rows.left l(:field_assigned_to), avatar(@issue.assigned_to, :size => "14").to_s.html_safe + (@issue.assigned_to ? link_to_user(@issue.assigned_to) : "-"), :class => 'assigned-to'
42 rows.left l(:field_assigned_to), avatar(@issue.assigned_to, :size => "14").to_s.html_safe + (@issue.assigned_to ? link_to_user(@issue.assigned_to) : "-"), :class => 'assigned-to'
43 end
43 end
44 unless @issue.disabled_core_fields.include?('category_id') || (@issue.category.nil? && @issue.project.issue_categories.none?)
44 unless @issue.disabled_core_fields.include?('category_id') || (@issue.category.nil? && @issue.project.issue_categories.none?)
45 rows.left l(:field_category), (@issue.category ? @issue.category.name : "-"), :class => 'category'
45 rows.left l(:field_category), (@issue.category ? @issue.category.name : "-"), :class => 'category'
46 end
46 end
47 unless @issue.disabled_core_fields.include?('fixed_version_id') || (@issue.fixed_version.nil? && @issue.assignable_versions.none?)
47 unless @issue.disabled_core_fields.include?('fixed_version_id') || (@issue.fixed_version.nil? && @issue.assignable_versions.none?)
48 rows.left l(:field_fixed_version), (@issue.fixed_version ? link_to_version(@issue.fixed_version) : "-"), :class => 'fixed-version'
48 rows.left l(:field_fixed_version), (@issue.fixed_version ? link_to_version(@issue.fixed_version) : "-"), :class => 'fixed-version'
49 end
49 end
50
50
51 unless @issue.disabled_core_fields.include?('start_date')
51 unless @issue.disabled_core_fields.include?('start_date')
52 rows.right l(:field_start_date), format_date(@issue.start_date), :class => 'start-date'
52 rows.right l(:field_start_date), format_date(@issue.start_date), :class => 'start-date'
53 end
53 end
54 unless @issue.disabled_core_fields.include?('due_date')
54 unless @issue.disabled_core_fields.include?('due_date')
55 rows.right l(:field_due_date), format_date(@issue.due_date), :class => 'due-date'
55 rows.right l(:field_due_date), format_date(@issue.due_date), :class => 'due-date'
56 end
56 end
57 unless @issue.disabled_core_fields.include?('done_ratio')
57 unless @issue.disabled_core_fields.include?('done_ratio')
58 rows.right l(:field_done_ratio), progress_bar(@issue.done_ratio, :legend => "#{@issue.done_ratio}%"), :class => 'progress'
58 rows.right l(:field_done_ratio), progress_bar(@issue.done_ratio, :legend => "#{@issue.done_ratio}%"), :class => 'progress'
59 end
59 end
60 unless @issue.disabled_core_fields.include?('estimated_hours')
60 unless @issue.disabled_core_fields.include?('estimated_hours')
61 rows.right l(:field_estimated_hours), issue_estimated_hours_details(@issue), :class => 'estimated-hours'
61 rows.right l(:field_estimated_hours), issue_estimated_hours_details(@issue), :class => 'estimated-hours'
62 end
62 end
63 if User.current.allowed_to_view_all_time_entries?(@project)
63 if User.current.allowed_to?(:view_time_entries, @project)
64 if @issue.total_spent_hours > 0
64 if @issue.total_spent_hours > 0
65 rows.right l(:label_spent_time), issue_spent_hours_details(@issue), :class => 'spent-time'
65 rows.right l(:label_spent_time), issue_spent_hours_details(@issue), :class => 'spent-time'
66 end
66 end
67 end
67 end
68 end %>
68 end %>
69 <%= render_half_width_custom_fields_rows(@issue) %>
69 <%= render_half_width_custom_fields_rows(@issue) %>
70 <%= call_hook(:view_issues_show_details_bottom, :issue => @issue) %>
70 <%= call_hook(:view_issues_show_details_bottom, :issue => @issue) %>
71 </div>
71 </div>
72
72
73 <% if @issue.description? || @issue.attachments.any? -%>
73 <% if @issue.description? || @issue.attachments.any? -%>
74 <hr />
74 <hr />
75 <% if @issue.description? %>
75 <% if @issue.description? %>
76 <div class="description">
76 <div class="description">
77 <div class="contextual">
77 <div class="contextual">
78 <%= link_to l(:button_quote), quoted_issue_path(@issue), :remote => true, :method => 'post', :class => 'icon icon-comment' if @issue.notes_addable? %>
78 <%= link_to l(:button_quote), quoted_issue_path(@issue), :remote => true, :method => 'post', :class => 'icon icon-comment' if @issue.notes_addable? %>
79 </div>
79 </div>
80
80
81 <p><strong><%=l(:field_description)%></strong></p>
81 <p><strong><%=l(:field_description)%></strong></p>
82 <div class="wiki">
82 <div class="wiki">
83 <%= textilizable @issue, :description, :attachments => @issue.attachments %>
83 <%= textilizable @issue, :description, :attachments => @issue.attachments %>
84 </div>
84 </div>
85 </div>
85 </div>
86 <% end %>
86 <% end %>
87 <%= link_to_attachments @issue, :thumbnails => true %>
87 <%= link_to_attachments @issue, :thumbnails => true %>
88 <% end -%>
88 <% end -%>
89
89
90 <%= render_full_width_custom_fields_rows(@issue) %>
90 <%= render_full_width_custom_fields_rows(@issue) %>
91
91
92 <%= call_hook(:view_issues_show_description_bottom, :issue => @issue) %>
92 <%= call_hook(:view_issues_show_description_bottom, :issue => @issue) %>
93
93
94 <% if !@issue.leaf? || User.current.allowed_to?(:manage_subtasks, @project) %>
94 <% if !@issue.leaf? || User.current.allowed_to?(:manage_subtasks, @project) %>
95 <hr />
95 <hr />
96 <div id="issue_tree">
96 <div id="issue_tree">
97 <div class="contextual">
97 <div class="contextual">
98 <%= link_to_new_subtask(@issue) if User.current.allowed_to?(:manage_subtasks, @project) %>
98 <%= link_to_new_subtask(@issue) if User.current.allowed_to?(:manage_subtasks, @project) %>
99 </div>
99 </div>
100 <p><strong><%=l(:label_subtask_plural)%></strong></p>
100 <p><strong><%=l(:label_subtask_plural)%></strong></p>
101 <%= form_tag({}, :data => {:cm_url => issues_context_menu_path}) do %>
101 <%= form_tag({}, :data => {:cm_url => issues_context_menu_path}) do %>
102 <%= render_descendants_tree(@issue) unless @issue.leaf? %>
102 <%= render_descendants_tree(@issue) unless @issue.leaf? %>
103 <% end %>
103 <% end %>
104 </div>
104 </div>
105 <% end %>
105 <% end %>
106
106
107 <% if @relations.present? || User.current.allowed_to?(:manage_issue_relations, @project) %>
107 <% if @relations.present? || User.current.allowed_to?(:manage_issue_relations, @project) %>
108 <hr />
108 <hr />
109 <div id="relations">
109 <div id="relations">
110 <%= render :partial => 'relations' %>
110 <%= render :partial => 'relations' %>
111 </div>
111 </div>
112 <% end %>
112 <% end %>
113
113
114 </div>
114 </div>
115
115
116 <% if @changesets.present? %>
116 <% if @changesets.present? %>
117 <div id="issue-changesets">
117 <div id="issue-changesets">
118 <h3><%=l(:label_associated_revisions)%></h3>
118 <h3><%=l(:label_associated_revisions)%></h3>
119 <%= render :partial => 'changesets', :locals => { :changesets => @changesets} %>
119 <%= render :partial => 'changesets', :locals => { :changesets => @changesets} %>
120 </div>
120 </div>
121 <% end %>
121 <% end %>
122
122
123 <% if @journals.present? %>
123 <% if @journals.present? %>
124 <div id="history">
124 <div id="history">
125 <h3><%=l(:label_history)%></h3>
125 <h3><%=l(:label_history)%></h3>
126 <%= render :partial => 'history', :locals => { :issue => @issue, :journals => @journals } %>
126 <%= render :partial => 'history', :locals => { :issue => @issue, :journals => @journals } %>
127 </div>
127 </div>
128 <% end %>
128 <% end %>
129
129
130
130
131 <div style="clear: both;"></div>
131 <div style="clear: both;"></div>
132 <%= render :partial => 'action_menu' %>
132 <%= render :partial => 'action_menu' %>
133
133
134 <div style="clear: both;"></div>
134 <div style="clear: both;"></div>
135 <% if @issue.editable? %>
135 <% if @issue.editable? %>
136 <div id="update" style="display:none;">
136 <div id="update" style="display:none;">
137 <h3><%= l(:button_edit) %></h3>
137 <h3><%= l(:button_edit) %></h3>
138 <%= render :partial => 'edit' %>
138 <%= render :partial => 'edit' %>
139 </div>
139 </div>
140 <% end %>
140 <% end %>
141
141
142 <% other_formats_links do |f| %>
142 <% other_formats_links do |f| %>
143 <%= f.link_to 'Atom', :url => {:key => User.current.rss_key} %>
143 <%= f.link_to 'Atom', :url => {:key => User.current.rss_key} %>
144 <%= f.link_to 'PDF' %>
144 <%= f.link_to 'PDF' %>
145 <% end %>
145 <% end %>
146
146
147 <% html_title "#{@issue.tracker.name} ##{@issue.id}: #{@issue.subject}" %>
147 <% html_title "#{@issue.tracker.name} ##{@issue.id}: #{@issue.subject}" %>
148
148
149 <% content_for :sidebar do %>
149 <% content_for :sidebar do %>
150 <%= render :partial => 'issues/sidebar' %>
150 <%= render :partial => 'issues/sidebar' %>
151
151
152 <% if User.current.allowed_to?(:add_issue_watchers, @project) ||
152 <% if User.current.allowed_to?(:add_issue_watchers, @project) ||
153 (@issue.watchers.present? && User.current.allowed_to?(:view_issue_watchers, @project)) %>
153 (@issue.watchers.present? && User.current.allowed_to?(:view_issue_watchers, @project)) %>
154 <div id="watchers">
154 <div id="watchers">
155 <%= render :partial => 'watchers/watchers', :locals => {:watched => @issue} %>
155 <%= render :partial => 'watchers/watchers', :locals => {:watched => @issue} %>
156 </div>
156 </div>
157 <% end %>
157 <% end %>
158 <% end %>
158 <% end %>
159
159
160 <% content_for :header_tags do %>
160 <% content_for :header_tags do %>
161 <%= auto_discovery_link_tag(:atom, {:format => 'atom', :key => User.current.rss_key}, :title => "#{@issue.project} - #{@issue.tracker} ##{@issue.id}: #{@issue.subject}") %>
161 <%= auto_discovery_link_tag(:atom, {:format => 'atom', :key => User.current.rss_key}, :title => "#{@issue.project} - #{@issue.tracker} ##{@issue.id}: #{@issue.subject}") %>
162 <% end %>
162 <% end %>
163
163
164 <%= context_menu %>
164 <%= context_menu %>
General Comments 0
You need to be logged in to leave comments. Login now