##// END OF EJS Templates
Moved users list diplayed as available watchers on the new issue form to an helper....
Jean-Philippe Lang -
r13613:9548d39a15c1
parent child
Show More
@@ -1,523 +1,519
1 # Redmine - project management software
1 # Redmine - project management software
2 # Copyright (C) 2006-2015 Jean-Philippe Lang
2 # Copyright (C) 2006-2015 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 :find_project, :only => [:new, :create, :update_form]
24 before_filter :find_project, :only => [:new, :create, :update_form]
25 before_filter :authorize, :except => [:index]
25 before_filter :authorize, :except => [:index]
26 before_filter :find_optional_project, :only => [:index]
26 before_filter :find_optional_project, :only => [:index]
27 before_filter :build_new_issue_from_params, :only => [:new, :create, :update_form]
27 before_filter :build_new_issue_from_params, :only => [:new, :create, :update_form]
28 accept_rss_auth :index, :show
28 accept_rss_auth :index, :show
29 accept_api_auth :index, :show, :create, :update, :destroy
29 accept_api_auth :index, :show, :create, :update, :destroy
30
30
31 rescue_from Query::StatementInvalid, :with => :query_statement_invalid
31 rescue_from Query::StatementInvalid, :with => :query_statement_invalid
32
32
33 helper :journals
33 helper :journals
34 helper :projects
34 helper :projects
35 include ProjectsHelper
35 include ProjectsHelper
36 helper :custom_fields
36 helper :custom_fields
37 include CustomFieldsHelper
37 include CustomFieldsHelper
38 helper :issue_relations
38 helper :issue_relations
39 include IssueRelationsHelper
39 include IssueRelationsHelper
40 helper :watchers
40 helper :watchers
41 include WatchersHelper
41 include WatchersHelper
42 helper :attachments
42 helper :attachments
43 include AttachmentsHelper
43 include AttachmentsHelper
44 helper :queries
44 helper :queries
45 include QueriesHelper
45 include QueriesHelper
46 helper :repositories
46 helper :repositories
47 include RepositoriesHelper
47 include RepositoriesHelper
48 helper :sort
48 helper :sort
49 include SortHelper
49 include SortHelper
50 include IssuesHelper
50 include IssuesHelper
51 helper :timelog
51 helper :timelog
52
52
53 def index
53 def index
54 retrieve_query
54 retrieve_query
55 sort_init(@query.sort_criteria.empty? ? [['id', 'desc']] : @query.sort_criteria)
55 sort_init(@query.sort_criteria.empty? ? [['id', 'desc']] : @query.sort_criteria)
56 sort_update(@query.sortable_columns)
56 sort_update(@query.sortable_columns)
57 @query.sort_criteria = sort_criteria.to_a
57 @query.sort_criteria = sort_criteria.to_a
58
58
59 if @query.valid?
59 if @query.valid?
60 case params[:format]
60 case params[:format]
61 when 'csv', 'pdf'
61 when 'csv', 'pdf'
62 @limit = Setting.issues_export_limit.to_i
62 @limit = Setting.issues_export_limit.to_i
63 if params[:columns] == 'all'
63 if params[:columns] == 'all'
64 @query.column_names = @query.available_inline_columns.map(&:name)
64 @query.column_names = @query.available_inline_columns.map(&:name)
65 end
65 end
66 when 'atom'
66 when 'atom'
67 @limit = Setting.feeds_limit.to_i
67 @limit = Setting.feeds_limit.to_i
68 when 'xml', 'json'
68 when 'xml', 'json'
69 @offset, @limit = api_offset_and_limit
69 @offset, @limit = api_offset_and_limit
70 @query.column_names = %w(author)
70 @query.column_names = %w(author)
71 else
71 else
72 @limit = per_page_option
72 @limit = per_page_option
73 end
73 end
74
74
75 @issue_count = @query.issue_count
75 @issue_count = @query.issue_count
76 @issue_pages = Paginator.new @issue_count, @limit, params['page']
76 @issue_pages = Paginator.new @issue_count, @limit, params['page']
77 @offset ||= @issue_pages.offset
77 @offset ||= @issue_pages.offset
78 @issues = @query.issues(:include => [:assigned_to, :tracker, :priority, :category, :fixed_version],
78 @issues = @query.issues(:include => [:assigned_to, :tracker, :priority, :category, :fixed_version],
79 :order => sort_clause,
79 :order => sort_clause,
80 :offset => @offset,
80 :offset => @offset,
81 :limit => @limit)
81 :limit => @limit)
82 @issue_count_by_group = @query.issue_count_by_group
82 @issue_count_by_group = @query.issue_count_by_group
83
83
84 respond_to do |format|
84 respond_to do |format|
85 format.html { render :template => 'issues/index', :layout => !request.xhr? }
85 format.html { render :template => 'issues/index', :layout => !request.xhr? }
86 format.api {
86 format.api {
87 Issue.load_visible_relations(@issues) if include_in_api_response?('relations')
87 Issue.load_visible_relations(@issues) if include_in_api_response?('relations')
88 }
88 }
89 format.atom { render_feed(@issues, :title => "#{@project || Setting.app_title}: #{l(:label_issue_plural)}") }
89 format.atom { render_feed(@issues, :title => "#{@project || Setting.app_title}: #{l(:label_issue_plural)}") }
90 format.csv { send_data(query_to_csv(@issues, @query, params), :type => 'text/csv; header=present', :filename => 'issues.csv') }
90 format.csv { send_data(query_to_csv(@issues, @query, params), :type => 'text/csv; header=present', :filename => 'issues.csv') }
91 format.pdf { send_file_headers! :type => 'application/pdf', :filename => 'issues.pdf' }
91 format.pdf { send_file_headers! :type => 'application/pdf', :filename => 'issues.pdf' }
92 end
92 end
93 else
93 else
94 respond_to do |format|
94 respond_to do |format|
95 format.html { render(:template => 'issues/index', :layout => !request.xhr?) }
95 format.html { render(:template => 'issues/index', :layout => !request.xhr?) }
96 format.any(:atom, :csv, :pdf) { render(:nothing => true) }
96 format.any(:atom, :csv, :pdf) { render(:nothing => true) }
97 format.api { render_validation_errors(@query) }
97 format.api { render_validation_errors(@query) }
98 end
98 end
99 end
99 end
100 rescue ActiveRecord::RecordNotFound
100 rescue ActiveRecord::RecordNotFound
101 render_404
101 render_404
102 end
102 end
103
103
104 def show
104 def show
105 @journals = @issue.journals.includes(:user, :details).
105 @journals = @issue.journals.includes(:user, :details).
106 references(:user, :details).
106 references(:user, :details).
107 reorder("#{Journal.table_name}.id ASC").to_a
107 reorder("#{Journal.table_name}.id ASC").to_a
108 @journals.each_with_index {|j,i| j.indice = i+1}
108 @journals.each_with_index {|j,i| j.indice = i+1}
109 @journals.reject!(&:private_notes?) unless User.current.allowed_to?(:view_private_notes, @issue.project)
109 @journals.reject!(&:private_notes?) unless User.current.allowed_to?(:view_private_notes, @issue.project)
110 Journal.preload_journals_details_custom_fields(@journals)
110 Journal.preload_journals_details_custom_fields(@journals)
111 @journals.select! {|journal| journal.notes? || journal.visible_details.any?}
111 @journals.select! {|journal| journal.notes? || journal.visible_details.any?}
112 @journals.reverse! if User.current.wants_comments_in_reverse_order?
112 @journals.reverse! if User.current.wants_comments_in_reverse_order?
113
113
114 @changesets = @issue.changesets.visible.to_a
114 @changesets = @issue.changesets.visible.to_a
115 @changesets.reverse! if User.current.wants_comments_in_reverse_order?
115 @changesets.reverse! if User.current.wants_comments_in_reverse_order?
116
116
117 @relations = @issue.relations.select {|r| r.other_issue(@issue) && r.other_issue(@issue).visible? }
117 @relations = @issue.relations.select {|r| r.other_issue(@issue) && r.other_issue(@issue).visible? }
118 @allowed_statuses = @issue.new_statuses_allowed_to(User.current)
118 @allowed_statuses = @issue.new_statuses_allowed_to(User.current)
119 @edit_allowed = User.current.allowed_to?(:edit_issues, @project)
119 @edit_allowed = User.current.allowed_to?(:edit_issues, @project)
120 @priorities = IssuePriority.active
120 @priorities = IssuePriority.active
121 @time_entry = TimeEntry.new(:issue => @issue, :project => @issue.project)
121 @time_entry = TimeEntry.new(:issue => @issue, :project => @issue.project)
122 @relation = IssueRelation.new
122 @relation = IssueRelation.new
123
123
124 respond_to do |format|
124 respond_to do |format|
125 format.html {
125 format.html {
126 retrieve_previous_and_next_issue_ids
126 retrieve_previous_and_next_issue_ids
127 render :template => 'issues/show'
127 render :template => 'issues/show'
128 }
128 }
129 format.api
129 format.api
130 format.atom { render :template => 'journals/index', :layout => false, :content_type => 'application/atom+xml' }
130 format.atom { render :template => 'journals/index', :layout => false, :content_type => 'application/atom+xml' }
131 format.pdf {
131 format.pdf {
132 send_file_headers! :type => 'application/pdf', :filename => "#{@project.identifier}-#{@issue.id}.pdf"
132 send_file_headers! :type => 'application/pdf', :filename => "#{@project.identifier}-#{@issue.id}.pdf"
133 }
133 }
134 end
134 end
135 end
135 end
136
136
137 # Add a new issue
137 # Add a new issue
138 # The new issue will be created from an existing one if copy_from parameter is given
138 # The new issue will be created from an existing one if copy_from parameter is given
139 def new
139 def new
140 respond_to do |format|
140 respond_to do |format|
141 format.html { render :action => 'new', :layout => !request.xhr? }
141 format.html { render :action => 'new', :layout => !request.xhr? }
142 end
142 end
143 end
143 end
144
144
145 def create
145 def create
146 unless User.current.allowed_to?(:add_issues, @issue.project)
146 unless User.current.allowed_to?(:add_issues, @issue.project)
147 raise ::Unauthorized
147 raise ::Unauthorized
148 end
148 end
149 call_hook(:controller_issues_new_before_save, { :params => params, :issue => @issue })
149 call_hook(:controller_issues_new_before_save, { :params => params, :issue => @issue })
150 @issue.save_attachments(params[:attachments] || (params[:issue] && params[:issue][:uploads]))
150 @issue.save_attachments(params[:attachments] || (params[:issue] && params[:issue][:uploads]))
151 if @issue.save
151 if @issue.save
152 call_hook(:controller_issues_new_after_save, { :params => params, :issue => @issue})
152 call_hook(:controller_issues_new_after_save, { :params => params, :issue => @issue})
153 respond_to do |format|
153 respond_to do |format|
154 format.html {
154 format.html {
155 render_attachment_warning_if_needed(@issue)
155 render_attachment_warning_if_needed(@issue)
156 flash[:notice] = l(:notice_issue_successful_create, :id => view_context.link_to("##{@issue.id}", issue_path(@issue), :title => @issue.subject))
156 flash[:notice] = l(:notice_issue_successful_create, :id => view_context.link_to("##{@issue.id}", issue_path(@issue), :title => @issue.subject))
157 if params[:continue]
157 if params[:continue]
158 attrs = {:tracker_id => @issue.tracker, :parent_issue_id => @issue.parent_issue_id}.reject {|k,v| v.nil?}
158 attrs = {:tracker_id => @issue.tracker, :parent_issue_id => @issue.parent_issue_id}.reject {|k,v| v.nil?}
159 redirect_to new_project_issue_path(@issue.project, :issue => attrs)
159 redirect_to new_project_issue_path(@issue.project, :issue => attrs)
160 else
160 else
161 redirect_to issue_path(@issue)
161 redirect_to issue_path(@issue)
162 end
162 end
163 }
163 }
164 format.api { render :action => 'show', :status => :created, :location => issue_url(@issue) }
164 format.api { render :action => 'show', :status => :created, :location => issue_url(@issue) }
165 end
165 end
166 return
166 return
167 else
167 else
168 respond_to do |format|
168 respond_to do |format|
169 format.html { render :action => 'new' }
169 format.html { render :action => 'new' }
170 format.api { render_validation_errors(@issue) }
170 format.api { render_validation_errors(@issue) }
171 end
171 end
172 end
172 end
173 end
173 end
174
174
175 def edit
175 def edit
176 return unless update_issue_from_params
176 return unless update_issue_from_params
177
177
178 respond_to do |format|
178 respond_to do |format|
179 format.html { }
179 format.html { }
180 format.xml { }
180 format.xml { }
181 end
181 end
182 end
182 end
183
183
184 def update
184 def update
185 return unless update_issue_from_params
185 return unless update_issue_from_params
186 @issue.save_attachments(params[:attachments] || (params[:issue] && params[:issue][:uploads]))
186 @issue.save_attachments(params[:attachments] || (params[:issue] && params[:issue][:uploads]))
187 saved = false
187 saved = false
188 begin
188 begin
189 saved = save_issue_with_child_records
189 saved = save_issue_with_child_records
190 rescue ActiveRecord::StaleObjectError
190 rescue ActiveRecord::StaleObjectError
191 @conflict = true
191 @conflict = true
192 if params[:last_journal_id]
192 if params[:last_journal_id]
193 @conflict_journals = @issue.journals_after(params[:last_journal_id]).to_a
193 @conflict_journals = @issue.journals_after(params[:last_journal_id]).to_a
194 @conflict_journals.reject!(&:private_notes?) unless User.current.allowed_to?(:view_private_notes, @issue.project)
194 @conflict_journals.reject!(&:private_notes?) unless User.current.allowed_to?(:view_private_notes, @issue.project)
195 end
195 end
196 end
196 end
197
197
198 if saved
198 if saved
199 render_attachment_warning_if_needed(@issue)
199 render_attachment_warning_if_needed(@issue)
200 flash[:notice] = l(:notice_successful_update) unless @issue.current_journal.new_record?
200 flash[:notice] = l(:notice_successful_update) unless @issue.current_journal.new_record?
201
201
202 respond_to do |format|
202 respond_to do |format|
203 format.html { redirect_back_or_default issue_path(@issue) }
203 format.html { redirect_back_or_default issue_path(@issue) }
204 format.api { render_api_ok }
204 format.api { render_api_ok }
205 end
205 end
206 else
206 else
207 respond_to do |format|
207 respond_to do |format|
208 format.html { render :action => 'edit' }
208 format.html { render :action => 'edit' }
209 format.api { render_validation_errors(@issue) }
209 format.api { render_validation_errors(@issue) }
210 end
210 end
211 end
211 end
212 end
212 end
213
213
214 # Updates the issue form when changing the project, status or tracker
214 # Updates the issue form when changing the project, status or tracker
215 # on issue creation/update
215 # on issue creation/update
216 def update_form
216 def update_form
217 end
217 end
218
218
219 # Bulk edit/copy a set of issues
219 # Bulk edit/copy a set of issues
220 def bulk_edit
220 def bulk_edit
221 @issues.sort!
221 @issues.sort!
222 @copy = params[:copy].present?
222 @copy = params[:copy].present?
223 @notes = params[:notes]
223 @notes = params[:notes]
224
224
225 if @copy
225 if @copy
226 unless User.current.allowed_to?(:copy_issues, @projects)
226 unless User.current.allowed_to?(:copy_issues, @projects)
227 raise ::Unauthorized
227 raise ::Unauthorized
228 end
228 end
229 end
229 end
230
230
231 @allowed_projects = Issue.allowed_target_projects
231 @allowed_projects = Issue.allowed_target_projects
232 if params[:issue]
232 if params[:issue]
233 @target_project = @allowed_projects.detect {|p| p.id.to_s == params[:issue][:project_id].to_s}
233 @target_project = @allowed_projects.detect {|p| p.id.to_s == params[:issue][:project_id].to_s}
234 if @target_project
234 if @target_project
235 target_projects = [@target_project]
235 target_projects = [@target_project]
236 end
236 end
237 end
237 end
238 target_projects ||= @projects
238 target_projects ||= @projects
239
239
240 if @copy
240 if @copy
241 # Copied issues will get their default statuses
241 # Copied issues will get their default statuses
242 @available_statuses = []
242 @available_statuses = []
243 else
243 else
244 @available_statuses = @issues.map(&:new_statuses_allowed_to).reduce(:&)
244 @available_statuses = @issues.map(&:new_statuses_allowed_to).reduce(:&)
245 end
245 end
246 @custom_fields = target_projects.map{|p|p.all_issue_custom_fields.visible}.reduce(:&)
246 @custom_fields = target_projects.map{|p|p.all_issue_custom_fields.visible}.reduce(:&)
247 @assignables = target_projects.map(&:assignable_users).reduce(:&)
247 @assignables = target_projects.map(&:assignable_users).reduce(:&)
248 @trackers = target_projects.map(&:trackers).reduce(:&)
248 @trackers = target_projects.map(&:trackers).reduce(:&)
249 @versions = target_projects.map {|p| p.shared_versions.open}.reduce(:&)
249 @versions = target_projects.map {|p| p.shared_versions.open}.reduce(:&)
250 @categories = target_projects.map {|p| p.issue_categories}.reduce(:&)
250 @categories = target_projects.map {|p| p.issue_categories}.reduce(:&)
251 if @copy
251 if @copy
252 @attachments_present = @issues.detect {|i| i.attachments.any?}.present?
252 @attachments_present = @issues.detect {|i| i.attachments.any?}.present?
253 @subtasks_present = @issues.detect {|i| !i.leaf?}.present?
253 @subtasks_present = @issues.detect {|i| !i.leaf?}.present?
254 end
254 end
255
255
256 @safe_attributes = @issues.map(&:safe_attribute_names).reduce(:&)
256 @safe_attributes = @issues.map(&:safe_attribute_names).reduce(:&)
257
257
258 @issue_params = params[:issue] || {}
258 @issue_params = params[:issue] || {}
259 @issue_params[:custom_field_values] ||= {}
259 @issue_params[:custom_field_values] ||= {}
260 end
260 end
261
261
262 def bulk_update
262 def bulk_update
263 @issues.sort!
263 @issues.sort!
264 @copy = params[:copy].present?
264 @copy = params[:copy].present?
265 attributes = parse_params_for_bulk_issue_attributes(params)
265 attributes = parse_params_for_bulk_issue_attributes(params)
266
266
267 if @copy
267 if @copy
268 unless User.current.allowed_to?(:copy_issues, @projects)
268 unless User.current.allowed_to?(:copy_issues, @projects)
269 raise ::Unauthorized
269 raise ::Unauthorized
270 end
270 end
271 target_projects = @projects
271 target_projects = @projects
272 if attributes['project_id'].present?
272 if attributes['project_id'].present?
273 target_projects = Project.where(:id => attributes['project_id']).to_a
273 target_projects = Project.where(:id => attributes['project_id']).to_a
274 end
274 end
275 unless User.current.allowed_to?(:add_issues, target_projects)
275 unless User.current.allowed_to?(:add_issues, target_projects)
276 raise ::Unauthorized
276 raise ::Unauthorized
277 end
277 end
278 end
278 end
279
279
280 unsaved_issues = []
280 unsaved_issues = []
281 saved_issues = []
281 saved_issues = []
282
282
283 if @copy && params[:copy_subtasks].present?
283 if @copy && params[:copy_subtasks].present?
284 # Descendant issues will be copied with the parent task
284 # Descendant issues will be copied with the parent task
285 # Don't copy them twice
285 # Don't copy them twice
286 @issues.reject! {|issue| @issues.detect {|other| issue.is_descendant_of?(other)}}
286 @issues.reject! {|issue| @issues.detect {|other| issue.is_descendant_of?(other)}}
287 end
287 end
288
288
289 @issues.each do |orig_issue|
289 @issues.each do |orig_issue|
290 orig_issue.reload
290 orig_issue.reload
291 if @copy
291 if @copy
292 issue = orig_issue.copy({},
292 issue = orig_issue.copy({},
293 :attachments => params[:copy_attachments].present?,
293 :attachments => params[:copy_attachments].present?,
294 :subtasks => params[:copy_subtasks].present?,
294 :subtasks => params[:copy_subtasks].present?,
295 :link => link_copy?(params[:link_copy])
295 :link => link_copy?(params[:link_copy])
296 )
296 )
297 else
297 else
298 issue = orig_issue
298 issue = orig_issue
299 end
299 end
300 journal = issue.init_journal(User.current, params[:notes])
300 journal = issue.init_journal(User.current, params[:notes])
301 issue.safe_attributes = attributes
301 issue.safe_attributes = attributes
302 call_hook(:controller_issues_bulk_edit_before_save, { :params => params, :issue => issue })
302 call_hook(:controller_issues_bulk_edit_before_save, { :params => params, :issue => issue })
303 if issue.save
303 if issue.save
304 saved_issues << issue
304 saved_issues << issue
305 else
305 else
306 unsaved_issues << orig_issue
306 unsaved_issues << orig_issue
307 end
307 end
308 end
308 end
309
309
310 if unsaved_issues.empty?
310 if unsaved_issues.empty?
311 flash[:notice] = l(:notice_successful_update) unless saved_issues.empty?
311 flash[:notice] = l(:notice_successful_update) unless saved_issues.empty?
312 if params[:follow]
312 if params[:follow]
313 if @issues.size == 1 && saved_issues.size == 1
313 if @issues.size == 1 && saved_issues.size == 1
314 redirect_to issue_path(saved_issues.first)
314 redirect_to issue_path(saved_issues.first)
315 elsif saved_issues.map(&:project).uniq.size == 1
315 elsif saved_issues.map(&:project).uniq.size == 1
316 redirect_to project_issues_path(saved_issues.map(&:project).first)
316 redirect_to project_issues_path(saved_issues.map(&:project).first)
317 end
317 end
318 else
318 else
319 redirect_back_or_default _project_issues_path(@project)
319 redirect_back_or_default _project_issues_path(@project)
320 end
320 end
321 else
321 else
322 @saved_issues = @issues
322 @saved_issues = @issues
323 @unsaved_issues = unsaved_issues
323 @unsaved_issues = unsaved_issues
324 @issues = Issue.visible.where(:id => @unsaved_issues.map(&:id)).to_a
324 @issues = Issue.visible.where(:id => @unsaved_issues.map(&:id)).to_a
325 bulk_edit
325 bulk_edit
326 render :action => 'bulk_edit'
326 render :action => 'bulk_edit'
327 end
327 end
328 end
328 end
329
329
330 def destroy
330 def destroy
331 @hours = TimeEntry.where(:issue_id => @issues.map(&:id)).sum(:hours).to_f
331 @hours = TimeEntry.where(:issue_id => @issues.map(&:id)).sum(:hours).to_f
332 if @hours > 0
332 if @hours > 0
333 case params[:todo]
333 case params[:todo]
334 when 'destroy'
334 when 'destroy'
335 # nothing to do
335 # nothing to do
336 when 'nullify'
336 when 'nullify'
337 TimeEntry.where(['issue_id IN (?)', @issues]).update_all('issue_id = NULL')
337 TimeEntry.where(['issue_id IN (?)', @issues]).update_all('issue_id = NULL')
338 when 'reassign'
338 when 'reassign'
339 reassign_to = @project.issues.find_by_id(params[:reassign_to_id])
339 reassign_to = @project.issues.find_by_id(params[:reassign_to_id])
340 if reassign_to.nil?
340 if reassign_to.nil?
341 flash.now[:error] = l(:error_issue_not_found_in_project)
341 flash.now[:error] = l(:error_issue_not_found_in_project)
342 return
342 return
343 else
343 else
344 TimeEntry.where(['issue_id IN (?)', @issues]).
344 TimeEntry.where(['issue_id IN (?)', @issues]).
345 update_all("issue_id = #{reassign_to.id}")
345 update_all("issue_id = #{reassign_to.id}")
346 end
346 end
347 else
347 else
348 # display the destroy form if it's a user request
348 # display the destroy form if it's a user request
349 return unless api_request?
349 return unless api_request?
350 end
350 end
351 end
351 end
352 @issues.each do |issue|
352 @issues.each do |issue|
353 begin
353 begin
354 issue.reload.destroy
354 issue.reload.destroy
355 rescue ::ActiveRecord::RecordNotFound # raised by #reload if issue no longer exists
355 rescue ::ActiveRecord::RecordNotFound # raised by #reload if issue no longer exists
356 # nothing to do, issue was already deleted (eg. by a parent)
356 # nothing to do, issue was already deleted (eg. by a parent)
357 end
357 end
358 end
358 end
359 respond_to do |format|
359 respond_to do |format|
360 format.html { redirect_back_or_default _project_issues_path(@project) }
360 format.html { redirect_back_or_default _project_issues_path(@project) }
361 format.api { render_api_ok }
361 format.api { render_api_ok }
362 end
362 end
363 end
363 end
364
364
365 private
365 private
366
366
367 def find_project
367 def find_project
368 project_id = params[:project_id] || (params[:issue] && params[:issue][:project_id])
368 project_id = params[:project_id] || (params[:issue] && params[:issue][:project_id])
369 @project = Project.find(project_id)
369 @project = Project.find(project_id)
370 rescue ActiveRecord::RecordNotFound
370 rescue ActiveRecord::RecordNotFound
371 render_404
371 render_404
372 end
372 end
373
373
374 def retrieve_previous_and_next_issue_ids
374 def retrieve_previous_and_next_issue_ids
375 retrieve_query_from_session
375 retrieve_query_from_session
376 if @query
376 if @query
377 sort_init(@query.sort_criteria.empty? ? [['id', 'desc']] : @query.sort_criteria)
377 sort_init(@query.sort_criteria.empty? ? [['id', 'desc']] : @query.sort_criteria)
378 sort_update(@query.sortable_columns, 'issues_index_sort')
378 sort_update(@query.sortable_columns, 'issues_index_sort')
379 limit = 500
379 limit = 500
380 issue_ids = @query.issue_ids(:order => sort_clause, :limit => (limit + 1), :include => [:assigned_to, :tracker, :priority, :category, :fixed_version])
380 issue_ids = @query.issue_ids(:order => sort_clause, :limit => (limit + 1), :include => [:assigned_to, :tracker, :priority, :category, :fixed_version])
381 if (idx = issue_ids.index(@issue.id)) && idx < limit
381 if (idx = issue_ids.index(@issue.id)) && idx < limit
382 if issue_ids.size < 500
382 if issue_ids.size < 500
383 @issue_position = idx + 1
383 @issue_position = idx + 1
384 @issue_count = issue_ids.size
384 @issue_count = issue_ids.size
385 end
385 end
386 @prev_issue_id = issue_ids[idx - 1] if idx > 0
386 @prev_issue_id = issue_ids[idx - 1] if idx > 0
387 @next_issue_id = issue_ids[idx + 1] if idx < (issue_ids.size - 1)
387 @next_issue_id = issue_ids[idx + 1] if idx < (issue_ids.size - 1)
388 end
388 end
389 end
389 end
390 end
390 end
391
391
392 # Used by #edit and #update to set some common instance variables
392 # Used by #edit and #update to set some common instance variables
393 # from the params
393 # from the params
394 # TODO: Refactor, not everything in here is needed by #edit
394 # TODO: Refactor, not everything in here is needed by #edit
395 def update_issue_from_params
395 def update_issue_from_params
396 @edit_allowed = User.current.allowed_to?(:edit_issues, @project)
396 @edit_allowed = User.current.allowed_to?(:edit_issues, @project)
397 @time_entry = TimeEntry.new(:issue => @issue, :project => @issue.project)
397 @time_entry = TimeEntry.new(:issue => @issue, :project => @issue.project)
398 if params[:time_entry]
398 if params[:time_entry]
399 @time_entry.attributes = params[:time_entry]
399 @time_entry.attributes = params[:time_entry]
400 end
400 end
401
401
402 @issue.init_journal(User.current)
402 @issue.init_journal(User.current)
403
403
404 issue_attributes = params[:issue]
404 issue_attributes = params[:issue]
405 if issue_attributes && params[:conflict_resolution]
405 if issue_attributes && params[:conflict_resolution]
406 case params[:conflict_resolution]
406 case params[:conflict_resolution]
407 when 'overwrite'
407 when 'overwrite'
408 issue_attributes = issue_attributes.dup
408 issue_attributes = issue_attributes.dup
409 issue_attributes.delete(:lock_version)
409 issue_attributes.delete(:lock_version)
410 when 'add_notes'
410 when 'add_notes'
411 issue_attributes = issue_attributes.slice(:notes)
411 issue_attributes = issue_attributes.slice(:notes)
412 when 'cancel'
412 when 'cancel'
413 redirect_to issue_path(@issue)
413 redirect_to issue_path(@issue)
414 return false
414 return false
415 end
415 end
416 end
416 end
417 @issue.safe_attributes = issue_attributes
417 @issue.safe_attributes = issue_attributes
418 @priorities = IssuePriority.active
418 @priorities = IssuePriority.active
419 @allowed_statuses = @issue.new_statuses_allowed_to(User.current)
419 @allowed_statuses = @issue.new_statuses_allowed_to(User.current)
420 true
420 true
421 end
421 end
422
422
423 # TODO: Refactor, lots of extra code in here
423 # TODO: Refactor, lots of extra code in here
424 # TODO: Changing tracker on an existing issue should not trigger this
424 # TODO: Changing tracker on an existing issue should not trigger this
425 def build_new_issue_from_params
425 def build_new_issue_from_params
426 if params[:id].blank?
426 if params[:id].blank?
427 @issue = Issue.new
427 @issue = Issue.new
428 if params[:copy_from]
428 if params[:copy_from]
429 begin
429 begin
430 @issue.init_journal(User.current)
430 @issue.init_journal(User.current)
431 @copy_from = Issue.visible.find(params[:copy_from])
431 @copy_from = Issue.visible.find(params[:copy_from])
432 unless User.current.allowed_to?(:copy_issues, @copy_from.project)
432 unless User.current.allowed_to?(:copy_issues, @copy_from.project)
433 raise ::Unauthorized
433 raise ::Unauthorized
434 end
434 end
435 @link_copy = link_copy?(params[:link_copy]) || request.get?
435 @link_copy = link_copy?(params[:link_copy]) || request.get?
436 @copy_attachments = params[:copy_attachments].present? || request.get?
436 @copy_attachments = params[:copy_attachments].present? || request.get?
437 @copy_subtasks = params[:copy_subtasks].present? || request.get?
437 @copy_subtasks = params[:copy_subtasks].present? || request.get?
438 @issue.copy_from(@copy_from, :attachments => @copy_attachments, :subtasks => @copy_subtasks, :link => @link_copy)
438 @issue.copy_from(@copy_from, :attachments => @copy_attachments, :subtasks => @copy_subtasks, :link => @link_copy)
439 rescue ActiveRecord::RecordNotFound
439 rescue ActiveRecord::RecordNotFound
440 render_404
440 render_404
441 return
441 return
442 end
442 end
443 end
443 end
444 @issue.project = @project
444 @issue.project = @project
445 @issue.author ||= User.current
445 @issue.author ||= User.current
446 @issue.start_date ||= Date.today if Setting.default_issue_start_date_to_creation_date?
446 @issue.start_date ||= Date.today if Setting.default_issue_start_date_to_creation_date?
447 else
447 else
448 @issue = @project.issues.visible.find(params[:id])
448 @issue = @project.issues.visible.find(params[:id])
449 end
449 end
450
450
451 if attrs = params[:issue].deep_dup
451 if attrs = params[:issue].deep_dup
452 if params[:was_default_status] == attrs[:status_id]
452 if params[:was_default_status] == attrs[:status_id]
453 attrs.delete(:status_id)
453 attrs.delete(:status_id)
454 end
454 end
455 @issue.safe_attributes = attrs
455 @issue.safe_attributes = attrs
456 end
456 end
457 @issue.tracker ||= @project.trackers.first
457 @issue.tracker ||= @project.trackers.first
458 if @issue.tracker.nil?
458 if @issue.tracker.nil?
459 render_error l(:error_no_tracker_in_project)
459 render_error l(:error_no_tracker_in_project)
460 return false
460 return false
461 end
461 end
462 if @issue.status.nil?
462 if @issue.status.nil?
463 render_error l(:error_no_default_issue_status)
463 render_error l(:error_no_default_issue_status)
464 return false
464 return false
465 end
465 end
466
466
467 @priorities = IssuePriority.active
467 @priorities = IssuePriority.active
468 @allowed_statuses = @issue.new_statuses_allowed_to(User.current, @issue.new_record?)
468 @allowed_statuses = @issue.new_statuses_allowed_to(User.current, @issue.new_record?)
469 @available_watchers = @issue.watcher_users
470 if @issue.project.users.count <= 20
471 @available_watchers = (@available_watchers + @issue.project.users.sort).uniq
472 end
473 end
469 end
474
470
475 def parse_params_for_bulk_issue_attributes(params)
471 def parse_params_for_bulk_issue_attributes(params)
476 attributes = (params[:issue] || {}).reject {|k,v| v.blank?}
472 attributes = (params[:issue] || {}).reject {|k,v| v.blank?}
477 attributes.keys.each {|k| attributes[k] = '' if attributes[k] == 'none'}
473 attributes.keys.each {|k| attributes[k] = '' if attributes[k] == 'none'}
478 if custom = attributes[:custom_field_values]
474 if custom = attributes[:custom_field_values]
479 custom.reject! {|k,v| v.blank?}
475 custom.reject! {|k,v| v.blank?}
480 custom.keys.each do |k|
476 custom.keys.each do |k|
481 if custom[k].is_a?(Array)
477 if custom[k].is_a?(Array)
482 custom[k] << '' if custom[k].delete('__none__')
478 custom[k] << '' if custom[k].delete('__none__')
483 else
479 else
484 custom[k] = '' if custom[k] == '__none__'
480 custom[k] = '' if custom[k] == '__none__'
485 end
481 end
486 end
482 end
487 end
483 end
488 attributes
484 attributes
489 end
485 end
490
486
491 # Saves @issue and a time_entry from the parameters
487 # Saves @issue and a time_entry from the parameters
492 def save_issue_with_child_records
488 def save_issue_with_child_records
493 Issue.transaction do
489 Issue.transaction do
494 if params[:time_entry] && (params[:time_entry][:hours].present? || params[:time_entry][:comments].present?) && User.current.allowed_to?(:log_time, @issue.project)
490 if params[:time_entry] && (params[:time_entry][:hours].present? || params[:time_entry][:comments].present?) && User.current.allowed_to?(:log_time, @issue.project)
495 time_entry = @time_entry || TimeEntry.new
491 time_entry = @time_entry || TimeEntry.new
496 time_entry.project = @issue.project
492 time_entry.project = @issue.project
497 time_entry.issue = @issue
493 time_entry.issue = @issue
498 time_entry.user = User.current
494 time_entry.user = User.current
499 time_entry.spent_on = User.current.today
495 time_entry.spent_on = User.current.today
500 time_entry.attributes = params[:time_entry]
496 time_entry.attributes = params[:time_entry]
501 @issue.time_entries << time_entry
497 @issue.time_entries << time_entry
502 end
498 end
503
499
504 call_hook(:controller_issues_edit_before_save, { :params => params, :issue => @issue, :time_entry => time_entry, :journal => @issue.current_journal})
500 call_hook(:controller_issues_edit_before_save, { :params => params, :issue => @issue, :time_entry => time_entry, :journal => @issue.current_journal})
505 if @issue.save
501 if @issue.save
506 call_hook(:controller_issues_edit_after_save, { :params => params, :issue => @issue, :time_entry => time_entry, :journal => @issue.current_journal})
502 call_hook(:controller_issues_edit_after_save, { :params => params, :issue => @issue, :time_entry => time_entry, :journal => @issue.current_journal})
507 else
503 else
508 raise ActiveRecord::Rollback
504 raise ActiveRecord::Rollback
509 end
505 end
510 end
506 end
511 end
507 end
512
508
513 def link_copy?(param)
509 def link_copy?(param)
514 case Setting.link_copied_issue
510 case Setting.link_copied_issue
515 when 'yes'
511 when 'yes'
516 true
512 true
517 when 'no'
513 when 'no'
518 false
514 false
519 when 'ask'
515 when 'ask'
520 param == '1'
516 param == '1'
521 end
517 end
522 end
518 end
523 end
519 end
@@ -1,463 +1,473
1 # encoding: utf-8
1 # encoding: utf-8
2 #
2 #
3 # Redmine - project management software
3 # Redmine - project management software
4 # Copyright (C) 2006-2015 Jean-Philippe Lang
4 # Copyright (C) 2006-2015 Jean-Philippe Lang
5 #
5 #
6 # This program is free software; you can redistribute it and/or
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
7 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; either version 2
8 # as published by the Free Software Foundation; either version 2
9 # of the License, or (at your option) any later version.
9 # of the License, or (at your option) any later version.
10 #
10 #
11 # This program is distributed in the hope that it will be useful,
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
14 # GNU General Public License for more details.
15 #
15 #
16 # You should have received a copy of the GNU General Public License
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
19
20 module IssuesHelper
20 module IssuesHelper
21 include ApplicationHelper
21 include ApplicationHelper
22 include Redmine::Export::PDF::IssuesPdfHelper
22 include Redmine::Export::PDF::IssuesPdfHelper
23
23
24 def issue_list(issues, &block)
24 def issue_list(issues, &block)
25 ancestors = []
25 ancestors = []
26 issues.each do |issue|
26 issues.each do |issue|
27 while (ancestors.any? && !issue.is_descendant_of?(ancestors.last))
27 while (ancestors.any? && !issue.is_descendant_of?(ancestors.last))
28 ancestors.pop
28 ancestors.pop
29 end
29 end
30 yield issue, ancestors.size
30 yield issue, ancestors.size
31 ancestors << issue unless issue.leaf?
31 ancestors << issue unless issue.leaf?
32 end
32 end
33 end
33 end
34
34
35 def grouped_issue_list(issues, query, issue_count_by_group, &block)
35 def grouped_issue_list(issues, query, issue_count_by_group, &block)
36 previous_group, first = false, true
36 previous_group, first = false, true
37 issue_list(issues) do |issue, level|
37 issue_list(issues) do |issue, level|
38 group_name = group_count = nil
38 group_name = group_count = nil
39 if query.grouped? && ((group = query.group_by_column.value(issue)) != previous_group || first)
39 if query.grouped? && ((group = query.group_by_column.value(issue)) != previous_group || first)
40 if group.blank? && group != false
40 if group.blank? && group != false
41 group_name = "(#{l(:label_blank_value)})"
41 group_name = "(#{l(:label_blank_value)})"
42 else
42 else
43 group_name = column_content(query.group_by_column, issue)
43 group_name = column_content(query.group_by_column, issue)
44 end
44 end
45 group_name ||= ""
45 group_name ||= ""
46 group_count = issue_count_by_group[group]
46 group_count = issue_count_by_group[group]
47 end
47 end
48 yield issue, level, group_name, group_count
48 yield issue, level, group_name, group_count
49 previous_group, first = group, false
49 previous_group, first = group, false
50 end
50 end
51 end
51 end
52
52
53 # Renders a HTML/CSS tooltip
53 # Renders a HTML/CSS tooltip
54 #
54 #
55 # To use, a trigger div is needed. This is a div with the class of "tooltip"
55 # To use, a trigger div is needed. This is a div with the class of "tooltip"
56 # that contains this method wrapped in a span with the class of "tip"
56 # that contains this method wrapped in a span with the class of "tip"
57 #
57 #
58 # <div class="tooltip"><%= link_to_issue(issue) %>
58 # <div class="tooltip"><%= link_to_issue(issue) %>
59 # <span class="tip"><%= render_issue_tooltip(issue) %></span>
59 # <span class="tip"><%= render_issue_tooltip(issue) %></span>
60 # </div>
60 # </div>
61 #
61 #
62 def render_issue_tooltip(issue)
62 def render_issue_tooltip(issue)
63 @cached_label_status ||= l(:field_status)
63 @cached_label_status ||= l(:field_status)
64 @cached_label_start_date ||= l(:field_start_date)
64 @cached_label_start_date ||= l(:field_start_date)
65 @cached_label_due_date ||= l(:field_due_date)
65 @cached_label_due_date ||= l(:field_due_date)
66 @cached_label_assigned_to ||= l(:field_assigned_to)
66 @cached_label_assigned_to ||= l(:field_assigned_to)
67 @cached_label_priority ||= l(:field_priority)
67 @cached_label_priority ||= l(:field_priority)
68 @cached_label_project ||= l(:field_project)
68 @cached_label_project ||= l(:field_project)
69
69
70 link_to_issue(issue) + "<br /><br />".html_safe +
70 link_to_issue(issue) + "<br /><br />".html_safe +
71 "<strong>#{@cached_label_project}</strong>: #{link_to_project(issue.project)}<br />".html_safe +
71 "<strong>#{@cached_label_project}</strong>: #{link_to_project(issue.project)}<br />".html_safe +
72 "<strong>#{@cached_label_status}</strong>: #{h(issue.status.name)}<br />".html_safe +
72 "<strong>#{@cached_label_status}</strong>: #{h(issue.status.name)}<br />".html_safe +
73 "<strong>#{@cached_label_start_date}</strong>: #{format_date(issue.start_date)}<br />".html_safe +
73 "<strong>#{@cached_label_start_date}</strong>: #{format_date(issue.start_date)}<br />".html_safe +
74 "<strong>#{@cached_label_due_date}</strong>: #{format_date(issue.due_date)}<br />".html_safe +
74 "<strong>#{@cached_label_due_date}</strong>: #{format_date(issue.due_date)}<br />".html_safe +
75 "<strong>#{@cached_label_assigned_to}</strong>: #{h(issue.assigned_to)}<br />".html_safe +
75 "<strong>#{@cached_label_assigned_to}</strong>: #{h(issue.assigned_to)}<br />".html_safe +
76 "<strong>#{@cached_label_priority}</strong>: #{h(issue.priority.name)}".html_safe
76 "<strong>#{@cached_label_priority}</strong>: #{h(issue.priority.name)}".html_safe
77 end
77 end
78
78
79 def issue_heading(issue)
79 def issue_heading(issue)
80 h("#{issue.tracker} ##{issue.id}")
80 h("#{issue.tracker} ##{issue.id}")
81 end
81 end
82
82
83 def render_issue_subject_with_tree(issue)
83 def render_issue_subject_with_tree(issue)
84 s = ''
84 s = ''
85 ancestors = issue.root? ? [] : issue.ancestors.visible.to_a
85 ancestors = issue.root? ? [] : issue.ancestors.visible.to_a
86 ancestors.each do |ancestor|
86 ancestors.each do |ancestor|
87 s << '<div>' + content_tag('p', link_to_issue(ancestor, :project => (issue.project_id != ancestor.project_id)))
87 s << '<div>' + content_tag('p', link_to_issue(ancestor, :project => (issue.project_id != ancestor.project_id)))
88 end
88 end
89 s << '<div>'
89 s << '<div>'
90 subject = h(issue.subject)
90 subject = h(issue.subject)
91 if issue.is_private?
91 if issue.is_private?
92 subject = content_tag('span', l(:field_is_private), :class => 'private') + ' ' + subject
92 subject = content_tag('span', l(:field_is_private), :class => 'private') + ' ' + subject
93 end
93 end
94 s << content_tag('h3', subject)
94 s << content_tag('h3', subject)
95 s << '</div>' * (ancestors.size + 1)
95 s << '</div>' * (ancestors.size + 1)
96 s.html_safe
96 s.html_safe
97 end
97 end
98
98
99 def render_descendants_tree(issue)
99 def render_descendants_tree(issue)
100 s = '<form><table class="list issues">'
100 s = '<form><table class="list issues">'
101 issue_list(issue.descendants.visible.sort_by(&:lft)) do |child, level|
101 issue_list(issue.descendants.visible.sort_by(&:lft)) do |child, level|
102 css = "issue issue-#{child.id} hascontextmenu"
102 css = "issue issue-#{child.id} hascontextmenu"
103 css << " idnt idnt-#{level}" if level > 0
103 css << " idnt idnt-#{level}" if level > 0
104 s << content_tag('tr',
104 s << content_tag('tr',
105 content_tag('td', check_box_tag("ids[]", child.id, false, :id => nil), :class => 'checkbox') +
105 content_tag('td', check_box_tag("ids[]", child.id, false, :id => nil), :class => 'checkbox') +
106 content_tag('td', link_to_issue(child, :project => (issue.project_id != child.project_id)), :class => 'subject', :style => 'width: 50%') +
106 content_tag('td', link_to_issue(child, :project => (issue.project_id != child.project_id)), :class => 'subject', :style => 'width: 50%') +
107 content_tag('td', h(child.status)) +
107 content_tag('td', h(child.status)) +
108 content_tag('td', link_to_user(child.assigned_to)) +
108 content_tag('td', link_to_user(child.assigned_to)) +
109 content_tag('td', progress_bar(child.done_ratio, :width => '80px')),
109 content_tag('td', progress_bar(child.done_ratio, :width => '80px')),
110 :class => css)
110 :class => css)
111 end
111 end
112 s << '</table></form>'
112 s << '</table></form>'
113 s.html_safe
113 s.html_safe
114 end
114 end
115
115
116 # Returns an array of error messages for bulk edited issues
116 # Returns an array of error messages for bulk edited issues
117 def bulk_edit_error_messages(issues)
117 def bulk_edit_error_messages(issues)
118 messages = {}
118 messages = {}
119 issues.each do |issue|
119 issues.each do |issue|
120 issue.errors.full_messages.each do |message|
120 issue.errors.full_messages.each do |message|
121 messages[message] ||= []
121 messages[message] ||= []
122 messages[message] << issue
122 messages[message] << issue
123 end
123 end
124 end
124 end
125 messages.map { |message, issues|
125 messages.map { |message, issues|
126 "#{message}: " + issues.map {|i| "##{i.id}"}.join(', ')
126 "#{message}: " + issues.map {|i| "##{i.id}"}.join(', ')
127 }
127 }
128 end
128 end
129
129
130 # Returns a link for adding a new subtask to the given issue
130 # Returns a link for adding a new subtask to the given issue
131 def link_to_new_subtask(issue)
131 def link_to_new_subtask(issue)
132 attrs = {
132 attrs = {
133 :tracker_id => issue.tracker,
133 :tracker_id => issue.tracker,
134 :parent_issue_id => issue
134 :parent_issue_id => issue
135 }
135 }
136 link_to(l(:button_add), new_project_issue_path(issue.project, :issue => attrs))
136 link_to(l(:button_add), new_project_issue_path(issue.project, :issue => attrs))
137 end
137 end
138
138
139 class IssueFieldsRows
139 class IssueFieldsRows
140 include ActionView::Helpers::TagHelper
140 include ActionView::Helpers::TagHelper
141
141
142 def initialize
142 def initialize
143 @left = []
143 @left = []
144 @right = []
144 @right = []
145 end
145 end
146
146
147 def left(*args)
147 def left(*args)
148 args.any? ? @left << cells(*args) : @left
148 args.any? ? @left << cells(*args) : @left
149 end
149 end
150
150
151 def right(*args)
151 def right(*args)
152 args.any? ? @right << cells(*args) : @right
152 args.any? ? @right << cells(*args) : @right
153 end
153 end
154
154
155 def size
155 def size
156 @left.size > @right.size ? @left.size : @right.size
156 @left.size > @right.size ? @left.size : @right.size
157 end
157 end
158
158
159 def to_html
159 def to_html
160 html = ''.html_safe
160 html = ''.html_safe
161 blank = content_tag('th', '') + content_tag('td', '')
161 blank = content_tag('th', '') + content_tag('td', '')
162 size.times do |i|
162 size.times do |i|
163 left = @left[i] || blank
163 left = @left[i] || blank
164 right = @right[i] || blank
164 right = @right[i] || blank
165 html << content_tag('tr', left + right)
165 html << content_tag('tr', left + right)
166 end
166 end
167 html
167 html
168 end
168 end
169
169
170 def cells(label, text, options={})
170 def cells(label, text, options={})
171 content_tag('th', "#{label}:", options) + content_tag('td', text, options)
171 content_tag('th', "#{label}:", options) + content_tag('td', text, options)
172 end
172 end
173 end
173 end
174
174
175 def issue_fields_rows
175 def issue_fields_rows
176 r = IssueFieldsRows.new
176 r = IssueFieldsRows.new
177 yield r
177 yield r
178 r.to_html
178 r.to_html
179 end
179 end
180
180
181 def render_custom_fields_rows(issue)
181 def render_custom_fields_rows(issue)
182 values = issue.visible_custom_field_values
182 values = issue.visible_custom_field_values
183 return if values.empty?
183 return if values.empty?
184 ordered_values = []
184 ordered_values = []
185 half = (values.size / 2.0).ceil
185 half = (values.size / 2.0).ceil
186 half.times do |i|
186 half.times do |i|
187 ordered_values << values[i]
187 ordered_values << values[i]
188 ordered_values << values[i + half]
188 ordered_values << values[i + half]
189 end
189 end
190 s = "<tr>\n"
190 s = "<tr>\n"
191 n = 0
191 n = 0
192 ordered_values.compact.each do |value|
192 ordered_values.compact.each do |value|
193 css = "cf_#{value.custom_field.id}"
193 css = "cf_#{value.custom_field.id}"
194 s << "</tr>\n<tr>\n" if n > 0 && (n % 2) == 0
194 s << "</tr>\n<tr>\n" if n > 0 && (n % 2) == 0
195 s << "\t<th class=\"#{css}\">#{ h(value.custom_field.name) }:</th><td class=\"#{css}\">#{ h(show_value(value)) }</td>\n"
195 s << "\t<th class=\"#{css}\">#{ h(value.custom_field.name) }:</th><td class=\"#{css}\">#{ h(show_value(value)) }</td>\n"
196 n += 1
196 n += 1
197 end
197 end
198 s << "</tr>\n"
198 s << "</tr>\n"
199 s.html_safe
199 s.html_safe
200 end
200 end
201
201
202 # Returns the number of descendants for an array of issues
202 # Returns the number of descendants for an array of issues
203 def issues_descendant_count(issues)
203 def issues_descendant_count(issues)
204 ids = issues.reject(&:leaf?).map {|issue| issue.descendants.ids}.flatten.uniq
204 ids = issues.reject(&:leaf?).map {|issue| issue.descendants.ids}.flatten.uniq
205 ids -= issues.map(&:id)
205 ids -= issues.map(&:id)
206 ids.size
206 ids.size
207 end
207 end
208
208
209 def issues_destroy_confirmation_message(issues)
209 def issues_destroy_confirmation_message(issues)
210 issues = [issues] unless issues.is_a?(Array)
210 issues = [issues] unless issues.is_a?(Array)
211 message = l(:text_issues_destroy_confirmation)
211 message = l(:text_issues_destroy_confirmation)
212
212
213 descendant_count = issues_descendant_count(issues)
213 descendant_count = issues_descendant_count(issues)
214 if descendant_count > 0
214 if descendant_count > 0
215 message << "\n" + l(:text_issues_destroy_descendants_confirmation, :count => descendant_count)
215 message << "\n" + l(:text_issues_destroy_descendants_confirmation, :count => descendant_count)
216 end
216 end
217 message
217 message
218 end
218 end
219
219
220 # Returns an array of users that are proposed as watchers
221 # on the new issue form
222 def users_for_new_issue_watchers(issue)
223 users = issue.watcher_users
224 if issue.project.users.count <= 20
225 users = (users + issue.project.users.sort).uniq
226 end
227 users
228 end
229
220 def sidebar_queries
230 def sidebar_queries
221 unless @sidebar_queries
231 unless @sidebar_queries
222 @sidebar_queries = IssueQuery.visible.
232 @sidebar_queries = IssueQuery.visible.
223 order("#{Query.table_name}.name ASC").
233 order("#{Query.table_name}.name ASC").
224 # Project specific queries and global queries
234 # Project specific queries and global queries
225 where(@project.nil? ? ["project_id IS NULL"] : ["project_id IS NULL OR project_id = ?", @project.id]).
235 where(@project.nil? ? ["project_id IS NULL"] : ["project_id IS NULL OR project_id = ?", @project.id]).
226 to_a
236 to_a
227 end
237 end
228 @sidebar_queries
238 @sidebar_queries
229 end
239 end
230
240
231 def query_links(title, queries)
241 def query_links(title, queries)
232 return '' if queries.empty?
242 return '' if queries.empty?
233 # links to #index on issues/show
243 # links to #index on issues/show
234 url_params = controller_name == 'issues' ? {:controller => 'issues', :action => 'index', :project_id => @project} : params
244 url_params = controller_name == 'issues' ? {:controller => 'issues', :action => 'index', :project_id => @project} : params
235
245
236 content_tag('h3', title) + "\n" +
246 content_tag('h3', title) + "\n" +
237 content_tag('ul',
247 content_tag('ul',
238 queries.collect {|query|
248 queries.collect {|query|
239 css = 'query'
249 css = 'query'
240 css << ' selected' if query == @query
250 css << ' selected' if query == @query
241 content_tag('li', link_to(query.name, url_params.merge(:query_id => query), :class => css))
251 content_tag('li', link_to(query.name, url_params.merge(:query_id => query), :class => css))
242 }.join("\n").html_safe,
252 }.join("\n").html_safe,
243 :class => 'queries'
253 :class => 'queries'
244 ) + "\n"
254 ) + "\n"
245 end
255 end
246
256
247 def render_sidebar_queries
257 def render_sidebar_queries
248 out = ''.html_safe
258 out = ''.html_safe
249 out << query_links(l(:label_my_queries), sidebar_queries.select(&:is_private?))
259 out << query_links(l(:label_my_queries), sidebar_queries.select(&:is_private?))
250 out << query_links(l(:label_query_plural), sidebar_queries.reject(&:is_private?))
260 out << query_links(l(:label_query_plural), sidebar_queries.reject(&:is_private?))
251 out
261 out
252 end
262 end
253
263
254 def email_issue_attributes(issue, user)
264 def email_issue_attributes(issue, user)
255 items = []
265 items = []
256 %w(author status priority assigned_to category fixed_version).each do |attribute|
266 %w(author status priority assigned_to category fixed_version).each do |attribute|
257 unless issue.disabled_core_fields.include?(attribute+"_id")
267 unless issue.disabled_core_fields.include?(attribute+"_id")
258 items << "#{l("field_#{attribute}")}: #{issue.send attribute}"
268 items << "#{l("field_#{attribute}")}: #{issue.send attribute}"
259 end
269 end
260 end
270 end
261 issue.visible_custom_field_values(user).each do |value|
271 issue.visible_custom_field_values(user).each do |value|
262 items << "#{value.custom_field.name}: #{show_value(value, false)}"
272 items << "#{value.custom_field.name}: #{show_value(value, false)}"
263 end
273 end
264 items
274 items
265 end
275 end
266
276
267 def render_email_issue_attributes(issue, user, html=false)
277 def render_email_issue_attributes(issue, user, html=false)
268 items = email_issue_attributes(issue, user)
278 items = email_issue_attributes(issue, user)
269 if html
279 if html
270 content_tag('ul', items.map{|s| content_tag('li', s)}.join("\n").html_safe)
280 content_tag('ul', items.map{|s| content_tag('li', s)}.join("\n").html_safe)
271 else
281 else
272 items.map{|s| "* #{s}"}.join("\n")
282 items.map{|s| "* #{s}"}.join("\n")
273 end
283 end
274 end
284 end
275
285
276 # Returns the textual representation of a journal details
286 # Returns the textual representation of a journal details
277 # as an array of strings
287 # as an array of strings
278 def details_to_strings(details, no_html=false, options={})
288 def details_to_strings(details, no_html=false, options={})
279 options[:only_path] = (options[:only_path] == false ? false : true)
289 options[:only_path] = (options[:only_path] == false ? false : true)
280 strings = []
290 strings = []
281 values_by_field = {}
291 values_by_field = {}
282 details.each do |detail|
292 details.each do |detail|
283 if detail.property == 'cf'
293 if detail.property == 'cf'
284 field = detail.custom_field
294 field = detail.custom_field
285 if field && field.multiple?
295 if field && field.multiple?
286 values_by_field[field] ||= {:added => [], :deleted => []}
296 values_by_field[field] ||= {:added => [], :deleted => []}
287 if detail.old_value
297 if detail.old_value
288 values_by_field[field][:deleted] << detail.old_value
298 values_by_field[field][:deleted] << detail.old_value
289 end
299 end
290 if detail.value
300 if detail.value
291 values_by_field[field][:added] << detail.value
301 values_by_field[field][:added] << detail.value
292 end
302 end
293 next
303 next
294 end
304 end
295 end
305 end
296 strings << show_detail(detail, no_html, options)
306 strings << show_detail(detail, no_html, options)
297 end
307 end
298 values_by_field.each do |field, changes|
308 values_by_field.each do |field, changes|
299 detail = JournalDetail.new(:property => 'cf', :prop_key => field.id.to_s)
309 detail = JournalDetail.new(:property => 'cf', :prop_key => field.id.to_s)
300 detail.instance_variable_set "@custom_field", field
310 detail.instance_variable_set "@custom_field", field
301 if changes[:added].any?
311 if changes[:added].any?
302 detail.value = changes[:added]
312 detail.value = changes[:added]
303 strings << show_detail(detail, no_html, options)
313 strings << show_detail(detail, no_html, options)
304 elsif changes[:deleted].any?
314 elsif changes[:deleted].any?
305 detail.old_value = changes[:deleted]
315 detail.old_value = changes[:deleted]
306 strings << show_detail(detail, no_html, options)
316 strings << show_detail(detail, no_html, options)
307 end
317 end
308 end
318 end
309 strings
319 strings
310 end
320 end
311
321
312 # Returns the textual representation of a single journal detail
322 # Returns the textual representation of a single journal detail
313 def show_detail(detail, no_html=false, options={})
323 def show_detail(detail, no_html=false, options={})
314 multiple = false
324 multiple = false
315 show_diff = false
325 show_diff = false
316
326
317 case detail.property
327 case detail.property
318 when 'attr'
328 when 'attr'
319 field = detail.prop_key.to_s.gsub(/\_id$/, "")
329 field = detail.prop_key.to_s.gsub(/\_id$/, "")
320 label = l(("field_" + field).to_sym)
330 label = l(("field_" + field).to_sym)
321 case detail.prop_key
331 case detail.prop_key
322 when 'due_date', 'start_date'
332 when 'due_date', 'start_date'
323 value = format_date(detail.value.to_date) if detail.value
333 value = format_date(detail.value.to_date) if detail.value
324 old_value = format_date(detail.old_value.to_date) if detail.old_value
334 old_value = format_date(detail.old_value.to_date) if detail.old_value
325
335
326 when 'project_id', 'status_id', 'tracker_id', 'assigned_to_id',
336 when 'project_id', 'status_id', 'tracker_id', 'assigned_to_id',
327 'priority_id', 'category_id', 'fixed_version_id'
337 'priority_id', 'category_id', 'fixed_version_id'
328 value = find_name_by_reflection(field, detail.value)
338 value = find_name_by_reflection(field, detail.value)
329 old_value = find_name_by_reflection(field, detail.old_value)
339 old_value = find_name_by_reflection(field, detail.old_value)
330
340
331 when 'estimated_hours'
341 when 'estimated_hours'
332 value = "%0.02f" % detail.value.to_f unless detail.value.blank?
342 value = "%0.02f" % detail.value.to_f unless detail.value.blank?
333 old_value = "%0.02f" % detail.old_value.to_f unless detail.old_value.blank?
343 old_value = "%0.02f" % detail.old_value.to_f unless detail.old_value.blank?
334
344
335 when 'parent_id'
345 when 'parent_id'
336 label = l(:field_parent_issue)
346 label = l(:field_parent_issue)
337 value = "##{detail.value}" unless detail.value.blank?
347 value = "##{detail.value}" unless detail.value.blank?
338 old_value = "##{detail.old_value}" unless detail.old_value.blank?
348 old_value = "##{detail.old_value}" unless detail.old_value.blank?
339
349
340 when 'is_private'
350 when 'is_private'
341 value = l(detail.value == "0" ? :general_text_No : :general_text_Yes) unless detail.value.blank?
351 value = l(detail.value == "0" ? :general_text_No : :general_text_Yes) unless detail.value.blank?
342 old_value = l(detail.old_value == "0" ? :general_text_No : :general_text_Yes) unless detail.old_value.blank?
352 old_value = l(detail.old_value == "0" ? :general_text_No : :general_text_Yes) unless detail.old_value.blank?
343
353
344 when 'description'
354 when 'description'
345 show_diff = true
355 show_diff = true
346 end
356 end
347 when 'cf'
357 when 'cf'
348 custom_field = detail.custom_field
358 custom_field = detail.custom_field
349 if custom_field
359 if custom_field
350 label = custom_field.name
360 label = custom_field.name
351 if custom_field.format.class.change_as_diff
361 if custom_field.format.class.change_as_diff
352 show_diff = true
362 show_diff = true
353 else
363 else
354 multiple = custom_field.multiple?
364 multiple = custom_field.multiple?
355 value = format_value(detail.value, custom_field) if detail.value
365 value = format_value(detail.value, custom_field) if detail.value
356 old_value = format_value(detail.old_value, custom_field) if detail.old_value
366 old_value = format_value(detail.old_value, custom_field) if detail.old_value
357 end
367 end
358 end
368 end
359 when 'attachment'
369 when 'attachment'
360 label = l(:label_attachment)
370 label = l(:label_attachment)
361 when 'relation'
371 when 'relation'
362 if detail.value && !detail.old_value
372 if detail.value && !detail.old_value
363 rel_issue = Issue.visible.find_by_id(detail.value)
373 rel_issue = Issue.visible.find_by_id(detail.value)
364 value = rel_issue.nil? ? "#{l(:label_issue)} ##{detail.value}" :
374 value = rel_issue.nil? ? "#{l(:label_issue)} ##{detail.value}" :
365 (no_html ? rel_issue : link_to_issue(rel_issue, :only_path => options[:only_path]))
375 (no_html ? rel_issue : link_to_issue(rel_issue, :only_path => options[:only_path]))
366 elsif detail.old_value && !detail.value
376 elsif detail.old_value && !detail.value
367 rel_issue = Issue.visible.find_by_id(detail.old_value)
377 rel_issue = Issue.visible.find_by_id(detail.old_value)
368 old_value = rel_issue.nil? ? "#{l(:label_issue)} ##{detail.old_value}" :
378 old_value = rel_issue.nil? ? "#{l(:label_issue)} ##{detail.old_value}" :
369 (no_html ? rel_issue : link_to_issue(rel_issue, :only_path => options[:only_path]))
379 (no_html ? rel_issue : link_to_issue(rel_issue, :only_path => options[:only_path]))
370 end
380 end
371 relation_type = IssueRelation::TYPES[detail.prop_key]
381 relation_type = IssueRelation::TYPES[detail.prop_key]
372 label = l(relation_type[:name]) if relation_type
382 label = l(relation_type[:name]) if relation_type
373 end
383 end
374 call_hook(:helper_issues_show_detail_after_setting,
384 call_hook(:helper_issues_show_detail_after_setting,
375 {:detail => detail, :label => label, :value => value, :old_value => old_value })
385 {:detail => detail, :label => label, :value => value, :old_value => old_value })
376
386
377 label ||= detail.prop_key
387 label ||= detail.prop_key
378 value ||= detail.value
388 value ||= detail.value
379 old_value ||= detail.old_value
389 old_value ||= detail.old_value
380
390
381 unless no_html
391 unless no_html
382 label = content_tag('strong', label)
392 label = content_tag('strong', label)
383 old_value = content_tag("i", h(old_value)) if detail.old_value
393 old_value = content_tag("i", h(old_value)) if detail.old_value
384 if detail.old_value && detail.value.blank? && detail.property != 'relation'
394 if detail.old_value && detail.value.blank? && detail.property != 'relation'
385 old_value = content_tag("del", old_value)
395 old_value = content_tag("del", old_value)
386 end
396 end
387 if detail.property == 'attachment' && value.present? &&
397 if detail.property == 'attachment' && value.present? &&
388 atta = detail.journal.journalized.attachments.detect {|a| a.id == detail.prop_key.to_i}
398 atta = detail.journal.journalized.attachments.detect {|a| a.id == detail.prop_key.to_i}
389 # Link to the attachment if it has not been removed
399 # Link to the attachment if it has not been removed
390 value = link_to_attachment(atta, :download => true, :only_path => options[:only_path])
400 value = link_to_attachment(atta, :download => true, :only_path => options[:only_path])
391 if options[:only_path] != false && atta.is_text?
401 if options[:only_path] != false && atta.is_text?
392 value += link_to(
402 value += link_to(
393 image_tag('magnifier.png'),
403 image_tag('magnifier.png'),
394 :controller => 'attachments', :action => 'show',
404 :controller => 'attachments', :action => 'show',
395 :id => atta, :filename => atta.filename
405 :id => atta, :filename => atta.filename
396 )
406 )
397 end
407 end
398 else
408 else
399 value = content_tag("i", h(value)) if value
409 value = content_tag("i", h(value)) if value
400 end
410 end
401 end
411 end
402
412
403 if show_diff
413 if show_diff
404 s = l(:text_journal_changed_no_detail, :label => label)
414 s = l(:text_journal_changed_no_detail, :label => label)
405 unless no_html
415 unless no_html
406 diff_link = link_to 'diff',
416 diff_link = link_to 'diff',
407 {:controller => 'journals', :action => 'diff', :id => detail.journal_id,
417 {:controller => 'journals', :action => 'diff', :id => detail.journal_id,
408 :detail_id => detail.id, :only_path => options[:only_path]},
418 :detail_id => detail.id, :only_path => options[:only_path]},
409 :title => l(:label_view_diff)
419 :title => l(:label_view_diff)
410 s << " (#{ diff_link })"
420 s << " (#{ diff_link })"
411 end
421 end
412 s.html_safe
422 s.html_safe
413 elsif detail.value.present?
423 elsif detail.value.present?
414 case detail.property
424 case detail.property
415 when 'attr', 'cf'
425 when 'attr', 'cf'
416 if detail.old_value.present?
426 if detail.old_value.present?
417 l(:text_journal_changed, :label => label, :old => old_value, :new => value).html_safe
427 l(:text_journal_changed, :label => label, :old => old_value, :new => value).html_safe
418 elsif multiple
428 elsif multiple
419 l(:text_journal_added, :label => label, :value => value).html_safe
429 l(:text_journal_added, :label => label, :value => value).html_safe
420 else
430 else
421 l(:text_journal_set_to, :label => label, :value => value).html_safe
431 l(:text_journal_set_to, :label => label, :value => value).html_safe
422 end
432 end
423 when 'attachment', 'relation'
433 when 'attachment', 'relation'
424 l(:text_journal_added, :label => label, :value => value).html_safe
434 l(:text_journal_added, :label => label, :value => value).html_safe
425 end
435 end
426 else
436 else
427 l(:text_journal_deleted, :label => label, :old => old_value).html_safe
437 l(:text_journal_deleted, :label => label, :old => old_value).html_safe
428 end
438 end
429 end
439 end
430
440
431 # Find the name of an associated record stored in the field attribute
441 # Find the name of an associated record stored in the field attribute
432 def find_name_by_reflection(field, id)
442 def find_name_by_reflection(field, id)
433 unless id.present?
443 unless id.present?
434 return nil
444 return nil
435 end
445 end
436 @detail_value_name_by_reflection ||= Hash.new do |hash, key|
446 @detail_value_name_by_reflection ||= Hash.new do |hash, key|
437 association = Issue.reflect_on_association(key.first.to_sym)
447 association = Issue.reflect_on_association(key.first.to_sym)
438 if association
448 if association
439 record = association.klass.find_by_id(key.last)
449 record = association.klass.find_by_id(key.last)
440 if record
450 if record
441 record.name.force_encoding('UTF-8')
451 record.name.force_encoding('UTF-8')
442 hash[key] = record.name
452 hash[key] = record.name
443 end
453 end
444 end
454 end
445 hash[key] ||= nil
455 hash[key] ||= nil
446 end
456 end
447 @detail_value_name_by_reflection[[field, id]]
457 @detail_value_name_by_reflection[[field, id]]
448 end
458 end
449
459
450 # Renders issue children recursively
460 # Renders issue children recursively
451 def render_api_issue_children(issue, api)
461 def render_api_issue_children(issue, api)
452 return if issue.leaf?
462 return if issue.leaf?
453 api.array :children do
463 api.array :children do
454 issue.children.each do |child|
464 issue.children.each do |child|
455 api.issue(:id => child.id) do
465 api.issue(:id => child.id) do
456 api.tracker(:id => child.tracker_id, :name => child.tracker.name) unless child.tracker.nil?
466 api.tracker(:id => child.tracker_id, :name => child.tracker.name) unless child.tracker.nil?
457 api.subject child.subject
467 api.subject child.subject
458 render_api_issue_children(child, api)
468 render_api_issue_children(child, api)
459 end
469 end
460 end
470 end
461 end
471 end
462 end
472 end
463 end
473 end
@@ -1,59 +1,59
1 <%= title l(:label_issue_new) %>
1 <%= title l(:label_issue_new) %>
2
2
3 <%= call_hook(:view_issues_new_top, {:issue => @issue}) %>
3 <%= call_hook(:view_issues_new_top, {:issue => @issue}) %>
4
4
5 <%= labelled_form_for @issue, :url => project_issues_path(@project),
5 <%= labelled_form_for @issue, :url => project_issues_path(@project),
6 :html => {:id => 'issue-form', :multipart => true} do |f| %>
6 :html => {:id => 'issue-form', :multipart => true} do |f| %>
7 <%= error_messages_for 'issue' %>
7 <%= error_messages_for 'issue' %>
8 <%= hidden_field_tag 'copy_from', params[:copy_from] if params[:copy_from] %>
8 <%= hidden_field_tag 'copy_from', params[:copy_from] if params[:copy_from] %>
9 <div class="box tabular">
9 <div class="box tabular">
10 <div id="all_attributes">
10 <div id="all_attributes">
11 <%= render :partial => 'issues/form', :locals => {:f => f} %>
11 <%= render :partial => 'issues/form', :locals => {:f => f} %>
12 </div>
12 </div>
13
13
14 <% if @copy_from && Setting.link_copied_issue == 'ask' %>
14 <% if @copy_from && Setting.link_copied_issue == 'ask' %>
15 <p>
15 <p>
16 <label for="link_copy"><%= l(:label_link_copied_issue) %></label>
16 <label for="link_copy"><%= l(:label_link_copied_issue) %></label>
17 <%= check_box_tag 'link_copy', '1', @link_copy %>
17 <%= check_box_tag 'link_copy', '1', @link_copy %>
18 </p>
18 </p>
19 <% end %>
19 <% end %>
20 <% if @copy_from && @copy_from.attachments.any? %>
20 <% if @copy_from && @copy_from.attachments.any? %>
21 <p>
21 <p>
22 <label for="copy_attachments"><%= l(:label_copy_attachments) %></label>
22 <label for="copy_attachments"><%= l(:label_copy_attachments) %></label>
23 <%= check_box_tag 'copy_attachments', '1', @copy_attachments %>
23 <%= check_box_tag 'copy_attachments', '1', @copy_attachments %>
24 </p>
24 </p>
25 <% end %>
25 <% end %>
26 <% if @copy_from && !@copy_from.leaf? %>
26 <% if @copy_from && !@copy_from.leaf? %>
27 <p>
27 <p>
28 <label for="copy_subtasks"><%= l(:label_copy_subtasks) %></label>
28 <label for="copy_subtasks"><%= l(:label_copy_subtasks) %></label>
29 <%= check_box_tag 'copy_subtasks', '1', @copy_subtasks %>
29 <%= check_box_tag 'copy_subtasks', '1', @copy_subtasks %>
30 </p>
30 </p>
31 <% end %>
31 <% end %>
32
32
33 <p id="attachments_form"><label><%= l(:label_attachment_plural) %></label><%= render :partial => 'attachments/form', :locals => {:container => @issue} %></p>
33 <p id="attachments_form"><label><%= l(:label_attachment_plural) %></label><%= render :partial => 'attachments/form', :locals => {:container => @issue} %></p>
34
34
35 <% if @issue.safe_attribute? 'watcher_user_ids' -%>
35 <% if @issue.safe_attribute? 'watcher_user_ids' -%>
36 <p id="watchers_form"><label><%= l(:label_issue_watchers) %></label>
36 <p id="watchers_form"><label><%= l(:label_issue_watchers) %></label>
37 <span id="watchers_inputs">
37 <span id="watchers_inputs">
38 <%= watchers_checkboxes(@issue, @available_watchers) %>
38 <%= watchers_checkboxes(@issue, users_for_new_issue_watchers(@issue)) %>
39 </span>
39 </span>
40 <span class="search_for_watchers">
40 <span class="search_for_watchers">
41 <%= link_to l(:label_search_for_watchers),
41 <%= link_to l(:label_search_for_watchers),
42 {:controller => 'watchers', :action => 'new', :project_id => @issue.project},
42 {:controller => 'watchers', :action => 'new', :project_id => @issue.project},
43 :remote => true,
43 :remote => true,
44 :method => 'get' %>
44 :method => 'get' %>
45 </span>
45 </span>
46 </p>
46 </p>
47 <% end %>
47 <% end %>
48 </div>
48 </div>
49
49
50 <%= submit_tag l(:button_create) %>
50 <%= submit_tag l(:button_create) %>
51 <%= submit_tag l(:button_create_and_continue), :name => 'continue' %>
51 <%= submit_tag l(:button_create_and_continue), :name => 'continue' %>
52 <%= preview_link preview_new_issue_path(:project_id => @project), 'issue-form' %>
52 <%= preview_link preview_new_issue_path(:project_id => @project), 'issue-form' %>
53 <% end %>
53 <% end %>
54
54
55 <div id="preview" class="wiki"></div>
55 <div id="preview" class="wiki"></div>
56
56
57 <% content_for :header_tags do %>
57 <% content_for :header_tags do %>
58 <%= robot_exclusion_tag %>
58 <%= robot_exclusion_tag %>
59 <% end %>
59 <% end %>
General Comments 0
You need to be logged in to leave comments. Login now