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