##// END OF EJS Templates
Bulk edit form not show fields based on target tracker and status (#23755)....
Jean-Philippe Lang -
r15433:dcf2e15b0617
parent child
Show More

The requested changes are too big and content was truncated. Show full diff

@@ -1,551 +1,568
1 # Redmine - project management software
1 # Redmine - project management software
2 # Copyright (C) 2006-2016 Jean-Philippe Lang
2 # Copyright (C) 2006-2016 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
18 class IssuesController < ApplicationController
18 class IssuesController < ApplicationController
19 default_search_scope :issues
19 default_search_scope :issues
20
20
21 before_action :find_issue, :only => [:show, :edit, :update]
21 before_action :find_issue, :only => [:show, :edit, :update]
22 before_action :find_issues, :only => [:bulk_edit, :bulk_update, :destroy]
22 before_action :find_issues, :only => [:bulk_edit, :bulk_update, :destroy]
23 before_action :authorize, :except => [:index, :new, :create]
23 before_action :authorize, :except => [:index, :new, :create]
24 before_action :find_optional_project, :only => [:index, :new, :create]
24 before_action :find_optional_project, :only => [:index, :new, :create]
25 before_action :build_new_issue_from_params, :only => [:new, :create]
25 before_action :build_new_issue_from_params, :only => [:new, :create]
26 accept_rss_auth :index, :show
26 accept_rss_auth :index, :show
27 accept_api_auth :index, :show, :create, :update, :destroy
27 accept_api_auth :index, :show, :create, :update, :destroy
28
28
29 rescue_from Query::StatementInvalid, :with => :query_statement_invalid
29 rescue_from Query::StatementInvalid, :with => :query_statement_invalid
30
30
31 helper :journals
31 helper :journals
32 helper :projects
32 helper :projects
33 helper :custom_fields
33 helper :custom_fields
34 helper :issue_relations
34 helper :issue_relations
35 helper :watchers
35 helper :watchers
36 helper :attachments
36 helper :attachments
37 helper :queries
37 helper :queries
38 include QueriesHelper
38 include QueriesHelper
39 helper :repositories
39 helper :repositories
40 helper :sort
40 helper :sort
41 include SortHelper
41 include SortHelper
42 helper :timelog
42 helper :timelog
43
43
44 def index
44 def index
45 retrieve_query
45 retrieve_query
46 sort_init(@query.sort_criteria.empty? ? [['id', 'desc']] : @query.sort_criteria)
46 sort_init(@query.sort_criteria.empty? ? [['id', 'desc']] : @query.sort_criteria)
47 sort_update(@query.sortable_columns)
47 sort_update(@query.sortable_columns)
48 @query.sort_criteria = sort_criteria.to_a
48 @query.sort_criteria = sort_criteria.to_a
49
49
50 if @query.valid?
50 if @query.valid?
51 case params[:format]
51 case params[:format]
52 when 'csv', 'pdf'
52 when 'csv', 'pdf'
53 @limit = Setting.issues_export_limit.to_i
53 @limit = Setting.issues_export_limit.to_i
54 if params[:columns] == 'all'
54 if params[:columns] == 'all'
55 @query.column_names = @query.available_inline_columns.map(&:name)
55 @query.column_names = @query.available_inline_columns.map(&:name)
56 end
56 end
57 when 'atom'
57 when 'atom'
58 @limit = Setting.feeds_limit.to_i
58 @limit = Setting.feeds_limit.to_i
59 when 'xml', 'json'
59 when 'xml', 'json'
60 @offset, @limit = api_offset_and_limit
60 @offset, @limit = api_offset_and_limit
61 @query.column_names = %w(author)
61 @query.column_names = %w(author)
62 else
62 else
63 @limit = per_page_option
63 @limit = per_page_option
64 end
64 end
65
65
66 @issue_count = @query.issue_count
66 @issue_count = @query.issue_count
67 @issue_pages = Paginator.new @issue_count, @limit, params['page']
67 @issue_pages = Paginator.new @issue_count, @limit, params['page']
68 @offset ||= @issue_pages.offset
68 @offset ||= @issue_pages.offset
69 @issues = @query.issues(:include => [:assigned_to, :tracker, :priority, :category, :fixed_version],
69 @issues = @query.issues(:include => [:assigned_to, :tracker, :priority, :category, :fixed_version],
70 :order => sort_clause,
70 :order => sort_clause,
71 :offset => @offset,
71 :offset => @offset,
72 :limit => @limit)
72 :limit => @limit)
73 @issue_count_by_group = @query.issue_count_by_group
73 @issue_count_by_group = @query.issue_count_by_group
74
74
75 respond_to do |format|
75 respond_to do |format|
76 format.html { render :template => 'issues/index', :layout => !request.xhr? }
76 format.html { render :template => 'issues/index', :layout => !request.xhr? }
77 format.api {
77 format.api {
78 Issue.load_visible_relations(@issues) if include_in_api_response?('relations')
78 Issue.load_visible_relations(@issues) if include_in_api_response?('relations')
79 }
79 }
80 format.atom { render_feed(@issues, :title => "#{@project || Setting.app_title}: #{l(:label_issue_plural)}") }
80 format.atom { render_feed(@issues, :title => "#{@project || Setting.app_title}: #{l(:label_issue_plural)}") }
81 format.csv { send_data(query_to_csv(@issues, @query, params[:csv]), :type => 'text/csv; header=present', :filename => 'issues.csv') }
81 format.csv { send_data(query_to_csv(@issues, @query, params[:csv]), :type => 'text/csv; header=present', :filename => 'issues.csv') }
82 format.pdf { send_file_headers! :type => 'application/pdf', :filename => 'issues.pdf' }
82 format.pdf { send_file_headers! :type => 'application/pdf', :filename => 'issues.pdf' }
83 end
83 end
84 else
84 else
85 respond_to do |format|
85 respond_to do |format|
86 format.html { render(:template => 'issues/index', :layout => !request.xhr?) }
86 format.html { render(:template => 'issues/index', :layout => !request.xhr?) }
87 format.any(:atom, :csv, :pdf) { head 422 }
87 format.any(:atom, :csv, :pdf) { head 422 }
88 format.api { render_validation_errors(@query) }
88 format.api { render_validation_errors(@query) }
89 end
89 end
90 end
90 end
91 rescue ActiveRecord::RecordNotFound
91 rescue ActiveRecord::RecordNotFound
92 render_404
92 render_404
93 end
93 end
94
94
95 def show
95 def show
96 @journals = @issue.journals.
96 @journals = @issue.journals.
97 preload(:details).
97 preload(:details).
98 preload(:user => :email_address).
98 preload(:user => :email_address).
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 respond_to do |format|
115 respond_to do |format|
116 format.html {
116 format.html {
117 retrieve_previous_and_next_issue_ids
117 retrieve_previous_and_next_issue_ids
118 render :template => 'issues/show'
118 render :template => 'issues/show'
119 }
119 }
120 format.api
120 format.api
121 format.atom { render :template => 'journals/index', :layout => false, :content_type => 'application/atom+xml' }
121 format.atom { render :template => 'journals/index', :layout => false, :content_type => 'application/atom+xml' }
122 format.pdf {
122 format.pdf {
123 send_file_headers! :type => 'application/pdf', :filename => "#{@project.identifier}-#{@issue.id}.pdf"
123 send_file_headers! :type => 'application/pdf', :filename => "#{@project.identifier}-#{@issue.id}.pdf"
124 }
124 }
125 end
125 end
126 end
126 end
127
127
128 def new
128 def new
129 respond_to do |format|
129 respond_to do |format|
130 format.html { render :action => 'new', :layout => !request.xhr? }
130 format.html { render :action => 'new', :layout => !request.xhr? }
131 format.js
131 format.js
132 end
132 end
133 end
133 end
134
134
135 def create
135 def create
136 unless User.current.allowed_to?(:add_issues, @issue.project, :global => true)
136 unless User.current.allowed_to?(:add_issues, @issue.project, :global => true)
137 raise ::Unauthorized
137 raise ::Unauthorized
138 end
138 end
139 call_hook(:controller_issues_new_before_save, { :params => params, :issue => @issue })
139 call_hook(:controller_issues_new_before_save, { :params => params, :issue => @issue })
140 @issue.save_attachments(params[:attachments] || (params[:issue] && params[:issue][:uploads]))
140 @issue.save_attachments(params[:attachments] || (params[:issue] && params[:issue][:uploads]))
141 if @issue.save
141 if @issue.save
142 call_hook(:controller_issues_new_after_save, { :params => params, :issue => @issue})
142 call_hook(:controller_issues_new_after_save, { :params => params, :issue => @issue})
143 respond_to do |format|
143 respond_to do |format|
144 format.html {
144 format.html {
145 render_attachment_warning_if_needed(@issue)
145 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))
146 flash[:notice] = l(:notice_issue_successful_create, :id => view_context.link_to("##{@issue.id}", issue_path(@issue), :title => @issue.subject))
147 redirect_after_create
147 redirect_after_create
148 }
148 }
149 format.api { render :action => 'show', :status => :created, :location => issue_url(@issue) }
149 format.api { render :action => 'show', :status => :created, :location => issue_url(@issue) }
150 end
150 end
151 return
151 return
152 else
152 else
153 respond_to do |format|
153 respond_to do |format|
154 format.html {
154 format.html {
155 if @issue.project.nil?
155 if @issue.project.nil?
156 render_error :status => 422
156 render_error :status => 422
157 else
157 else
158 render :action => 'new'
158 render :action => 'new'
159 end
159 end
160 }
160 }
161 format.api { render_validation_errors(@issue) }
161 format.api { render_validation_errors(@issue) }
162 end
162 end
163 end
163 end
164 end
164 end
165
165
166 def edit
166 def edit
167 return unless update_issue_from_params
167 return unless update_issue_from_params
168
168
169 respond_to do |format|
169 respond_to do |format|
170 format.html { }
170 format.html { }
171 format.js
171 format.js
172 end
172 end
173 end
173 end
174
174
175 def update
175 def update
176 return unless update_issue_from_params
176 return unless update_issue_from_params
177 @issue.save_attachments(params[:attachments] || (params[:issue] && params[:issue][:uploads]))
177 @issue.save_attachments(params[:attachments] || (params[:issue] && params[:issue][:uploads]))
178 saved = false
178 saved = false
179 begin
179 begin
180 saved = save_issue_with_child_records
180 saved = save_issue_with_child_records
181 rescue ActiveRecord::StaleObjectError
181 rescue ActiveRecord::StaleObjectError
182 @conflict = true
182 @conflict = true
183 if params[:last_journal_id]
183 if params[:last_journal_id]
184 @conflict_journals = @issue.journals_after(params[:last_journal_id]).to_a
184 @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)
185 @conflict_journals.reject!(&:private_notes?) unless User.current.allowed_to?(:view_private_notes, @issue.project)
186 end
186 end
187 end
187 end
188
188
189 if saved
189 if saved
190 render_attachment_warning_if_needed(@issue)
190 render_attachment_warning_if_needed(@issue)
191 flash[:notice] = l(:notice_successful_update) unless @issue.current_journal.new_record?
191 flash[:notice] = l(:notice_successful_update) unless @issue.current_journal.new_record?
192
192
193 respond_to do |format|
193 respond_to do |format|
194 format.html { redirect_back_or_default issue_path(@issue, previous_and_next_issue_ids_params) }
194 format.html { redirect_back_or_default issue_path(@issue, previous_and_next_issue_ids_params) }
195 format.api { render_api_ok }
195 format.api { render_api_ok }
196 end
196 end
197 else
197 else
198 respond_to do |format|
198 respond_to do |format|
199 format.html { render :action => 'edit' }
199 format.html { render :action => 'edit' }
200 format.api { render_validation_errors(@issue) }
200 format.api { render_validation_errors(@issue) }
201 end
201 end
202 end
202 end
203 end
203 end
204
204
205 # Bulk edit/copy a set of issues
205 # Bulk edit/copy a set of issues
206 def bulk_edit
206 def bulk_edit
207 @issues.sort!
207 @issues.sort!
208 @copy = params[:copy].present?
208 @copy = params[:copy].present?
209 @notes = params[:notes]
209 @notes = params[:notes]
210
210
211 if @copy
211 if @copy
212 unless User.current.allowed_to?(:copy_issues, @projects)
212 unless User.current.allowed_to?(:copy_issues, @projects)
213 raise ::Unauthorized
213 raise ::Unauthorized
214 end
214 end
215 else
215 else
216 unless @issues.all?(&:attributes_editable?)
216 unless @issues.all?(&:attributes_editable?)
217 raise ::Unauthorized
217 raise ::Unauthorized
218 end
218 end
219 end
219 end
220
220
221 edited_issues = Issue.where(:id => @issues.map(&:id)).to_a
222
221 @allowed_projects = Issue.allowed_target_projects
223 @allowed_projects = Issue.allowed_target_projects
222 if params[:issue]
224 if params[:issue]
223 @target_project = @allowed_projects.detect {|p| p.id.to_s == params[:issue][:project_id].to_s}
225 @target_project = @allowed_projects.detect {|p| p.id.to_s == params[:issue][:project_id].to_s}
224 if @target_project
226 if @target_project
225 target_projects = [@target_project]
227 target_projects = [@target_project]
228 edited_issues.each {|issue| issue.project = @target_project}
226 end
229 end
227 end
230 end
228 target_projects ||= @projects
231 target_projects ||= @projects
229
232
233 @trackers = target_projects.map {|p| Issue.allowed_target_trackers(p) }.reduce(:&)
234 if params[:issue]
235 @target_tracker = @trackers.detect {|t| t.id.to_s == params[:issue][:tracker_id].to_s}
236 if @target_tracker
237 edited_issues.each {|issue| issue.tracker = @target_tracker}
238 end
239 end
240
230 if @copy
241 if @copy
231 # Copied issues will get their default statuses
242 # Copied issues will get their default statuses
232 @available_statuses = []
243 @available_statuses = []
233 else
244 else
234 @available_statuses = @issues.map(&:new_statuses_allowed_to).reduce(:&)
245 @available_statuses = edited_issues.map(&:new_statuses_allowed_to).reduce(:&)
235 end
246 end
236 @custom_fields = @issues.map{|i|i.editable_custom_fields}.reduce(:&)
247 if params[:issue]
248 @target_status = @available_statuses.detect {|t| t.id.to_s == params[:issue][:status_id].to_s}
249 if @target_status
250 edited_issues.each {|issue| issue.status = @target_status}
251 end
252 end
253
254 @custom_fields = edited_issues.map{|i|i.editable_custom_fields}.reduce(:&)
237 @assignables = target_projects.map(&:assignable_users).reduce(:&)
255 @assignables = target_projects.map(&:assignable_users).reduce(:&)
238 @trackers = target_projects.map {|p| Issue.allowed_target_trackers(p) }.reduce(:&)
239 @versions = target_projects.map {|p| p.shared_versions.open}.reduce(:&)
256 @versions = target_projects.map {|p| p.shared_versions.open}.reduce(:&)
240 @categories = target_projects.map {|p| p.issue_categories}.reduce(:&)
257 @categories = target_projects.map {|p| p.issue_categories}.reduce(:&)
241 if @copy
258 if @copy
242 @attachments_present = @issues.detect {|i| i.attachments.any?}.present?
259 @attachments_present = @issues.detect {|i| i.attachments.any?}.present?
243 @subtasks_present = @issues.detect {|i| !i.leaf?}.present?
260 @subtasks_present = @issues.detect {|i| !i.leaf?}.present?
244 end
261 end
245
262
246 @safe_attributes = @issues.map(&:safe_attribute_names).reduce(:&)
263 @safe_attributes = edited_issues.map(&:safe_attribute_names).reduce(:&)
247
264
248 @issue_params = params[:issue] || {}
265 @issue_params = params[:issue] || {}
249 @issue_params[:custom_field_values] ||= {}
266 @issue_params[:custom_field_values] ||= {}
250 end
267 end
251
268
252 def bulk_update
269 def bulk_update
253 @issues.sort!
270 @issues.sort!
254 @copy = params[:copy].present?
271 @copy = params[:copy].present?
255
272
256 attributes = parse_params_for_bulk_update(params[:issue])
273 attributes = parse_params_for_bulk_update(params[:issue])
257 copy_subtasks = (params[:copy_subtasks] == '1')
274 copy_subtasks = (params[:copy_subtasks] == '1')
258 copy_attachments = (params[:copy_attachments] == '1')
275 copy_attachments = (params[:copy_attachments] == '1')
259
276
260 if @copy
277 if @copy
261 unless User.current.allowed_to?(:copy_issues, @projects)
278 unless User.current.allowed_to?(:copy_issues, @projects)
262 raise ::Unauthorized
279 raise ::Unauthorized
263 end
280 end
264 target_projects = @projects
281 target_projects = @projects
265 if attributes['project_id'].present?
282 if attributes['project_id'].present?
266 target_projects = Project.where(:id => attributes['project_id']).to_a
283 target_projects = Project.where(:id => attributes['project_id']).to_a
267 end
284 end
268 unless User.current.allowed_to?(:add_issues, target_projects)
285 unless User.current.allowed_to?(:add_issues, target_projects)
269 raise ::Unauthorized
286 raise ::Unauthorized
270 end
287 end
271 else
288 else
272 unless @issues.all?(&:attributes_editable?)
289 unless @issues.all?(&:attributes_editable?)
273 raise ::Unauthorized
290 raise ::Unauthorized
274 end
291 end
275 end
292 end
276
293
277 unsaved_issues = []
294 unsaved_issues = []
278 saved_issues = []
295 saved_issues = []
279
296
280 if @copy && copy_subtasks
297 if @copy && copy_subtasks
281 # Descendant issues will be copied with the parent task
298 # Descendant issues will be copied with the parent task
282 # Don't copy them twice
299 # Don't copy them twice
283 @issues.reject! {|issue| @issues.detect {|other| issue.is_descendant_of?(other)}}
300 @issues.reject! {|issue| @issues.detect {|other| issue.is_descendant_of?(other)}}
284 end
301 end
285
302
286 @issues.each do |orig_issue|
303 @issues.each do |orig_issue|
287 orig_issue.reload
304 orig_issue.reload
288 if @copy
305 if @copy
289 issue = orig_issue.copy({},
306 issue = orig_issue.copy({},
290 :attachments => copy_attachments,
307 :attachments => copy_attachments,
291 :subtasks => copy_subtasks,
308 :subtasks => copy_subtasks,
292 :link => link_copy?(params[:link_copy])
309 :link => link_copy?(params[:link_copy])
293 )
310 )
294 else
311 else
295 issue = orig_issue
312 issue = orig_issue
296 end
313 end
297 journal = issue.init_journal(User.current, params[:notes])
314 journal = issue.init_journal(User.current, params[:notes])
298 issue.safe_attributes = attributes
315 issue.safe_attributes = attributes
299 call_hook(:controller_issues_bulk_edit_before_save, { :params => params, :issue => issue })
316 call_hook(:controller_issues_bulk_edit_before_save, { :params => params, :issue => issue })
300 if issue.save
317 if issue.save
301 saved_issues << issue
318 saved_issues << issue
302 else
319 else
303 unsaved_issues << orig_issue
320 unsaved_issues << orig_issue
304 end
321 end
305 end
322 end
306
323
307 if unsaved_issues.empty?
324 if unsaved_issues.empty?
308 flash[:notice] = l(:notice_successful_update) unless saved_issues.empty?
325 flash[:notice] = l(:notice_successful_update) unless saved_issues.empty?
309 if params[:follow]
326 if params[:follow]
310 if @issues.size == 1 && saved_issues.size == 1
327 if @issues.size == 1 && saved_issues.size == 1
311 redirect_to issue_path(saved_issues.first)
328 redirect_to issue_path(saved_issues.first)
312 elsif saved_issues.map(&:project).uniq.size == 1
329 elsif saved_issues.map(&:project).uniq.size == 1
313 redirect_to project_issues_path(saved_issues.map(&:project).first)
330 redirect_to project_issues_path(saved_issues.map(&:project).first)
314 end
331 end
315 else
332 else
316 redirect_back_or_default _project_issues_path(@project)
333 redirect_back_or_default _project_issues_path(@project)
317 end
334 end
318 else
335 else
319 @saved_issues = @issues
336 @saved_issues = @issues
320 @unsaved_issues = unsaved_issues
337 @unsaved_issues = unsaved_issues
321 @issues = Issue.visible.where(:id => @unsaved_issues.map(&:id)).to_a
338 @issues = Issue.visible.where(:id => @unsaved_issues.map(&:id)).to_a
322 bulk_edit
339 bulk_edit
323 render :action => 'bulk_edit'
340 render :action => 'bulk_edit'
324 end
341 end
325 end
342 end
326
343
327 def destroy
344 def destroy
328 raise Unauthorized unless @issues.all?(&:deletable?)
345 raise Unauthorized unless @issues.all?(&:deletable?)
329 @hours = TimeEntry.where(:issue_id => @issues.map(&:id)).sum(:hours).to_f
346 @hours = TimeEntry.where(:issue_id => @issues.map(&:id)).sum(:hours).to_f
330 if @hours > 0
347 if @hours > 0
331 case params[:todo]
348 case params[:todo]
332 when 'destroy'
349 when 'destroy'
333 # nothing to do
350 # nothing to do
334 when 'nullify'
351 when 'nullify'
335 TimeEntry.where(['issue_id IN (?)', @issues]).update_all('issue_id = NULL')
352 TimeEntry.where(['issue_id IN (?)', @issues]).update_all('issue_id = NULL')
336 when 'reassign'
353 when 'reassign'
337 reassign_to = @project.issues.find_by_id(params[:reassign_to_id])
354 reassign_to = @project.issues.find_by_id(params[:reassign_to_id])
338 if reassign_to.nil?
355 if reassign_to.nil?
339 flash.now[:error] = l(:error_issue_not_found_in_project)
356 flash.now[:error] = l(:error_issue_not_found_in_project)
340 return
357 return
341 else
358 else
342 TimeEntry.where(['issue_id IN (?)', @issues]).
359 TimeEntry.where(['issue_id IN (?)', @issues]).
343 update_all("issue_id = #{reassign_to.id}")
360 update_all("issue_id = #{reassign_to.id}")
344 end
361 end
345 else
362 else
346 # display the destroy form if it's a user request
363 # display the destroy form if it's a user request
347 return unless api_request?
364 return unless api_request?
348 end
365 end
349 end
366 end
350 @issues.each do |issue|
367 @issues.each do |issue|
351 begin
368 begin
352 issue.reload.destroy
369 issue.reload.destroy
353 rescue ::ActiveRecord::RecordNotFound # raised by #reload if issue no longer exists
370 rescue ::ActiveRecord::RecordNotFound # raised by #reload if issue no longer exists
354 # nothing to do, issue was already deleted (eg. by a parent)
371 # nothing to do, issue was already deleted (eg. by a parent)
355 end
372 end
356 end
373 end
357 respond_to do |format|
374 respond_to do |format|
358 format.html { redirect_back_or_default _project_issues_path(@project) }
375 format.html { redirect_back_or_default _project_issues_path(@project) }
359 format.api { render_api_ok }
376 format.api { render_api_ok }
360 end
377 end
361 end
378 end
362
379
363 # Overrides Redmine::MenuManager::MenuController::ClassMethods for
380 # Overrides Redmine::MenuManager::MenuController::ClassMethods for
364 # when the "New issue" tab is enabled
381 # when the "New issue" tab is enabled
365 def current_menu_item
382 def current_menu_item
366 if Setting.new_item_menu_tab == '1' && [:new, :create].include?(action_name.to_sym)
383 if Setting.new_item_menu_tab == '1' && [:new, :create].include?(action_name.to_sym)
367 :new_issue
384 :new_issue
368 else
385 else
369 super
386 super
370 end
387 end
371 end
388 end
372
389
373 private
390 private
374
391
375 def retrieve_previous_and_next_issue_ids
392 def retrieve_previous_and_next_issue_ids
376 if params[:prev_issue_id].present? || params[:next_issue_id].present?
393 if params[:prev_issue_id].present? || params[:next_issue_id].present?
377 @prev_issue_id = params[:prev_issue_id].presence.try(:to_i)
394 @prev_issue_id = params[:prev_issue_id].presence.try(:to_i)
378 @next_issue_id = params[:next_issue_id].presence.try(:to_i)
395 @next_issue_id = params[:next_issue_id].presence.try(:to_i)
379 @issue_position = params[:issue_position].presence.try(:to_i)
396 @issue_position = params[:issue_position].presence.try(:to_i)
380 @issue_count = params[:issue_count].presence.try(:to_i)
397 @issue_count = params[:issue_count].presence.try(:to_i)
381 else
398 else
382 retrieve_query_from_session
399 retrieve_query_from_session
383 if @query
400 if @query
384 sort_init(@query.sort_criteria.empty? ? [['id', 'desc']] : @query.sort_criteria)
401 sort_init(@query.sort_criteria.empty? ? [['id', 'desc']] : @query.sort_criteria)
385 sort_update(@query.sortable_columns, 'issues_index_sort')
402 sort_update(@query.sortable_columns, 'issues_index_sort')
386 limit = 500
403 limit = 500
387 issue_ids = @query.issue_ids(:order => sort_clause, :limit => (limit + 1), :include => [:assigned_to, :tracker, :priority, :category, :fixed_version])
404 issue_ids = @query.issue_ids(:order => sort_clause, :limit => (limit + 1), :include => [:assigned_to, :tracker, :priority, :category, :fixed_version])
388 if (idx = issue_ids.index(@issue.id)) && idx < limit
405 if (idx = issue_ids.index(@issue.id)) && idx < limit
389 if issue_ids.size < 500
406 if issue_ids.size < 500
390 @issue_position = idx + 1
407 @issue_position = idx + 1
391 @issue_count = issue_ids.size
408 @issue_count = issue_ids.size
392 end
409 end
393 @prev_issue_id = issue_ids[idx - 1] if idx > 0
410 @prev_issue_id = issue_ids[idx - 1] if idx > 0
394 @next_issue_id = issue_ids[idx + 1] if idx < (issue_ids.size - 1)
411 @next_issue_id = issue_ids[idx + 1] if idx < (issue_ids.size - 1)
395 end
412 end
396 end
413 end
397 end
414 end
398 end
415 end
399
416
400 def previous_and_next_issue_ids_params
417 def previous_and_next_issue_ids_params
401 {
418 {
402 :prev_issue_id => params[:prev_issue_id],
419 :prev_issue_id => params[:prev_issue_id],
403 :next_issue_id => params[:next_issue_id],
420 :next_issue_id => params[:next_issue_id],
404 :issue_position => params[:issue_position],
421 :issue_position => params[:issue_position],
405 :issue_count => params[:issue_count]
422 :issue_count => params[:issue_count]
406 }.reject {|k,v| k.blank?}
423 }.reject {|k,v| k.blank?}
407 end
424 end
408
425
409 # Used by #edit and #update to set some common instance variables
426 # Used by #edit and #update to set some common instance variables
410 # from the params
427 # from the params
411 def update_issue_from_params
428 def update_issue_from_params
412 @time_entry = TimeEntry.new(:issue => @issue, :project => @issue.project)
429 @time_entry = TimeEntry.new(:issue => @issue, :project => @issue.project)
413 if params[:time_entry]
430 if params[:time_entry]
414 @time_entry.safe_attributes = params[:time_entry]
431 @time_entry.safe_attributes = params[:time_entry]
415 end
432 end
416
433
417 @issue.init_journal(User.current)
434 @issue.init_journal(User.current)
418
435
419 issue_attributes = params[:issue]
436 issue_attributes = params[:issue]
420 if issue_attributes && params[:conflict_resolution]
437 if issue_attributes && params[:conflict_resolution]
421 case params[:conflict_resolution]
438 case params[:conflict_resolution]
422 when 'overwrite'
439 when 'overwrite'
423 issue_attributes = issue_attributes.dup
440 issue_attributes = issue_attributes.dup
424 issue_attributes.delete(:lock_version)
441 issue_attributes.delete(:lock_version)
425 when 'add_notes'
442 when 'add_notes'
426 issue_attributes = issue_attributes.slice(:notes, :private_notes)
443 issue_attributes = issue_attributes.slice(:notes, :private_notes)
427 when 'cancel'
444 when 'cancel'
428 redirect_to issue_path(@issue)
445 redirect_to issue_path(@issue)
429 return false
446 return false
430 end
447 end
431 end
448 end
432 @issue.safe_attributes = issue_attributes
449 @issue.safe_attributes = issue_attributes
433 @priorities = IssuePriority.active
450 @priorities = IssuePriority.active
434 @allowed_statuses = @issue.new_statuses_allowed_to(User.current)
451 @allowed_statuses = @issue.new_statuses_allowed_to(User.current)
435 true
452 true
436 end
453 end
437
454
438 # Used by #new and #create to build a new issue from the params
455 # Used by #new and #create to build a new issue from the params
439 # The new issue will be copied from an existing one if copy_from parameter is given
456 # The new issue will be copied from an existing one if copy_from parameter is given
440 def build_new_issue_from_params
457 def build_new_issue_from_params
441 @issue = Issue.new
458 @issue = Issue.new
442 if params[:copy_from]
459 if params[:copy_from]
443 begin
460 begin
444 @issue.init_journal(User.current)
461 @issue.init_journal(User.current)
445 @copy_from = Issue.visible.find(params[:copy_from])
462 @copy_from = Issue.visible.find(params[:copy_from])
446 unless User.current.allowed_to?(:copy_issues, @copy_from.project)
463 unless User.current.allowed_to?(:copy_issues, @copy_from.project)
447 raise ::Unauthorized
464 raise ::Unauthorized
448 end
465 end
449 @link_copy = link_copy?(params[:link_copy]) || request.get?
466 @link_copy = link_copy?(params[:link_copy]) || request.get?
450 @copy_attachments = params[:copy_attachments].present? || request.get?
467 @copy_attachments = params[:copy_attachments].present? || request.get?
451 @copy_subtasks = params[:copy_subtasks].present? || request.get?
468 @copy_subtasks = params[:copy_subtasks].present? || request.get?
452 @issue.copy_from(@copy_from, :attachments => @copy_attachments, :subtasks => @copy_subtasks, :link => @link_copy)
469 @issue.copy_from(@copy_from, :attachments => @copy_attachments, :subtasks => @copy_subtasks, :link => @link_copy)
453 @issue.parent_issue_id = @copy_from.parent_id
470 @issue.parent_issue_id = @copy_from.parent_id
454 rescue ActiveRecord::RecordNotFound
471 rescue ActiveRecord::RecordNotFound
455 render_404
472 render_404
456 return
473 return
457 end
474 end
458 end
475 end
459 @issue.project = @project
476 @issue.project = @project
460 if request.get?
477 if request.get?
461 @issue.project ||= @issue.allowed_target_projects.first
478 @issue.project ||= @issue.allowed_target_projects.first
462 end
479 end
463 @issue.author ||= User.current
480 @issue.author ||= User.current
464 @issue.start_date ||= User.current.today if Setting.default_issue_start_date_to_creation_date?
481 @issue.start_date ||= User.current.today if Setting.default_issue_start_date_to_creation_date?
465
482
466 attrs = (params[:issue] || {}).deep_dup
483 attrs = (params[:issue] || {}).deep_dup
467 if action_name == 'new' && params[:was_default_status] == attrs[:status_id]
484 if action_name == 'new' && params[:was_default_status] == attrs[:status_id]
468 attrs.delete(:status_id)
485 attrs.delete(:status_id)
469 end
486 end
470 if action_name == 'new' && params[:form_update_triggered_by] == 'issue_project_id'
487 if action_name == 'new' && params[:form_update_triggered_by] == 'issue_project_id'
471 # Discard submitted version when changing the project on the issue form
488 # Discard submitted version when changing the project on the issue form
472 # so we can use the default version for the new project
489 # so we can use the default version for the new project
473 attrs.delete(:fixed_version_id)
490 attrs.delete(:fixed_version_id)
474 end
491 end
475 @issue.safe_attributes = attrs
492 @issue.safe_attributes = attrs
476
493
477 if @issue.project
494 if @issue.project
478 @issue.tracker ||= @issue.allowed_target_trackers.first
495 @issue.tracker ||= @issue.allowed_target_trackers.first
479 if @issue.tracker.nil?
496 if @issue.tracker.nil?
480 if @issue.project.trackers.any?
497 if @issue.project.trackers.any?
481 # None of the project trackers is allowed to the user
498 # None of the project trackers is allowed to the user
482 render_error :message => l(:error_no_tracker_allowed_for_new_issue_in_project), :status => 403
499 render_error :message => l(:error_no_tracker_allowed_for_new_issue_in_project), :status => 403
483 else
500 else
484 # Project has no trackers
501 # Project has no trackers
485 render_error l(:error_no_tracker_in_project)
502 render_error l(:error_no_tracker_in_project)
486 end
503 end
487 return false
504 return false
488 end
505 end
489 if @issue.status.nil?
506 if @issue.status.nil?
490 render_error l(:error_no_default_issue_status)
507 render_error l(:error_no_default_issue_status)
491 return false
508 return false
492 end
509 end
493 elsif request.get?
510 elsif request.get?
494 render_error :message => l(:error_no_projects_with_tracker_allowed_for_new_issue), :status => 403
511 render_error :message => l(:error_no_projects_with_tracker_allowed_for_new_issue), :status => 403
495 return false
512 return false
496 end
513 end
497
514
498 @priorities = IssuePriority.active
515 @priorities = IssuePriority.active
499 @allowed_statuses = @issue.new_statuses_allowed_to(User.current)
516 @allowed_statuses = @issue.new_statuses_allowed_to(User.current)
500 end
517 end
501
518
502 # Saves @issue and a time_entry from the parameters
519 # Saves @issue and a time_entry from the parameters
503 def save_issue_with_child_records
520 def save_issue_with_child_records
504 Issue.transaction do
521 Issue.transaction do
505 if params[:time_entry] && (params[:time_entry][:hours].present? || params[:time_entry][:comments].present?) && User.current.allowed_to?(:log_time, @issue.project)
522 if params[:time_entry] && (params[:time_entry][:hours].present? || params[:time_entry][:comments].present?) && User.current.allowed_to?(:log_time, @issue.project)
506 time_entry = @time_entry || TimeEntry.new
523 time_entry = @time_entry || TimeEntry.new
507 time_entry.project = @issue.project
524 time_entry.project = @issue.project
508 time_entry.issue = @issue
525 time_entry.issue = @issue
509 time_entry.user = User.current
526 time_entry.user = User.current
510 time_entry.spent_on = User.current.today
527 time_entry.spent_on = User.current.today
511 time_entry.attributes = params[:time_entry]
528 time_entry.attributes = params[:time_entry]
512 @issue.time_entries << time_entry
529 @issue.time_entries << time_entry
513 end
530 end
514
531
515 call_hook(:controller_issues_edit_before_save, { :params => params, :issue => @issue, :time_entry => time_entry, :journal => @issue.current_journal})
532 call_hook(:controller_issues_edit_before_save, { :params => params, :issue => @issue, :time_entry => time_entry, :journal => @issue.current_journal})
516 if @issue.save
533 if @issue.save
517 call_hook(:controller_issues_edit_after_save, { :params => params, :issue => @issue, :time_entry => time_entry, :journal => @issue.current_journal})
534 call_hook(:controller_issues_edit_after_save, { :params => params, :issue => @issue, :time_entry => time_entry, :journal => @issue.current_journal})
518 else
535 else
519 raise ActiveRecord::Rollback
536 raise ActiveRecord::Rollback
520 end
537 end
521 end
538 end
522 end
539 end
523
540
524 # Returns true if the issue copy should be linked
541 # Returns true if the issue copy should be linked
525 # to the original issue
542 # to the original issue
526 def link_copy?(param)
543 def link_copy?(param)
527 case Setting.link_copied_issue
544 case Setting.link_copied_issue
528 when 'yes'
545 when 'yes'
529 true
546 true
530 when 'no'
547 when 'no'
531 false
548 false
532 when 'ask'
549 when 'ask'
533 param == '1'
550 param == '1'
534 end
551 end
535 end
552 end
536
553
537 # Redirects user after a successful issue creation
554 # Redirects user after a successful issue creation
538 def redirect_after_create
555 def redirect_after_create
539 if params[:continue]
556 if params[:continue]
540 attrs = {:tracker_id => @issue.tracker, :parent_issue_id => @issue.parent_issue_id}.reject {|k,v| v.nil?}
557 attrs = {:tracker_id => @issue.tracker, :parent_issue_id => @issue.parent_issue_id}.reject {|k,v| v.nil?}
541 if params[:project_id]
558 if params[:project_id]
542 redirect_to new_project_issue_path(@issue.project, :issue => attrs)
559 redirect_to new_project_issue_path(@issue.project, :issue => attrs)
543 else
560 else
544 attrs.merge! :project_id => @issue.project_id
561 attrs.merge! :project_id => @issue.project_id
545 redirect_to new_issue_path(:issue => attrs)
562 redirect_to new_issue_path(:issue => attrs)
546 end
563 end
547 else
564 else
548 redirect_to issue_path(@issue)
565 redirect_to issue_path(@issue)
549 end
566 end
550 end
567 end
551 end
568 end
@@ -1,215 +1,217
1 <h2><%= @copy ? l(:button_copy) : l(:label_bulk_edit_selected_issues) %></h2>
1 <h2><%= @copy ? l(:button_copy) : l(:label_bulk_edit_selected_issues) %></h2>
2
2
3 <% if @saved_issues && @unsaved_issues.present? %>
3 <% if @saved_issues && @unsaved_issues.present? %>
4 <div id="errorExplanation">
4 <div id="errorExplanation">
5 <span>
5 <span>
6 <%= l(:notice_failed_to_save_issues,
6 <%= l(:notice_failed_to_save_issues,
7 :count => @unsaved_issues.size,
7 :count => @unsaved_issues.size,
8 :total => @saved_issues.size,
8 :total => @saved_issues.size,
9 :ids => @unsaved_issues.map {|i| "##{i.id}"}.join(', ')) %>
9 :ids => @unsaved_issues.map {|i| "##{i.id}"}.join(', ')) %>
10 </span>
10 </span>
11 <ul>
11 <ul>
12 <% bulk_edit_error_messages(@unsaved_issues).each do |message| %>
12 <% bulk_edit_error_messages(@unsaved_issues).each do |message| %>
13 <li><%= message %></li>
13 <li><%= message %></li>
14 <% end %>
14 <% end %>
15 </ul>
15 </ul>
16 </div>
16 </div>
17 <% end %>
17 <% end %>
18
18
19 <ul id="bulk-selection">
19 <ul id="bulk-selection">
20 <% @issues.each do |issue| %>
20 <% @issues.each do |issue| %>
21 <%= content_tag 'li', link_to_issue(issue) %>
21 <%= content_tag 'li', link_to_issue(issue) %>
22 <% end %>
22 <% end %>
23 </ul>
23 </ul>
24
24
25 <%= form_tag(bulk_update_issues_path, :id => 'bulk_edit_form') do %>
25 <%= form_tag(bulk_update_issues_path, :id => 'bulk_edit_form') do %>
26 <%= @issues.collect {|i| hidden_field_tag('ids[]', i.id, :id => nil)}.join("\n").html_safe %>
26 <%= @issues.collect {|i| hidden_field_tag('ids[]', i.id, :id => nil)}.join("\n").html_safe %>
27 <div class="box tabular">
27 <div class="box tabular">
28 <fieldset class="attributes">
28 <fieldset class="attributes">
29 <legend><%= l(:label_change_properties) %></legend>
29 <legend><%= l(:label_change_properties) %></legend>
30
30
31 <div class="splitcontentleft">
31 <div class="splitcontentleft">
32 <% if @allowed_projects.present? %>
32 <% if @allowed_projects.present? %>
33 <p>
33 <p>
34 <label for="issue_project_id"><%= l(:field_project) %></label>
34 <label for="issue_project_id"><%= l(:field_project) %></label>
35 <%= select_tag('issue[project_id]',
35 <%= select_tag('issue[project_id]',
36 project_tree_options_for_select(@allowed_projects,
36 project_tree_options_for_select(@allowed_projects,
37 :include_blank => ((!@copy || (@projects & @allowed_projects == @projects)) ? l(:label_no_change_option) : false),
37 :include_blank => ((!@copy || (@projects & @allowed_projects == @projects)) ? l(:label_no_change_option) : false),
38 :selected => @target_project),
38 :selected => @target_project),
39 :onchange => "updateBulkEditFrom('#{escape_javascript url_for(:action => 'bulk_edit', :format => 'js')}')") %>
39 :onchange => "updateBulkEditFrom('#{escape_javascript url_for(:action => 'bulk_edit', :format => 'js')}')") %>
40 </p>
40 </p>
41 <% end %>
41 <% end %>
42 <p>
42 <p>
43 <label for="issue_tracker_id"><%= l(:field_tracker) %></label>
43 <label for="issue_tracker_id"><%= l(:field_tracker) %></label>
44 <%= select_tag('issue[tracker_id]',
44 <%= select_tag('issue[tracker_id]',
45 content_tag('option', l(:label_no_change_option), :value => '') +
45 content_tag('option', l(:label_no_change_option), :value => '') +
46 options_from_collection_for_select(@trackers, :id, :name, @issue_params[:tracker_id])) %>
46 options_from_collection_for_select(@trackers, :id, :name, @issue_params[:tracker_id]),
47 :onchange => "updateBulkEditFrom('#{escape_javascript url_for(:action => 'bulk_edit', :format => 'js')}')") %>
47 </p>
48 </p>
48 <% if @available_statuses.any? %>
49 <% if @available_statuses.any? %>
49 <p>
50 <p>
50 <label for='issue_status_id'><%= l(:field_status) %></label>
51 <label for='issue_status_id'><%= l(:field_status) %></label>
51 <%= select_tag('issue[status_id]',
52 <%= select_tag('issue[status_id]',
52 content_tag('option', l(:label_no_change_option), :value => '') +
53 content_tag('option', l(:label_no_change_option), :value => '') +
53 options_from_collection_for_select(@available_statuses, :id, :name, @issue_params[:status_id])) %>
54 options_from_collection_for_select(@available_statuses, :id, :name, @issue_params[:status_id]),
55 :onchange => "updateBulkEditFrom('#{escape_javascript url_for(:action => 'bulk_edit', :format => 'js')}')") %>
54 </p>
56 </p>
55 <% end %>
57 <% end %>
56
58
57 <% if @safe_attributes.include?('priority_id') -%>
59 <% if @safe_attributes.include?('priority_id') -%>
58 <p>
60 <p>
59 <label for='issue_priority_id'><%= l(:field_priority) %></label>
61 <label for='issue_priority_id'><%= l(:field_priority) %></label>
60 <%= select_tag('issue[priority_id]',
62 <%= select_tag('issue[priority_id]',
61 content_tag('option', l(:label_no_change_option), :value => '') +
63 content_tag('option', l(:label_no_change_option), :value => '') +
62 options_from_collection_for_select(IssuePriority.active, :id, :name, @issue_params[:priority_id])) %>
64 options_from_collection_for_select(IssuePriority.active, :id, :name, @issue_params[:priority_id])) %>
63 </p>
65 </p>
64 <% end %>
66 <% end %>
65
67
66 <% if @safe_attributes.include?('assigned_to_id') -%>
68 <% if @safe_attributes.include?('assigned_to_id') -%>
67 <p>
69 <p>
68 <label for='issue_assigned_to_id'><%= l(:field_assigned_to) %></label>
70 <label for='issue_assigned_to_id'><%= l(:field_assigned_to) %></label>
69 <%= select_tag('issue[assigned_to_id]',
71 <%= select_tag('issue[assigned_to_id]',
70 content_tag('option', l(:label_no_change_option), :value => '') +
72 content_tag('option', l(:label_no_change_option), :value => '') +
71 content_tag('option', l(:label_nobody), :value => 'none', :selected => (@issue_params[:assigned_to_id] == 'none')) +
73 content_tag('option', l(:label_nobody), :value => 'none', :selected => (@issue_params[:assigned_to_id] == 'none')) +
72 principals_options_for_select(@assignables, @issue_params[:assigned_to_id])) %>
74 principals_options_for_select(@assignables, @issue_params[:assigned_to_id])) %>
73 </p>
75 </p>
74 <% end %>
76 <% end %>
75
77
76 <% if @safe_attributes.include?('category_id') -%>
78 <% if @safe_attributes.include?('category_id') -%>
77 <p>
79 <p>
78 <label for='issue_category_id'><%= l(:field_category) %></label>
80 <label for='issue_category_id'><%= l(:field_category) %></label>
79 <%= select_tag('issue[category_id]', content_tag('option', l(:label_no_change_option), :value => '') +
81 <%= select_tag('issue[category_id]', content_tag('option', l(:label_no_change_option), :value => '') +
80 content_tag('option', l(:label_none), :value => 'none', :selected => (@issue_params[:category_id] == 'none')) +
82 content_tag('option', l(:label_none), :value => 'none', :selected => (@issue_params[:category_id] == 'none')) +
81 options_from_collection_for_select(@categories, :id, :name, @issue_params[:category_id])) %>
83 options_from_collection_for_select(@categories, :id, :name, @issue_params[:category_id])) %>
82 </p>
84 </p>
83 <% end %>
85 <% end %>
84
86
85 <% if @safe_attributes.include?('fixed_version_id') -%>
87 <% if @safe_attributes.include?('fixed_version_id') -%>
86 <p>
88 <p>
87 <label for='issue_fixed_version_id'><%= l(:field_fixed_version) %></label>
89 <label for='issue_fixed_version_id'><%= l(:field_fixed_version) %></label>
88 <%= select_tag('issue[fixed_version_id]', content_tag('option', l(:label_no_change_option), :value => '') +
90 <%= select_tag('issue[fixed_version_id]', content_tag('option', l(:label_no_change_option), :value => '') +
89 content_tag('option', l(:label_none), :value => 'none', :selected => (@issue_params[:fixed_version_id] == 'none')) +
91 content_tag('option', l(:label_none), :value => 'none', :selected => (@issue_params[:fixed_version_id] == 'none')) +
90 version_options_for_select(@versions.sort, @issue_params[:fixed_version_id])) %>
92 version_options_for_select(@versions.sort, @issue_params[:fixed_version_id])) %>
91 </p>
93 </p>
92 <% end %>
94 <% end %>
93
95
94 <% @custom_fields.each do |custom_field| %>
96 <% @custom_fields.each do |custom_field| %>
95 <p>
97 <p>
96 <label><%= custom_field.name %></label>
98 <label><%= custom_field.name %></label>
97 <%= custom_field_tag_for_bulk_edit('issue', custom_field, @issues, @issue_params[:custom_field_values][custom_field.id.to_s]) %>
99 <%= custom_field_tag_for_bulk_edit('issue', custom_field, @issues, @issue_params[:custom_field_values][custom_field.id.to_s]) %>
98 </p>
100 </p>
99 <% end %>
101 <% end %>
100
102
101 <% if @copy && Setting.link_copied_issue == 'ask' %>
103 <% if @copy && Setting.link_copied_issue == 'ask' %>
102 <p>
104 <p>
103 <label for='link_copy'><%= l(:label_link_copied_issue) %></label>
105 <label for='link_copy'><%= l(:label_link_copied_issue) %></label>
104 <%= hidden_field_tag 'link_copy', '0' %>
106 <%= hidden_field_tag 'link_copy', '0' %>
105 <%= check_box_tag 'link_copy', '1', params[:link_copy] != 0 %>
107 <%= check_box_tag 'link_copy', '1', params[:link_copy] != 0 %>
106 </p>
108 </p>
107 <% end %>
109 <% end %>
108
110
109 <% if @copy && @attachments_present %>
111 <% if @copy && @attachments_present %>
110 <%= hidden_field_tag 'copy_attachments', '0' %>
112 <%= hidden_field_tag 'copy_attachments', '0' %>
111 <p>
113 <p>
112 <label for='copy_attachments'><%= l(:label_copy_attachments) %></label>
114 <label for='copy_attachments'><%= l(:label_copy_attachments) %></label>
113 <%= check_box_tag 'copy_attachments', '1', params[:copy_attachments] != '0' %>
115 <%= check_box_tag 'copy_attachments', '1', params[:copy_attachments] != '0' %>
114 </p>
116 </p>
115 <% end %>
117 <% end %>
116
118
117 <% if @copy && @subtasks_present %>
119 <% if @copy && @subtasks_present %>
118 <%= hidden_field_tag 'copy_subtasks', '0' %>
120 <%= hidden_field_tag 'copy_subtasks', '0' %>
119 <p>
121 <p>
120 <label for='copy_subtasks'><%= l(:label_copy_subtasks) %></label>
122 <label for='copy_subtasks'><%= l(:label_copy_subtasks) %></label>
121 <%= check_box_tag 'copy_subtasks', '1', params[:copy_subtasks] != '0' %>
123 <%= check_box_tag 'copy_subtasks', '1', params[:copy_subtasks] != '0' %>
122 </p>
124 </p>
123 <% end %>
125 <% end %>
124
126
125 <%= call_hook(:view_issues_bulk_edit_details_bottom, { :issues => @issues }) %>
127 <%= call_hook(:view_issues_bulk_edit_details_bottom, { :issues => @issues }) %>
126 </div>
128 </div>
127
129
128 <div class="splitcontentright">
130 <div class="splitcontentright">
129 <% if @safe_attributes.include?('is_private') %>
131 <% if @safe_attributes.include?('is_private') %>
130 <p>
132 <p>
131 <label for='issue_is_private'><%= l(:field_is_private) %></label>
133 <label for='issue_is_private'><%= l(:field_is_private) %></label>
132 <%= select_tag('issue[is_private]', content_tag('option', l(:label_no_change_option), :value => '') +
134 <%= select_tag('issue[is_private]', content_tag('option', l(:label_no_change_option), :value => '') +
133 content_tag('option', l(:general_text_Yes), :value => '1', :selected => (@issue_params[:is_private] == '1')) +
135 content_tag('option', l(:general_text_Yes), :value => '1', :selected => (@issue_params[:is_private] == '1')) +
134 content_tag('option', l(:general_text_No), :value => '0', :selected => (@issue_params[:is_private] == '0'))) %>
136 content_tag('option', l(:general_text_No), :value => '0', :selected => (@issue_params[:is_private] == '0'))) %>
135 </p>
137 </p>
136 <% end %>
138 <% end %>
137
139
138 <% if @safe_attributes.include?('parent_issue_id') && @project %>
140 <% if @safe_attributes.include?('parent_issue_id') && @project %>
139 <p>
141 <p>
140 <label for='issue_parent_issue_id'><%= l(:field_parent_issue) %></label>
142 <label for='issue_parent_issue_id'><%= l(:field_parent_issue) %></label>
141 <%= text_field_tag 'issue[parent_issue_id]', '', :size => 10, :value => @issue_params[:parent_issue_id] %>
143 <%= text_field_tag 'issue[parent_issue_id]', '', :size => 10, :value => @issue_params[:parent_issue_id] %>
142 <label class="inline"><%= check_box_tag 'issue[parent_issue_id]', 'none', (@issue_params[:parent_issue_id] == 'none'), :id => nil, :data => {:disables => '#issue_parent_issue_id'} %><%= l(:button_clear) %></label>
144 <label class="inline"><%= check_box_tag 'issue[parent_issue_id]', 'none', (@issue_params[:parent_issue_id] == 'none'), :id => nil, :data => {:disables => '#issue_parent_issue_id'} %><%= l(:button_clear) %></label>
143 </p>
145 </p>
144 <%= javascript_tag "observeAutocompleteField('issue_parent_issue_id', '#{escape_javascript auto_complete_issues_path(:project_id => @project, :scope => Setting.cross_project_subtasks)}')" %>
146 <%= javascript_tag "observeAutocompleteField('issue_parent_issue_id', '#{escape_javascript auto_complete_issues_path(:project_id => @project, :scope => Setting.cross_project_subtasks)}')" %>
145 <% end %>
147 <% end %>
146
148
147 <% if @safe_attributes.include?('start_date') %>
149 <% if @safe_attributes.include?('start_date') %>
148 <p>
150 <p>
149 <label for='issue_start_date'><%= l(:field_start_date) %></label>
151 <label for='issue_start_date'><%= l(:field_start_date) %></label>
150 <%= date_field_tag 'issue[start_date]', '', :value => @issue_params[:start_date], :size => 10 %><%= calendar_for('issue_start_date') %>
152 <%= date_field_tag 'issue[start_date]', '', :value => @issue_params[:start_date], :size => 10 %><%= calendar_for('issue_start_date') %>
151 <label class="inline"><%= check_box_tag 'issue[start_date]', 'none', (@issue_params[:start_date] == 'none'), :id => nil, :data => {:disables => '#issue_start_date'} %><%= l(:button_clear) %></label>
153 <label class="inline"><%= check_box_tag 'issue[start_date]', 'none', (@issue_params[:start_date] == 'none'), :id => nil, :data => {:disables => '#issue_start_date'} %><%= l(:button_clear) %></label>
152 </p>
154 </p>
153 <% end %>
155 <% end %>
154
156
155 <% if @safe_attributes.include?('due_date') %>
157 <% if @safe_attributes.include?('due_date') %>
156 <p>
158 <p>
157 <label for='issue_due_date'><%= l(:field_due_date) %></label>
159 <label for='issue_due_date'><%= l(:field_due_date) %></label>
158 <%= date_field_tag 'issue[due_date]', '', :value => @issue_params[:due_date], :size => 10 %><%= calendar_for('issue_due_date') %>
160 <%= date_field_tag 'issue[due_date]', '', :value => @issue_params[:due_date], :size => 10 %><%= calendar_for('issue_due_date') %>
159 <label class="inline"><%= check_box_tag 'issue[due_date]', 'none', (@issue_params[:due_date] == 'none'), :id => nil, :data => {:disables => '#issue_due_date'} %><%= l(:button_clear) %></label>
161 <label class="inline"><%= check_box_tag 'issue[due_date]', 'none', (@issue_params[:due_date] == 'none'), :id => nil, :data => {:disables => '#issue_due_date'} %><%= l(:button_clear) %></label>
160 </p>
162 </p>
161 <% end %>
163 <% end %>
162
164
163 <% if @safe_attributes.include?('estimated_hours') %>
165 <% if @safe_attributes.include?('estimated_hours') %>
164 <p>
166 <p>
165 <label for='issue_estimated_hours'><%= l(:field_estimated_hours) %></label>
167 <label for='issue_estimated_hours'><%= l(:field_estimated_hours) %></label>
166 <%= text_field_tag 'issue[estimated_hours]', '', :value => @issue_params[:estimated_hours], :size => 10 %>
168 <%= text_field_tag 'issue[estimated_hours]', '', :value => @issue_params[:estimated_hours], :size => 10 %>
167 <label class="inline"><%= check_box_tag 'issue[estimated_hours]', 'none', (@issue_params[:estimated_hours] == 'none'), :id => nil, :data => {:disables => '#issue_estimated_hours'} %><%= l(:button_clear) %></label>
169 <label class="inline"><%= check_box_tag 'issue[estimated_hours]', 'none', (@issue_params[:estimated_hours] == 'none'), :id => nil, :data => {:disables => '#issue_estimated_hours'} %><%= l(:button_clear) %></label>
168 </p>
170 </p>
169 <% end %>
171 <% end %>
170
172
171 <% if @safe_attributes.include?('done_ratio') && Issue.use_field_for_done_ratio? %>
173 <% if @safe_attributes.include?('done_ratio') && Issue.use_field_for_done_ratio? %>
172 <p>
174 <p>
173 <label for='issue_done_ratio'><%= l(:field_done_ratio) %></label>
175 <label for='issue_done_ratio'><%= l(:field_done_ratio) %></label>
174 <%= select_tag 'issue[done_ratio]', options_for_select([[l(:label_no_change_option), '']] + (0..10).to_a.collect {|r| ["#{r*10} %", r*10] }, @issue_params[:done_ratio]) %>
176 <%= select_tag 'issue[done_ratio]', options_for_select([[l(:label_no_change_option), '']] + (0..10).to_a.collect {|r| ["#{r*10} %", r*10] }, @issue_params[:done_ratio]) %>
175 </p>
177 </p>
176 <% end %>
178 <% end %>
177 </div>
179 </div>
178 </fieldset>
180 </fieldset>
179
181
180 <fieldset>
182 <fieldset>
181 <legend><%= l(:field_notes) %></legend>
183 <legend><%= l(:field_notes) %></legend>
182 <%= text_area_tag 'notes', @notes, :cols => 60, :rows => 10, :class => 'wiki-edit' %>
184 <%= text_area_tag 'notes', @notes, :cols => 60, :rows => 10, :class => 'wiki-edit' %>
183 <%= wikitoolbar_for 'notes' %>
185 <%= wikitoolbar_for 'notes' %>
184 </fieldset>
186 </fieldset>
185 </div>
187 </div>
186
188
187 <p>
189 <p>
188 <% if @copy %>
190 <% if @copy %>
189 <%= hidden_field_tag 'copy', '1' %>
191 <%= hidden_field_tag 'copy', '1' %>
190 <%= submit_tag l(:button_copy) %>
192 <%= submit_tag l(:button_copy) %>
191 <%= submit_tag l(:button_copy_and_follow), :name => 'follow' %>
193 <%= submit_tag l(:button_copy_and_follow), :name => 'follow' %>
192 <% elsif @target_project %>
194 <% elsif @target_project %>
193 <%= submit_tag l(:button_move) %>
195 <%= submit_tag l(:button_move) %>
194 <%= submit_tag l(:button_move_and_follow), :name => 'follow' %>
196 <%= submit_tag l(:button_move_and_follow), :name => 'follow' %>
195 <% else %>
197 <% else %>
196 <%= submit_tag l(:button_submit) %>
198 <%= submit_tag l(:button_submit) %>
197 <% end %>
199 <% end %>
198 </p>
200 </p>
199
201
200 <% end %>
202 <% end %>
201
203
202 <%= javascript_tag do %>
204 <%= javascript_tag do %>
203 $(window).load(function(){
205 $(window).load(function(){
204 $(document).on('change', 'input[data-disables]', function(){
206 $(document).on('change', 'input[data-disables]', function(){
205 if ($(this).prop('checked')){
207 if ($(this).prop('checked')){
206 $($(this).data('disables')).attr('disabled', true).val('');
208 $($(this).data('disables')).attr('disabled', true).val('');
207 } else {
209 } else {
208 $($(this).data('disables')).attr('disabled', false);
210 $($(this).data('disables')).attr('disabled', false);
209 }
211 }
210 });
212 });
211 });
213 });
212 $(document).ready(function(){
214 $(document).ready(function(){
213 $('input[data-disables]').trigger('change');
215 $('input[data-disables]').trigger('change');
214 });
216 });
215 <% end %>
217 <% end %>
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
General Comments 0
You need to be logged in to leave comments. Login now