##// END OF EJS Templates
Sort changesets in the same order as comments on the issue details view (#1546)....
Jean-Philippe Lang -
r2455:0101e609f72a
parent child
Show More
@@ -1,496 +1,498
1 1 # Redmine - project management software
2 2 # Copyright (C) 2006-2008 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 menu_item :new_issue, :only => :new
20 20
21 21 before_filter :find_issue, :only => [:show, :edit, :reply]
22 22 before_filter :find_issues, :only => [:bulk_edit, :move, :destroy]
23 23 before_filter :find_project, :only => [:new, :update_form, :preview]
24 24 before_filter :authorize, :except => [:index, :changes, :gantt, :calendar, :preview, :update_form, :context_menu]
25 25 before_filter :find_optional_project, :only => [:index, :changes, :gantt, :calendar]
26 26 accept_key_auth :index, :changes
27 27
28 28 helper :journals
29 29 helper :projects
30 30 include ProjectsHelper
31 31 helper :custom_fields
32 32 include CustomFieldsHelper
33 33 helper :issue_relations
34 34 include IssueRelationsHelper
35 35 helper :watchers
36 36 include WatchersHelper
37 37 helper :attachments
38 38 include AttachmentsHelper
39 39 helper :queries
40 40 helper :sort
41 41 include SortHelper
42 42 include IssuesHelper
43 43 helper :timelog
44 44 include Redmine::Export::PDF
45 45
46 46 def index
47 47 retrieve_query
48 48 sort_init 'id', 'desc'
49 49 sort_update({'id' => "#{Issue.table_name}.id"}.merge(@query.columns.inject({}) {|h, c| h[c.name.to_s] = c.sortable; h}))
50 50
51 51 if @query.valid?
52 52 limit = per_page_option
53 53 respond_to do |format|
54 54 format.html { }
55 55 format.atom { }
56 56 format.csv { limit = Setting.issues_export_limit.to_i }
57 57 format.pdf { limit = Setting.issues_export_limit.to_i }
58 58 end
59 59 @issue_count = Issue.count(:include => [:status, :project], :conditions => @query.statement)
60 60 @issue_pages = Paginator.new self, @issue_count, limit, params['page']
61 61 @issues = Issue.find :all, :order => sort_clause,
62 62 :include => [ :assigned_to, :status, :tracker, :project, :priority, :category, :fixed_version ],
63 63 :conditions => @query.statement,
64 64 :limit => limit,
65 65 :offset => @issue_pages.current.offset
66 66 respond_to do |format|
67 67 format.html { render :template => 'issues/index.rhtml', :layout => !request.xhr? }
68 68 format.atom { render_feed(@issues, :title => "#{@project || Setting.app_title}: #{l(:label_issue_plural)}") }
69 69 format.csv { send_data(issues_to_csv(@issues, @project).read, :type => 'text/csv; header=present', :filename => 'export.csv') }
70 70 format.pdf { send_data(issues_to_pdf(@issues, @project), :type => 'application/pdf', :filename => 'export.pdf') }
71 71 end
72 72 else
73 73 # Send html if the query is not valid
74 74 render(:template => 'issues/index.rhtml', :layout => !request.xhr?)
75 75 end
76 76 rescue ActiveRecord::RecordNotFound
77 77 render_404
78 78 end
79 79
80 80 def changes
81 81 retrieve_query
82 82 sort_init 'id', 'desc'
83 83 sort_update({'id' => "#{Issue.table_name}.id"}.merge(@query.columns.inject({}) {|h, c| h[c.name.to_s] = c.sortable; h}))
84 84
85 85 if @query.valid?
86 86 @journals = Journal.find :all, :include => [ :details, :user, {:issue => [:project, :author, :tracker, :status]} ],
87 87 :conditions => @query.statement,
88 88 :limit => 25,
89 89 :order => "#{Journal.table_name}.created_on DESC"
90 90 end
91 91 @title = (@project ? @project.name : Setting.app_title) + ": " + (@query.new_record? ? l(:label_changes_details) : @query.name)
92 92 render :layout => false, :content_type => 'application/atom+xml'
93 93 rescue ActiveRecord::RecordNotFound
94 94 render_404
95 95 end
96 96
97 97 def show
98 98 @journals = @issue.journals.find(:all, :include => [:user, :details], :order => "#{Journal.table_name}.created_on ASC")
99 99 @journals.each_with_index {|j,i| j.indice = i+1}
100 100 @journals.reverse! if User.current.wants_comments_in_reverse_order?
101 @changesets = @issue.changesets
102 @changesets.reverse! if User.current.wants_comments_in_reverse_order?
101 103 @allowed_statuses = @issue.new_statuses_allowed_to(User.current)
102 104 @edit_allowed = User.current.allowed_to?(:edit_issues, @project)
103 105 @priorities = Enumeration.priorities
104 106 @time_entry = TimeEntry.new
105 107 respond_to do |format|
106 108 format.html { render :template => 'issues/show.rhtml' }
107 109 format.atom { render :action => 'changes', :layout => false, :content_type => 'application/atom+xml' }
108 110 format.pdf { send_data(issue_to_pdf(@issue), :type => 'application/pdf', :filename => "#{@project.identifier}-#{@issue.id}.pdf") }
109 111 end
110 112 end
111 113
112 114 # Add a new issue
113 115 # The new issue will be created from an existing one if copy_from parameter is given
114 116 def new
115 117 @issue = Issue.new
116 118 @issue.copy_from(params[:copy_from]) if params[:copy_from]
117 119 @issue.project = @project
118 120 # Tracker must be set before custom field values
119 121 @issue.tracker ||= @project.trackers.find((params[:issue] && params[:issue][:tracker_id]) || params[:tracker_id] || :first)
120 122 if @issue.tracker.nil?
121 123 flash.now[:error] = 'No tracker is associated to this project. Please check the Project settings.'
122 124 render :nothing => true, :layout => true
123 125 return
124 126 end
125 127 if params[:issue].is_a?(Hash)
126 128 @issue.attributes = params[:issue]
127 129 @issue.watcher_user_ids = params[:issue]['watcher_user_ids'] if User.current.allowed_to?(:add_issue_watchers, @project)
128 130 end
129 131 @issue.author = User.current
130 132
131 133 default_status = IssueStatus.default
132 134 unless default_status
133 135 flash.now[:error] = 'No default issue status is defined. Please check your configuration (Go to "Administration -> Issue statuses").'
134 136 render :nothing => true, :layout => true
135 137 return
136 138 end
137 139 @issue.status = default_status
138 140 @allowed_statuses = ([default_status] + default_status.find_new_statuses_allowed_to(User.current.role_for_project(@project), @issue.tracker)).uniq
139 141
140 142 if request.get? || request.xhr?
141 143 @issue.start_date ||= Date.today
142 144 else
143 145 requested_status = IssueStatus.find_by_id(params[:issue][:status_id])
144 146 # Check that the user is allowed to apply the requested status
145 147 @issue.status = (@allowed_statuses.include? requested_status) ? requested_status : default_status
146 148 if @issue.save
147 149 attach_files(@issue, params[:attachments])
148 150 flash[:notice] = l(:notice_successful_create)
149 151 Mailer.deliver_issue_add(@issue) if Setting.notified_events.include?('issue_added')
150 152 call_hook(:controller_issues_new_after_save, { :params => params, :issue => @issue})
151 153 redirect_to(params[:continue] ? { :action => 'new', :tracker_id => @issue.tracker } :
152 154 { :action => 'show', :id => @issue })
153 155 return
154 156 end
155 157 end
156 158 @priorities = Enumeration.priorities
157 159 render :layout => !request.xhr?
158 160 end
159 161
160 162 # Attributes that can be updated on workflow transition (without :edit permission)
161 163 # TODO: make it configurable (at least per role)
162 164 UPDATABLE_ATTRS_ON_TRANSITION = %w(status_id assigned_to_id fixed_version_id done_ratio) unless const_defined?(:UPDATABLE_ATTRS_ON_TRANSITION)
163 165
164 166 def edit
165 167 @allowed_statuses = @issue.new_statuses_allowed_to(User.current)
166 168 @priorities = Enumeration.priorities
167 169 @edit_allowed = User.current.allowed_to?(:edit_issues, @project)
168 170 @time_entry = TimeEntry.new
169 171
170 172 @notes = params[:notes]
171 173 journal = @issue.init_journal(User.current, @notes)
172 174 # User can change issue attributes only if he has :edit permission or if a workflow transition is allowed
173 175 if (@edit_allowed || !@allowed_statuses.empty?) && params[:issue]
174 176 attrs = params[:issue].dup
175 177 attrs.delete_if {|k,v| !UPDATABLE_ATTRS_ON_TRANSITION.include?(k) } unless @edit_allowed
176 178 attrs.delete(:status_id) unless @allowed_statuses.detect {|s| s.id.to_s == attrs[:status_id].to_s}
177 179 @issue.attributes = attrs
178 180 end
179 181
180 182 if request.post?
181 183 @time_entry = TimeEntry.new(:project => @project, :issue => @issue, :user => User.current, :spent_on => Date.today)
182 184 @time_entry.attributes = params[:time_entry]
183 185 attachments = attach_files(@issue, params[:attachments])
184 186 attachments.each {|a| journal.details << JournalDetail.new(:property => 'attachment', :prop_key => a.id, :value => a.filename)}
185 187
186 188 call_hook(:controller_issues_edit_before_save, { :params => params, :issue => @issue, :time_entry => @time_entry, :journal => journal})
187 189
188 190 if (@time_entry.hours.nil? || @time_entry.valid?) && @issue.save
189 191 # Log spend time
190 192 if User.current.allowed_to?(:log_time, @project)
191 193 @time_entry.save
192 194 end
193 195 if !journal.new_record?
194 196 # Only send notification if something was actually changed
195 197 flash[:notice] = l(:notice_successful_update)
196 198 Mailer.deliver_issue_edit(journal) if Setting.notified_events.include?('issue_updated')
197 199 end
198 200 call_hook(:controller_issues_edit_after_save, { :params => params, :issue => @issue, :time_entry => @time_entry, :journal => journal})
199 201 redirect_to(params[:back_to] || {:action => 'show', :id => @issue})
200 202 end
201 203 end
202 204 rescue ActiveRecord::StaleObjectError
203 205 # Optimistic locking exception
204 206 flash.now[:error] = l(:notice_locking_conflict)
205 207 end
206 208
207 209 def reply
208 210 journal = Journal.find(params[:journal_id]) if params[:journal_id]
209 211 if journal
210 212 user = journal.user
211 213 text = journal.notes
212 214 else
213 215 user = @issue.author
214 216 text = @issue.description
215 217 end
216 218 content = "#{ll(Setting.default_language, :text_user_wrote, user)}\\n> "
217 219 content << text.to_s.strip.gsub(%r{<pre>((.|\s)*?)</pre>}m, '[...]').gsub('"', '\"').gsub(/(\r?\n|\r\n?)/, "\\n> ") + "\\n\\n"
218 220 render(:update) { |page|
219 221 page.<< "$('notes').value = \"#{content}\";"
220 222 page.show 'update'
221 223 page << "Form.Element.focus('notes');"
222 224 page << "Element.scrollTo('update');"
223 225 page << "$('notes').scrollTop = $('notes').scrollHeight - $('notes').clientHeight;"
224 226 }
225 227 end
226 228
227 229 # Bulk edit a set of issues
228 230 def bulk_edit
229 231 if request.post?
230 232 status = params[:status_id].blank? ? nil : IssueStatus.find_by_id(params[:status_id])
231 233 priority = params[:priority_id].blank? ? nil : Enumeration.find_by_id(params[:priority_id])
232 234 assigned_to = (params[:assigned_to_id].blank? || params[:assigned_to_id] == 'none') ? nil : User.find_by_id(params[:assigned_to_id])
233 235 category = (params[:category_id].blank? || params[:category_id] == 'none') ? nil : @project.issue_categories.find_by_id(params[:category_id])
234 236 fixed_version = (params[:fixed_version_id].blank? || params[:fixed_version_id] == 'none') ? nil : @project.versions.find_by_id(params[:fixed_version_id])
235 237 custom_field_values = params[:custom_field_values] ? params[:custom_field_values].reject {|k,v| v.blank?} : nil
236 238
237 239 unsaved_issue_ids = []
238 240 @issues.each do |issue|
239 241 journal = issue.init_journal(User.current, params[:notes])
240 242 issue.priority = priority if priority
241 243 issue.assigned_to = assigned_to if assigned_to || params[:assigned_to_id] == 'none'
242 244 issue.category = category if category || params[:category_id] == 'none'
243 245 issue.fixed_version = fixed_version if fixed_version || params[:fixed_version_id] == 'none'
244 246 issue.start_date = params[:start_date] unless params[:start_date].blank?
245 247 issue.due_date = params[:due_date] unless params[:due_date].blank?
246 248 issue.done_ratio = params[:done_ratio] unless params[:done_ratio].blank?
247 249 issue.custom_field_values = custom_field_values if custom_field_values && !custom_field_values.empty?
248 250 call_hook(:controller_issues_bulk_edit_before_save, { :params => params, :issue => issue })
249 251 # Don't save any change to the issue if the user is not authorized to apply the requested status
250 252 if (status.nil? || (issue.status.new_status_allowed_to?(status, current_role, issue.tracker) && issue.status = status)) && issue.save
251 253 # Send notification for each issue (if changed)
252 254 Mailer.deliver_issue_edit(journal) if journal.details.any? && Setting.notified_events.include?('issue_updated')
253 255 else
254 256 # Keep unsaved issue ids to display them in flash error
255 257 unsaved_issue_ids << issue.id
256 258 end
257 259 end
258 260 if unsaved_issue_ids.empty?
259 261 flash[:notice] = l(:notice_successful_update) unless @issues.empty?
260 262 else
261 263 flash[:error] = l(:notice_failed_to_save_issues, :count => unsaved_issue_ids.size,
262 264 :total => @issues.size,
263 265 :ids => '#' + unsaved_issue_ids.join(', #'))
264 266 end
265 267 redirect_to(params[:back_to] || {:controller => 'issues', :action => 'index', :project_id => @project})
266 268 return
267 269 end
268 270 # Find potential statuses the user could be allowed to switch issues to
269 271 @available_statuses = Workflow.find(:all, :include => :new_status,
270 272 :conditions => {:role_id => current_role.id}).collect(&:new_status).compact.uniq.sort
271 273 @custom_fields = @project.issue_custom_fields.select {|f| f.field_format == 'list'}
272 274 end
273 275
274 276 def move
275 277 @allowed_projects = []
276 278 # find projects to which the user is allowed to move the issue
277 279 if User.current.admin?
278 280 # admin is allowed to move issues to any active (visible) project
279 281 @allowed_projects = Project.find(:all, :conditions => Project.visible_by(User.current))
280 282 else
281 283 User.current.memberships.each {|m| @allowed_projects << m.project if m.role.allowed_to?(:move_issues)}
282 284 end
283 285 @target_project = @allowed_projects.detect {|p| p.id.to_s == params[:new_project_id]} if params[:new_project_id]
284 286 @target_project ||= @project
285 287 @trackers = @target_project.trackers
286 288 if request.post?
287 289 new_tracker = params[:new_tracker_id].blank? ? nil : @target_project.trackers.find_by_id(params[:new_tracker_id])
288 290 unsaved_issue_ids = []
289 291 @issues.each do |issue|
290 292 issue.init_journal(User.current)
291 293 unsaved_issue_ids << issue.id unless issue.move_to(@target_project, new_tracker, params[:copy_options])
292 294 end
293 295 if unsaved_issue_ids.empty?
294 296 flash[:notice] = l(:notice_successful_update) unless @issues.empty?
295 297 else
296 298 flash[:error] = l(:notice_failed_to_save_issues, :count => unsaved_issue_ids.size,
297 299 :total => @issues.size,
298 300 :ids => '#' + unsaved_issue_ids.join(', #'))
299 301 end
300 302 redirect_to :controller => 'issues', :action => 'index', :project_id => @project
301 303 return
302 304 end
303 305 render :layout => false if request.xhr?
304 306 end
305 307
306 308 def destroy
307 309 @hours = TimeEntry.sum(:hours, :conditions => ['issue_id IN (?)', @issues]).to_f
308 310 if @hours > 0
309 311 case params[:todo]
310 312 when 'destroy'
311 313 # nothing to do
312 314 when 'nullify'
313 315 TimeEntry.update_all('issue_id = NULL', ['issue_id IN (?)', @issues])
314 316 when 'reassign'
315 317 reassign_to = @project.issues.find_by_id(params[:reassign_to_id])
316 318 if reassign_to.nil?
317 319 flash.now[:error] = l(:error_issue_not_found_in_project)
318 320 return
319 321 else
320 322 TimeEntry.update_all("issue_id = #{reassign_to.id}", ['issue_id IN (?)', @issues])
321 323 end
322 324 else
323 325 # display the destroy form
324 326 return
325 327 end
326 328 end
327 329 @issues.each(&:destroy)
328 330 redirect_to :action => 'index', :project_id => @project
329 331 end
330 332
331 333 def gantt
332 334 @gantt = Redmine::Helpers::Gantt.new(params)
333 335 retrieve_query
334 336 if @query.valid?
335 337 events = []
336 338 # Issues that have start and due dates
337 339 events += Issue.find(:all,
338 340 :order => "start_date, due_date",
339 341 :include => [:tracker, :status, :assigned_to, :priority, :project],
340 342 :conditions => ["(#{@query.statement}) AND (((start_date>=? and start_date<=?) or (due_date>=? and due_date<=?) or (start_date<? and due_date>?)) and start_date is not null and due_date is not null)", @gantt.date_from, @gantt.date_to, @gantt.date_from, @gantt.date_to, @gantt.date_from, @gantt.date_to]
341 343 )
342 344 # Issues that don't have a due date but that are assigned to a version with a date
343 345 events += Issue.find(:all,
344 346 :order => "start_date, effective_date",
345 347 :include => [:tracker, :status, :assigned_to, :priority, :project, :fixed_version],
346 348 :conditions => ["(#{@query.statement}) AND (((start_date>=? and start_date<=?) or (effective_date>=? and effective_date<=?) or (start_date<? and effective_date>?)) and start_date is not null and due_date is null and effective_date is not null)", @gantt.date_from, @gantt.date_to, @gantt.date_from, @gantt.date_to, @gantt.date_from, @gantt.date_to]
347 349 )
348 350 # Versions
349 351 events += Version.find(:all, :include => :project,
350 352 :conditions => ["(#{@query.project_statement}) AND effective_date BETWEEN ? AND ?", @gantt.date_from, @gantt.date_to])
351 353
352 354 @gantt.events = events
353 355 end
354 356
355 357 respond_to do |format|
356 358 format.html { render :template => "issues/gantt.rhtml", :layout => !request.xhr? }
357 359 format.png { send_data(@gantt.to_image, :disposition => 'inline', :type => 'image/png', :filename => "#{@project.nil? ? '' : "#{@project.identifier}-" }gantt.png") } if @gantt.respond_to?('to_image')
358 360 format.pdf { send_data(gantt_to_pdf(@gantt, @project), :type => 'application/pdf', :filename => "#{@project.nil? ? '' : "#{@project.identifier}-" }gantt.pdf") }
359 361 end
360 362 end
361 363
362 364 def calendar
363 365 if params[:year] and params[:year].to_i > 1900
364 366 @year = params[:year].to_i
365 367 if params[:month] and params[:month].to_i > 0 and params[:month].to_i < 13
366 368 @month = params[:month].to_i
367 369 end
368 370 end
369 371 @year ||= Date.today.year
370 372 @month ||= Date.today.month
371 373
372 374 @calendar = Redmine::Helpers::Calendar.new(Date.civil(@year, @month, 1), current_language, :month)
373 375 retrieve_query
374 376 if @query.valid?
375 377 events = []
376 378 events += Issue.find(:all,
377 379 :include => [:tracker, :status, :assigned_to, :priority, :project],
378 380 :conditions => ["(#{@query.statement}) AND ((start_date BETWEEN ? AND ?) OR (due_date BETWEEN ? AND ?))", @calendar.startdt, @calendar.enddt, @calendar.startdt, @calendar.enddt]
379 381 )
380 382 events += Version.find(:all, :include => :project,
381 383 :conditions => ["(#{@query.project_statement}) AND effective_date BETWEEN ? AND ?", @calendar.startdt, @calendar.enddt])
382 384
383 385 @calendar.events = events
384 386 end
385 387
386 388 render :layout => false if request.xhr?
387 389 end
388 390
389 391 def context_menu
390 392 @issues = Issue.find_all_by_id(params[:ids], :include => :project)
391 393 if (@issues.size == 1)
392 394 @issue = @issues.first
393 395 @allowed_statuses = @issue.new_statuses_allowed_to(User.current)
394 396 end
395 397 projects = @issues.collect(&:project).compact.uniq
396 398 @project = projects.first if projects.size == 1
397 399
398 400 @can = {:edit => (@project && User.current.allowed_to?(:edit_issues, @project)),
399 401 :log_time => (@project && User.current.allowed_to?(:log_time, @project)),
400 402 :update => (@project && (User.current.allowed_to?(:edit_issues, @project) || (User.current.allowed_to?(:change_status, @project) && @allowed_statuses && !@allowed_statuses.empty?))),
401 403 :move => (@project && User.current.allowed_to?(:move_issues, @project)),
402 404 :copy => (@issue && @project.trackers.include?(@issue.tracker) && User.current.allowed_to?(:add_issues, @project)),
403 405 :delete => (@project && User.current.allowed_to?(:delete_issues, @project))
404 406 }
405 407 if @project
406 408 @assignables = @project.assignable_users
407 409 @assignables << @issue.assigned_to if @issue && @issue.assigned_to && !@assignables.include?(@issue.assigned_to)
408 410 end
409 411
410 412 @priorities = Enumeration.priorities.reverse
411 413 @statuses = IssueStatus.find(:all, :order => 'position')
412 414 @back = request.env['HTTP_REFERER']
413 415
414 416 render :layout => false
415 417 end
416 418
417 419 def update_form
418 420 @issue = Issue.new(params[:issue])
419 421 render :action => :new, :layout => false
420 422 end
421 423
422 424 def preview
423 425 @issue = @project.issues.find_by_id(params[:id]) unless params[:id].blank?
424 426 @attachements = @issue.attachments if @issue
425 427 @text = params[:notes] || (params[:issue] ? params[:issue][:description] : nil)
426 428 render :partial => 'common/preview'
427 429 end
428 430
429 431 private
430 432 def find_issue
431 433 @issue = Issue.find(params[:id], :include => [:project, :tracker, :status, :author, :priority, :category])
432 434 @project = @issue.project
433 435 rescue ActiveRecord::RecordNotFound
434 436 render_404
435 437 end
436 438
437 439 # Filter for bulk operations
438 440 def find_issues
439 441 @issues = Issue.find_all_by_id(params[:id] || params[:ids])
440 442 raise ActiveRecord::RecordNotFound if @issues.empty?
441 443 projects = @issues.collect(&:project).compact.uniq
442 444 if projects.size == 1
443 445 @project = projects.first
444 446 else
445 447 # TODO: let users bulk edit/move/destroy issues from different projects
446 448 render_error 'Can not bulk edit/move/destroy issues from different projects' and return false
447 449 end
448 450 rescue ActiveRecord::RecordNotFound
449 451 render_404
450 452 end
451 453
452 454 def find_project
453 455 @project = Project.find(params[:project_id])
454 456 rescue ActiveRecord::RecordNotFound
455 457 render_404
456 458 end
457 459
458 460 def find_optional_project
459 461 @project = Project.find(params[:project_id]) unless params[:project_id].blank?
460 462 allowed = User.current.allowed_to?({:controller => params[:controller], :action => params[:action]}, @project, :global => true)
461 463 allowed ? true : deny_access
462 464 rescue ActiveRecord::RecordNotFound
463 465 render_404
464 466 end
465 467
466 468 # Retrieve query from session or build a new query
467 469 def retrieve_query
468 470 if !params[:query_id].blank?
469 471 cond = "project_id IS NULL"
470 472 cond << " OR project_id = #{@project.id}" if @project
471 473 @query = Query.find(params[:query_id], :conditions => cond)
472 474 @query.project = @project
473 475 session[:query] = {:id => @query.id, :project_id => @query.project_id}
474 476 else
475 477 if params[:set_filter] || session[:query].nil? || session[:query][:project_id] != (@project ? @project.id : nil)
476 478 # Give it a name, required to be valid
477 479 @query = Query.new(:name => "_")
478 480 @query.project = @project
479 481 if params[:fields] and params[:fields].is_a? Array
480 482 params[:fields].each do |field|
481 483 @query.add_filter(field, params[:operators][field], params[:values][field])
482 484 end
483 485 else
484 486 @query.available_filters.keys.each do |field|
485 487 @query.add_short_filter(field, params[field]) if params[field]
486 488 end
487 489 end
488 490 session[:query] = {:project_id => @query.project_id, :filters => @query.filters}
489 491 else
490 492 @query = Query.find_by_id(session[:query][:id]) if session[:query][:id]
491 493 @query ||= Query.new(:name => "_", :project => @project, :filters => session[:query][:filters])
492 494 @query.project = @project
493 495 end
494 496 end
495 497 end
496 498 end
@@ -1,125 +1,125
1 1 <div class="contextual">
2 2 <%= link_to_if_authorized(l(:button_update), {:controller => 'issues', :action => 'edit', :id => @issue }, :onclick => 'showAndScrollTo("update", "notes"); return false;', :class => 'icon icon-edit', :accesskey => accesskey(:edit)) %>
3 3 <%= link_to_if_authorized l(:button_log_time), {:controller => 'timelog', :action => 'edit', :issue_id => @issue}, :class => 'icon icon-time-add' %>
4 4 <%= watcher_tag(@issue, User.current) %>
5 5 <%= link_to_if_authorized l(:button_copy), {:controller => 'issues', :action => 'new', :project_id => @project, :copy_from => @issue }, :class => 'icon icon-copy' %>
6 6 <%= link_to_if_authorized l(:button_move), {:controller => 'issues', :action => 'move', :id => @issue }, :class => 'icon icon-move' %>
7 7 <%= 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' %>
8 8 </div>
9 9
10 10 <h2><%= @issue.tracker.name %> #<%= @issue.id %></h2>
11 11
12 12 <div class="<%= css_issue_classes(@issue) %>">
13 13 <%= avatar(@issue.author, :size => "64") %>
14 14 <h3><%=h @issue.subject %></h3>
15 15 <p class="author">
16 16 <%= authoring @issue.created_on, @issue.author %>.
17 17 <%= l(:label_updated_time, distance_of_time_in_words(Time.now, @issue.updated_on)) + '.' if @issue.created_on != @issue.updated_on %>
18 18 </p>
19 19
20 20 <table width="100%">
21 21 <tr>
22 22 <td style="width:15%" class="status"><b><%=l(:field_status)%>:</b></td><td style="width:35%" class="status"><%= @issue.status.name %></td>
23 23 <td style="width:15%" class="start-date"><b><%=l(:field_start_date)%>:</b></td><td style="width:35%"><%= format_date(@issue.start_date) %></td>
24 24 </tr>
25 25 <tr>
26 26 <td class="priority"><b><%=l(:field_priority)%>:</b></td><td class="priority"><%= @issue.priority.name %></td>
27 27 <td class="due-date"><b><%=l(:field_due_date)%>:</b></td><td class="due-date"><%= format_date(@issue.due_date) %></td>
28 28 </tr>
29 29 <tr>
30 30 <td class="assigned-to"><b><%=l(:field_assigned_to)%>:</b></td><td><%= avatar(@issue.assigned_to, :size => "14") %><%= @issue.assigned_to ? link_to_user(@issue.assigned_to) : "-" %></td>
31 31 <td class="progress"><b><%=l(:field_done_ratio)%>:</b></td><td class="progress"><%= progress_bar @issue.done_ratio, :width => '80px', :legend => "#{@issue.done_ratio}%" %></td>
32 32 </tr>
33 33 <tr>
34 34 <td class="category"><b><%=l(:field_category)%>:</b></td><td><%=h @issue.category ? @issue.category.name : "-" %></td>
35 35 <% if User.current.allowed_to?(:view_time_entries, @project) %>
36 36 <td class="spent-time"><b><%=l(:label_spent_time)%>:</b></td>
37 37 <td class="spent-hours"><%= @issue.spent_hours > 0 ? (link_to l_hours(@issue.spent_hours), {:controller => 'timelog', :action => 'details', :project_id => @project, :issue_id => @issue}) : "-" %></td>
38 38 <% end %>
39 39 </tr>
40 40 <tr>
41 41 <td class="fixed-version"><b><%=l(:field_fixed_version)%>:</b></td><td><%= @issue.fixed_version ? link_to_version(@issue.fixed_version) : "-" %></td>
42 42 <% if @issue.estimated_hours %>
43 43 <td class="estimated-hours"><b><%=l(:field_estimated_hours)%>:</b></td><td><%= l_hours(@issue.estimated_hours) %></td>
44 44 <% end %>
45 45 </tr>
46 46 <tr>
47 47 <% n = 0 -%>
48 48 <% @issue.custom_values.each do |value| -%>
49 49 <td valign="top"><b><%=h value.custom_field.name %>:</b></td><td valign="top"><%= simple_format(h(show_value(value))) %></td>
50 50 <% n = n + 1
51 51 if (n > 1)
52 52 n = 0 %>
53 53 </tr><tr>
54 54 <%end
55 55 end %>
56 56 </tr>
57 57 <%= call_hook(:view_issues_show_details_bottom, :issue => @issue) %>
58 58 </table>
59 59 <hr />
60 60
61 61 <div class="contextual">
62 62 <%= link_to_remote_if_authorized(l(:button_quote), { :url => {:action => 'reply', :id => @issue} }, :class => 'icon icon-comment') unless @issue.description.blank? %>
63 63 </div>
64 64
65 65 <p><strong><%=l(:field_description)%></strong></p>
66 66 <div class="wiki">
67 67 <%= textilizable @issue, :description, :attachments => @issue.attachments %>
68 68 </div>
69 69
70 70 <%= link_to_attachments @issue %>
71 71
72 72 <% if authorize_for('issue_relations', 'new') || @issue.relations.any? %>
73 73 <hr />
74 74 <div id="relations">
75 75 <%= render :partial => 'relations' %>
76 76 </div>
77 77 <% end %>
78 78
79 79 <% if User.current.allowed_to?(:add_issue_watchers, @project) ||
80 80 (@issue.watchers.any? && User.current.allowed_to?(:view_issue_watchers, @project)) %>
81 81 <hr />
82 82 <div id="watchers">
83 83 <%= render :partial => 'watchers/watchers', :locals => {:watched => @issue} %>
84 84 </div>
85 85 <% end %>
86 86
87 87 </div>
88 88
89 <% if @issue.changesets.any? && User.current.allowed_to?(:view_changesets, @project) %>
89 <% if @changesets.any? && User.current.allowed_to?(:view_changesets, @project) %>
90 90 <div id="issue-changesets">
91 91 <h3><%=l(:label_associated_revisions)%></h3>
92 <%= render :partial => 'changesets', :locals => { :changesets => @issue.changesets} %>
92 <%= render :partial => 'changesets', :locals => { :changesets => @changesets} %>
93 93 </div>
94 94 <% end %>
95 95
96 96 <% if @journals.any? %>
97 97 <div id="history">
98 98 <h3><%=l(:label_history)%></h3>
99 99 <%= render :partial => 'history', :locals => { :journals => @journals } %>
100 100 </div>
101 101 <% end %>
102 102 <div style="clear: both;"></div>
103 103
104 104 <% if authorize_for('issues', 'edit') %>
105 105 <div id="update" style="display:none;">
106 106 <h3><%= l(:button_update) %></h3>
107 107 <%= render :partial => 'edit' %>
108 108 </div>
109 109 <% end %>
110 110
111 111 <% other_formats_links do |f| %>
112 112 <%= f.link_to 'Atom', :url => {:key => User.current.rss_key} %>
113 113 <%= f.link_to 'PDF' %>
114 114 <% end %>
115 115
116 116 <% html_title "#{@issue.tracker.name} ##{@issue.id}: #{@issue.subject}" %>
117 117
118 118 <% content_for :sidebar do %>
119 119 <%= render :partial => 'issues/sidebar' %>
120 120 <% end %>
121 121
122 122 <% content_for :header_tags do %>
123 123 <%= auto_discovery_link_tag(:atom, {:format => 'atom', :key => User.current.rss_key}, :title => "#{@issue.project} - #{@issue.tracker} ##{@issue.id}: #{@issue.subject}") %>
124 124 <%= stylesheet_link_tag 'scm' %>
125 125 <% end %>
General Comments 0
You need to be logged in to leave comments. Login now