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