##// END OF EJS Templates
Adds tracker update to context menu and bulk edit form (#2405)....
Jean-Philippe Lang -
r2995:f134e72fec4a
parent child
Show More
@@ -1,530 +1,533
1 # Redmine - project management software
1 # Redmine - project management software
2 # Copyright (C) 2006-2008 Jean-Philippe Lang
2 # Copyright (C) 2006-2008 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
18 class IssuesController < ApplicationController
18 class IssuesController < ApplicationController
19 menu_item :new_issue, :only => :new
19 menu_item :new_issue, :only => :new
20 default_search_scope :issues
20 default_search_scope :issues
21
21
22 before_filter :find_issue, :only => [:show, :edit, :reply]
22 before_filter :find_issue, :only => [:show, :edit, :reply]
23 before_filter :find_issues, :only => [:bulk_edit, :move, :destroy]
23 before_filter :find_issues, :only => [:bulk_edit, :move, :destroy]
24 before_filter :find_project, :only => [:new, :update_form, :preview]
24 before_filter :find_project, :only => [:new, :update_form, :preview]
25 before_filter :authorize, :except => [:index, :changes, :gantt, :calendar, :preview, :context_menu]
25 before_filter :authorize, :except => [:index, :changes, :gantt, :calendar, :preview, :context_menu]
26 before_filter :find_optional_project, :only => [:index, :changes, :gantt, :calendar]
26 before_filter :find_optional_project, :only => [:index, :changes, :gantt, :calendar]
27 accept_key_auth :index, :show, :changes
27 accept_key_auth :index, :show, :changes
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 include ProjectsHelper
33 include ProjectsHelper
34 helper :custom_fields
34 helper :custom_fields
35 include CustomFieldsHelper
35 include CustomFieldsHelper
36 helper :issue_relations
36 helper :issue_relations
37 include IssueRelationsHelper
37 include IssueRelationsHelper
38 helper :watchers
38 helper :watchers
39 include WatchersHelper
39 include WatchersHelper
40 helper :attachments
40 helper :attachments
41 include AttachmentsHelper
41 include AttachmentsHelper
42 helper :queries
42 helper :queries
43 helper :sort
43 helper :sort
44 include SortHelper
44 include SortHelper
45 include IssuesHelper
45 include IssuesHelper
46 helper :timelog
46 helper :timelog
47 include Redmine::Export::PDF
47 include Redmine::Export::PDF
48
48
49 verify :method => :post,
49 verify :method => :post,
50 :only => :destroy,
50 :only => :destroy,
51 :render => { :nothing => true, :status => :method_not_allowed }
51 :render => { :nothing => true, :status => :method_not_allowed }
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({'id' => "#{Issue.table_name}.id"}.merge(@query.available_columns.inject({}) {|h, c| h[c.name.to_s] = c.sortable; h}))
56 sort_update({'id' => "#{Issue.table_name}.id"}.merge(@query.available_columns.inject({}) {|h, c| h[c.name.to_s] = c.sortable; h}))
57
57
58 if @query.valid?
58 if @query.valid?
59 limit = per_page_option
59 limit = per_page_option
60 respond_to do |format|
60 respond_to do |format|
61 format.html { }
61 format.html { }
62 format.atom { limit = Setting.feeds_limit.to_i }
62 format.atom { limit = Setting.feeds_limit.to_i }
63 format.csv { limit = Setting.issues_export_limit.to_i }
63 format.csv { limit = Setting.issues_export_limit.to_i }
64 format.pdf { limit = Setting.issues_export_limit.to_i }
64 format.pdf { limit = Setting.issues_export_limit.to_i }
65 end
65 end
66
66
67 @issue_count = @query.issue_count
67 @issue_count = @query.issue_count
68 @issue_pages = Paginator.new self, @issue_count, limit, params['page']
68 @issue_pages = Paginator.new self, @issue_count, limit, params['page']
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 => @issue_pages.current.offset,
71 :offset => @issue_pages.current.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.rhtml', :layout => !request.xhr? }
76 format.html { render :template => 'issues/index.rhtml', :layout => !request.xhr? }
77 format.atom { render_feed(@issues, :title => "#{@project || Setting.app_title}: #{l(:label_issue_plural)}") }
77 format.atom { render_feed(@issues, :title => "#{@project || Setting.app_title}: #{l(:label_issue_plural)}") }
78 format.csv { send_data(issues_to_csv(@issues, @project), :type => 'text/csv; header=present', :filename => 'export.csv') }
78 format.csv { send_data(issues_to_csv(@issues, @project), :type => 'text/csv; header=present', :filename => 'export.csv') }
79 format.pdf { send_data(issues_to_pdf(@issues, @project, @query), :type => 'application/pdf', :filename => 'export.pdf') }
79 format.pdf { send_data(issues_to_pdf(@issues, @project, @query), :type => 'application/pdf', :filename => 'export.pdf') }
80 end
80 end
81 else
81 else
82 # Send html if the query is not valid
82 # Send html if the query is not valid
83 render(:template => 'issues/index.rhtml', :layout => !request.xhr?)
83 render(:template => 'issues/index.rhtml', :layout => !request.xhr?)
84 end
84 end
85 rescue ActiveRecord::RecordNotFound
85 rescue ActiveRecord::RecordNotFound
86 render_404
86 render_404
87 end
87 end
88
88
89 def changes
89 def changes
90 retrieve_query
90 retrieve_query
91 sort_init 'id', 'desc'
91 sort_init 'id', 'desc'
92 sort_update({'id' => "#{Issue.table_name}.id"}.merge(@query.available_columns.inject({}) {|h, c| h[c.name.to_s] = c.sortable; h}))
92 sort_update({'id' => "#{Issue.table_name}.id"}.merge(@query.available_columns.inject({}) {|h, c| h[c.name.to_s] = c.sortable; h}))
93
93
94 if @query.valid?
94 if @query.valid?
95 @journals = @query.journals(:order => "#{Journal.table_name}.created_on DESC",
95 @journals = @query.journals(:order => "#{Journal.table_name}.created_on DESC",
96 :limit => 25)
96 :limit => 25)
97 end
97 end
98 @title = (@project ? @project.name : Setting.app_title) + ": " + (@query.new_record? ? l(:label_changes_details) : @query.name)
98 @title = (@project ? @project.name : Setting.app_title) + ": " + (@query.new_record? ? l(:label_changes_details) : @query.name)
99 render :layout => false, :content_type => 'application/atom+xml'
99 render :layout => false, :content_type => 'application/atom+xml'
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.find(:all, :include => [:user, :details], :order => "#{Journal.table_name}.created_on ASC")
105 @journals = @issue.journals.find(:all, :include => [:user, :details], :order => "#{Journal.table_name}.created_on ASC")
106 @journals.each_with_index {|j,i| j.indice = i+1}
106 @journals.each_with_index {|j,i| j.indice = i+1}
107 @journals.reverse! if User.current.wants_comments_in_reverse_order?
107 @journals.reverse! if User.current.wants_comments_in_reverse_order?
108 @changesets = @issue.changesets
108 @changesets = @issue.changesets
109 @changesets.reverse! if User.current.wants_comments_in_reverse_order?
109 @changesets.reverse! if User.current.wants_comments_in_reverse_order?
110 @allowed_statuses = @issue.new_statuses_allowed_to(User.current)
110 @allowed_statuses = @issue.new_statuses_allowed_to(User.current)
111 @edit_allowed = User.current.allowed_to?(:edit_issues, @project)
111 @edit_allowed = User.current.allowed_to?(:edit_issues, @project)
112 @priorities = IssuePriority.all
112 @priorities = IssuePriority.all
113 @time_entry = TimeEntry.new
113 @time_entry = TimeEntry.new
114 respond_to do |format|
114 respond_to do |format|
115 format.html { render :template => 'issues/show.rhtml' }
115 format.html { render :template => 'issues/show.rhtml' }
116 format.atom { render :action => 'changes', :layout => false, :content_type => 'application/atom+xml' }
116 format.atom { render :action => 'changes', :layout => false, :content_type => 'application/atom+xml' }
117 format.pdf { send_data(issue_to_pdf(@issue), :type => 'application/pdf', :filename => "#{@project.identifier}-#{@issue.id}.pdf") }
117 format.pdf { send_data(issue_to_pdf(@issue), :type => 'application/pdf', :filename => "#{@project.identifier}-#{@issue.id}.pdf") }
118 end
118 end
119 end
119 end
120
120
121 # Add a new issue
121 # Add a new issue
122 # The new issue will be created from an existing one if copy_from parameter is given
122 # The new issue will be created from an existing one if copy_from parameter is given
123 def new
123 def new
124 @issue = Issue.new
124 @issue = Issue.new
125 @issue.copy_from(params[:copy_from]) if params[:copy_from]
125 @issue.copy_from(params[:copy_from]) if params[:copy_from]
126 @issue.project = @project
126 @issue.project = @project
127 # Tracker must be set before custom field values
127 # Tracker must be set before custom field values
128 @issue.tracker ||= @project.trackers.find((params[:issue] && params[:issue][:tracker_id]) || params[:tracker_id] || :first)
128 @issue.tracker ||= @project.trackers.find((params[:issue] && params[:issue][:tracker_id]) || params[:tracker_id] || :first)
129 if @issue.tracker.nil?
129 if @issue.tracker.nil?
130 render_error l(:error_no_tracker_in_project)
130 render_error l(:error_no_tracker_in_project)
131 return
131 return
132 end
132 end
133 if params[:issue].is_a?(Hash)
133 if params[:issue].is_a?(Hash)
134 @issue.attributes = params[:issue]
134 @issue.attributes = params[:issue]
135 @issue.watcher_user_ids = params[:issue]['watcher_user_ids'] if User.current.allowed_to?(:add_issue_watchers, @project)
135 @issue.watcher_user_ids = params[:issue]['watcher_user_ids'] if User.current.allowed_to?(:add_issue_watchers, @project)
136 end
136 end
137 @issue.author = User.current
137 @issue.author = User.current
138
138
139 default_status = IssueStatus.default
139 default_status = IssueStatus.default
140 unless default_status
140 unless default_status
141 render_error l(:error_no_default_issue_status)
141 render_error l(:error_no_default_issue_status)
142 return
142 return
143 end
143 end
144 @issue.status = default_status
144 @issue.status = default_status
145 @allowed_statuses = ([default_status] + default_status.find_new_statuses_allowed_to(User.current.roles_for_project(@project), @issue.tracker)).uniq
145 @allowed_statuses = ([default_status] + default_status.find_new_statuses_allowed_to(User.current.roles_for_project(@project), @issue.tracker)).uniq
146
146
147 if request.get? || request.xhr?
147 if request.get? || request.xhr?
148 @issue.start_date ||= Date.today
148 @issue.start_date ||= Date.today
149 else
149 else
150 requested_status = IssueStatus.find_by_id(params[:issue][:status_id])
150 requested_status = IssueStatus.find_by_id(params[:issue][:status_id])
151 # Check that the user is allowed to apply the requested status
151 # Check that the user is allowed to apply the requested status
152 @issue.status = (@allowed_statuses.include? requested_status) ? requested_status : default_status
152 @issue.status = (@allowed_statuses.include? requested_status) ? requested_status : default_status
153 if @issue.save
153 if @issue.save
154 attach_files(@issue, params[:attachments])
154 attach_files(@issue, params[:attachments])
155 flash[:notice] = l(:notice_successful_create)
155 flash[:notice] = l(:notice_successful_create)
156 call_hook(:controller_issues_new_after_save, { :params => params, :issue => @issue})
156 call_hook(:controller_issues_new_after_save, { :params => params, :issue => @issue})
157 redirect_to(params[:continue] ? { :action => 'new', :tracker_id => @issue.tracker } :
157 redirect_to(params[:continue] ? { :action => 'new', :tracker_id => @issue.tracker } :
158 { :action => 'show', :id => @issue })
158 { :action => 'show', :id => @issue })
159 return
159 return
160 end
160 end
161 end
161 end
162 @priorities = IssuePriority.all
162 @priorities = IssuePriority.all
163 render :layout => !request.xhr?
163 render :layout => !request.xhr?
164 end
164 end
165
165
166 # Attributes that can be updated on workflow transition (without :edit permission)
166 # Attributes that can be updated on workflow transition (without :edit permission)
167 # TODO: make it configurable (at least per role)
167 # TODO: make it configurable (at least per role)
168 UPDATABLE_ATTRS_ON_TRANSITION = %w(status_id assigned_to_id fixed_version_id done_ratio) unless const_defined?(:UPDATABLE_ATTRS_ON_TRANSITION)
168 UPDATABLE_ATTRS_ON_TRANSITION = %w(status_id assigned_to_id fixed_version_id done_ratio) unless const_defined?(:UPDATABLE_ATTRS_ON_TRANSITION)
169
169
170 def edit
170 def edit
171 @allowed_statuses = @issue.new_statuses_allowed_to(User.current)
171 @allowed_statuses = @issue.new_statuses_allowed_to(User.current)
172 @priorities = IssuePriority.all
172 @priorities = IssuePriority.all
173 @edit_allowed = User.current.allowed_to?(:edit_issues, @project)
173 @edit_allowed = User.current.allowed_to?(:edit_issues, @project)
174 @time_entry = TimeEntry.new
174 @time_entry = TimeEntry.new
175
175
176 @notes = params[:notes]
176 @notes = params[:notes]
177 journal = @issue.init_journal(User.current, @notes)
177 journal = @issue.init_journal(User.current, @notes)
178 # User can change issue attributes only if he has :edit permission or if a workflow transition is allowed
178 # User can change issue attributes only if he has :edit permission or if a workflow transition is allowed
179 if (@edit_allowed || !@allowed_statuses.empty?) && params[:issue]
179 if (@edit_allowed || !@allowed_statuses.empty?) && params[:issue]
180 attrs = params[:issue].dup
180 attrs = params[:issue].dup
181 attrs.delete_if {|k,v| !UPDATABLE_ATTRS_ON_TRANSITION.include?(k) } unless @edit_allowed
181 attrs.delete_if {|k,v| !UPDATABLE_ATTRS_ON_TRANSITION.include?(k) } unless @edit_allowed
182 attrs.delete(:status_id) unless @allowed_statuses.detect {|s| s.id.to_s == attrs[:status_id].to_s}
182 attrs.delete(:status_id) unless @allowed_statuses.detect {|s| s.id.to_s == attrs[:status_id].to_s}
183 @issue.attributes = attrs
183 @issue.attributes = attrs
184 end
184 end
185
185
186 if request.post?
186 if request.post?
187 @time_entry = TimeEntry.new(:project => @project, :issue => @issue, :user => User.current, :spent_on => Date.today)
187 @time_entry = TimeEntry.new(:project => @project, :issue => @issue, :user => User.current, :spent_on => Date.today)
188 @time_entry.attributes = params[:time_entry]
188 @time_entry.attributes = params[:time_entry]
189 attachments = attach_files(@issue, params[:attachments])
189 attachments = attach_files(@issue, params[:attachments])
190 attachments.each {|a| journal.details << JournalDetail.new(:property => 'attachment', :prop_key => a.id, :value => a.filename)}
190 attachments.each {|a| journal.details << JournalDetail.new(:property => 'attachment', :prop_key => a.id, :value => a.filename)}
191
191
192 call_hook(:controller_issues_edit_before_save, { :params => params, :issue => @issue, :time_entry => @time_entry, :journal => journal})
192 call_hook(:controller_issues_edit_before_save, { :params => params, :issue => @issue, :time_entry => @time_entry, :journal => journal})
193
193
194 if (@time_entry.hours.nil? || @time_entry.valid?) && @issue.save
194 if (@time_entry.hours.nil? || @time_entry.valid?) && @issue.save
195 # Log spend time
195 # Log spend time
196 if User.current.allowed_to?(:log_time, @project)
196 if User.current.allowed_to?(:log_time, @project)
197 @time_entry.save
197 @time_entry.save
198 end
198 end
199 if !journal.new_record?
199 if !journal.new_record?
200 # Only send notification if something was actually changed
200 # Only send notification if something was actually changed
201 flash[:notice] = l(:notice_successful_update)
201 flash[:notice] = l(:notice_successful_update)
202 end
202 end
203 call_hook(:controller_issues_edit_after_save, { :params => params, :issue => @issue, :time_entry => @time_entry, :journal => journal})
203 call_hook(:controller_issues_edit_after_save, { :params => params, :issue => @issue, :time_entry => @time_entry, :journal => journal})
204 redirect_to(params[:back_to] || {:action => 'show', :id => @issue})
204 redirect_to(params[:back_to] || {:action => 'show', :id => @issue})
205 end
205 end
206 end
206 end
207 rescue ActiveRecord::StaleObjectError
207 rescue ActiveRecord::StaleObjectError
208 # Optimistic locking exception
208 # Optimistic locking exception
209 flash.now[:error] = l(:notice_locking_conflict)
209 flash.now[:error] = l(:notice_locking_conflict)
210 # Remove the previously added attachments if issue was not updated
210 # Remove the previously added attachments if issue was not updated
211 attachments.each(&:destroy)
211 attachments.each(&:destroy)
212 end
212 end
213
213
214 def reply
214 def reply
215 journal = Journal.find(params[:journal_id]) if params[:journal_id]
215 journal = Journal.find(params[:journal_id]) if params[:journal_id]
216 if journal
216 if journal
217 user = journal.user
217 user = journal.user
218 text = journal.notes
218 text = journal.notes
219 else
219 else
220 user = @issue.author
220 user = @issue.author
221 text = @issue.description
221 text = @issue.description
222 end
222 end
223 content = "#{ll(Setting.default_language, :text_user_wrote, user)}\\n> "
223 content = "#{ll(Setting.default_language, :text_user_wrote, user)}\\n> "
224 content << text.to_s.strip.gsub(%r{<pre>((.|\s)*?)</pre>}m, '[...]').gsub('"', '\"').gsub(/(\r?\n|\r\n?)/, "\\n> ") + "\\n\\n"
224 content << text.to_s.strip.gsub(%r{<pre>((.|\s)*?)</pre>}m, '[...]').gsub('"', '\"').gsub(/(\r?\n|\r\n?)/, "\\n> ") + "\\n\\n"
225 render(:update) { |page|
225 render(:update) { |page|
226 page.<< "$('notes').value = \"#{content}\";"
226 page.<< "$('notes').value = \"#{content}\";"
227 page.show 'update'
227 page.show 'update'
228 page << "Form.Element.focus('notes');"
228 page << "Form.Element.focus('notes');"
229 page << "Element.scrollTo('update');"
229 page << "Element.scrollTo('update');"
230 page << "$('notes').scrollTop = $('notes').scrollHeight - $('notes').clientHeight;"
230 page << "$('notes').scrollTop = $('notes').scrollHeight - $('notes').clientHeight;"
231 }
231 }
232 end
232 end
233
233
234 # Bulk edit a set of issues
234 # Bulk edit a set of issues
235 def bulk_edit
235 def bulk_edit
236 if request.post?
236 if request.post?
237 tracker = params[:tracker_id].blank? ? nil : @project.trackers.find_by_id(params[:tracker_id])
237 status = params[:status_id].blank? ? nil : IssueStatus.find_by_id(params[:status_id])
238 status = params[:status_id].blank? ? nil : IssueStatus.find_by_id(params[:status_id])
238 priority = params[:priority_id].blank? ? nil : IssuePriority.find_by_id(params[:priority_id])
239 priority = params[:priority_id].blank? ? nil : IssuePriority.find_by_id(params[:priority_id])
239 assigned_to = (params[:assigned_to_id].blank? || params[:assigned_to_id] == 'none') ? nil : User.find_by_id(params[:assigned_to_id])
240 assigned_to = (params[:assigned_to_id].blank? || params[:assigned_to_id] == 'none') ? nil : User.find_by_id(params[:assigned_to_id])
240 category = (params[:category_id].blank? || params[:category_id] == 'none') ? nil : @project.issue_categories.find_by_id(params[:category_id])
241 category = (params[:category_id].blank? || params[:category_id] == 'none') ? nil : @project.issue_categories.find_by_id(params[:category_id])
241 fixed_version = (params[:fixed_version_id].blank? || params[:fixed_version_id] == 'none') ? nil : @project.versions.find_by_id(params[:fixed_version_id])
242 fixed_version = (params[:fixed_version_id].blank? || params[:fixed_version_id] == 'none') ? nil : @project.versions.find_by_id(params[:fixed_version_id])
242 custom_field_values = params[:custom_field_values] ? params[:custom_field_values].reject {|k,v| v.blank?} : nil
243 custom_field_values = params[:custom_field_values] ? params[:custom_field_values].reject {|k,v| v.blank?} : nil
243
244
244 unsaved_issue_ids = []
245 unsaved_issue_ids = []
245 @issues.each do |issue|
246 @issues.each do |issue|
246 journal = issue.init_journal(User.current, params[:notes])
247 journal = issue.init_journal(User.current, params[:notes])
248 issue.tracker = tracker if tracker
247 issue.priority = priority if priority
249 issue.priority = priority if priority
248 issue.assigned_to = assigned_to if assigned_to || params[:assigned_to_id] == 'none'
250 issue.assigned_to = assigned_to if assigned_to || params[:assigned_to_id] == 'none'
249 issue.category = category if category || params[:category_id] == 'none'
251 issue.category = category if category || params[:category_id] == 'none'
250 issue.fixed_version = fixed_version if fixed_version || params[:fixed_version_id] == 'none'
252 issue.fixed_version = fixed_version if fixed_version || params[:fixed_version_id] == 'none'
251 issue.start_date = params[:start_date] unless params[:start_date].blank?
253 issue.start_date = params[:start_date] unless params[:start_date].blank?
252 issue.due_date = params[:due_date] unless params[:due_date].blank?
254 issue.due_date = params[:due_date] unless params[:due_date].blank?
253 issue.done_ratio = params[:done_ratio] unless params[:done_ratio].blank?
255 issue.done_ratio = params[:done_ratio] unless params[:done_ratio].blank?
254 issue.custom_field_values = custom_field_values if custom_field_values && !custom_field_values.empty?
256 issue.custom_field_values = custom_field_values if custom_field_values && !custom_field_values.empty?
255 call_hook(:controller_issues_bulk_edit_before_save, { :params => params, :issue => issue })
257 call_hook(:controller_issues_bulk_edit_before_save, { :params => params, :issue => issue })
256 # Don't save any change to the issue if the user is not authorized to apply the requested status
258 # Don't save any change to the issue if the user is not authorized to apply the requested status
257 unless (status.nil? || (issue.new_statuses_allowed_to(User.current).include?(status) && issue.status = status)) && issue.save
259 unless (status.nil? || (issue.new_statuses_allowed_to(User.current).include?(status) && issue.status = status)) && issue.save
258 # Keep unsaved issue ids to display them in flash error
260 # Keep unsaved issue ids to display them in flash error
259 unsaved_issue_ids << issue.id
261 unsaved_issue_ids << issue.id
260 end
262 end
261 end
263 end
262 if unsaved_issue_ids.empty?
264 if unsaved_issue_ids.empty?
263 flash[:notice] = l(:notice_successful_update) unless @issues.empty?
265 flash[:notice] = l(:notice_successful_update) unless @issues.empty?
264 else
266 else
265 flash[:error] = l(:notice_failed_to_save_issues, :count => unsaved_issue_ids.size,
267 flash[:error] = l(:notice_failed_to_save_issues, :count => unsaved_issue_ids.size,
266 :total => @issues.size,
268 :total => @issues.size,
267 :ids => '#' + unsaved_issue_ids.join(', #'))
269 :ids => '#' + unsaved_issue_ids.join(', #'))
268 end
270 end
269 redirect_to(params[:back_to] || {:controller => 'issues', :action => 'index', :project_id => @project})
271 redirect_to(params[:back_to] || {:controller => 'issues', :action => 'index', :project_id => @project})
270 return
272 return
271 end
273 end
272 # Find potential statuses the user could be allowed to switch issues to
274 # Find potential statuses the user could be allowed to switch issues to
273 @available_statuses = Workflow.find(:all, :include => :new_status,
275 @available_statuses = Workflow.find(:all, :include => :new_status,
274 :conditions => {:role_id => User.current.roles_for_project(@project).collect(&:id)}).collect(&:new_status).compact.uniq.sort
276 :conditions => {:role_id => User.current.roles_for_project(@project).collect(&:id)}).collect(&:new_status).compact.uniq.sort
275 @custom_fields = @project.issue_custom_fields.select {|f| f.field_format == 'list'}
277 @custom_fields = @project.issue_custom_fields.select {|f| f.field_format == 'list'}
276 end
278 end
277
279
278 def move
280 def move
279 @allowed_projects = []
281 @allowed_projects = []
280 # find projects to which the user is allowed to move the issue
282 # find projects to which the user is allowed to move the issue
281 if User.current.admin?
283 if User.current.admin?
282 # admin is allowed to move issues to any active (visible) project
284 # admin is allowed to move issues to any active (visible) project
283 @allowed_projects = Project.find(:all, :conditions => Project.visible_by(User.current))
285 @allowed_projects = Project.find(:all, :conditions => Project.visible_by(User.current))
284 else
286 else
285 User.current.memberships.each {|m| @allowed_projects << m.project if m.roles.detect {|r| r.allowed_to?(:move_issues)}}
287 User.current.memberships.each {|m| @allowed_projects << m.project if m.roles.detect {|r| r.allowed_to?(:move_issues)}}
286 end
288 end
287 @target_project = @allowed_projects.detect {|p| p.id.to_s == params[:new_project_id]} if params[:new_project_id]
289 @target_project = @allowed_projects.detect {|p| p.id.to_s == params[:new_project_id]} if params[:new_project_id]
288 @target_project ||= @project
290 @target_project ||= @project
289 @trackers = @target_project.trackers
291 @trackers = @target_project.trackers
290 if request.post?
292 if request.post?
291 new_tracker = params[:new_tracker_id].blank? ? nil : @target_project.trackers.find_by_id(params[:new_tracker_id])
293 new_tracker = params[:new_tracker_id].blank? ? nil : @target_project.trackers.find_by_id(params[:new_tracker_id])
292 unsaved_issue_ids = []
294 unsaved_issue_ids = []
293 moved_issues = []
295 moved_issues = []
294 @issues.each do |issue|
296 @issues.each do |issue|
295 issue.init_journal(User.current)
297 issue.init_journal(User.current)
296 if r = issue.move_to(@target_project, new_tracker, params[:copy_options])
298 if r = issue.move_to(@target_project, new_tracker, params[:copy_options])
297 moved_issues << r
299 moved_issues << r
298 else
300 else
299 unsaved_issue_ids << issue.id
301 unsaved_issue_ids << issue.id
300 end
302 end
301 end
303 end
302 if unsaved_issue_ids.empty?
304 if unsaved_issue_ids.empty?
303 flash[:notice] = l(:notice_successful_update) unless @issues.empty?
305 flash[:notice] = l(:notice_successful_update) unless @issues.empty?
304 else
306 else
305 flash[:error] = l(:notice_failed_to_save_issues, :count => unsaved_issue_ids.size,
307 flash[:error] = l(:notice_failed_to_save_issues, :count => unsaved_issue_ids.size,
306 :total => @issues.size,
308 :total => @issues.size,
307 :ids => '#' + unsaved_issue_ids.join(', #'))
309 :ids => '#' + unsaved_issue_ids.join(', #'))
308 end
310 end
309 if params[:follow]
311 if params[:follow]
310 if @issues.size == 1 && moved_issues.size == 1
312 if @issues.size == 1 && moved_issues.size == 1
311 redirect_to :controller => 'issues', :action => 'show', :id => moved_issues.first
313 redirect_to :controller => 'issues', :action => 'show', :id => moved_issues.first
312 else
314 else
313 redirect_to :controller => 'issues', :action => 'index', :project_id => (@target_project || @project)
315 redirect_to :controller => 'issues', :action => 'index', :project_id => (@target_project || @project)
314 end
316 end
315 else
317 else
316 redirect_to :controller => 'issues', :action => 'index', :project_id => @project
318 redirect_to :controller => 'issues', :action => 'index', :project_id => @project
317 end
319 end
318 return
320 return
319 end
321 end
320 render :layout => false if request.xhr?
322 render :layout => false if request.xhr?
321 end
323 end
322
324
323 def destroy
325 def destroy
324 @hours = TimeEntry.sum(:hours, :conditions => ['issue_id IN (?)', @issues]).to_f
326 @hours = TimeEntry.sum(:hours, :conditions => ['issue_id IN (?)', @issues]).to_f
325 if @hours > 0
327 if @hours > 0
326 case params[:todo]
328 case params[:todo]
327 when 'destroy'
329 when 'destroy'
328 # nothing to do
330 # nothing to do
329 when 'nullify'
331 when 'nullify'
330 TimeEntry.update_all('issue_id = NULL', ['issue_id IN (?)', @issues])
332 TimeEntry.update_all('issue_id = NULL', ['issue_id IN (?)', @issues])
331 when 'reassign'
333 when 'reassign'
332 reassign_to = @project.issues.find_by_id(params[:reassign_to_id])
334 reassign_to = @project.issues.find_by_id(params[:reassign_to_id])
333 if reassign_to.nil?
335 if reassign_to.nil?
334 flash.now[:error] = l(:error_issue_not_found_in_project)
336 flash.now[:error] = l(:error_issue_not_found_in_project)
335 return
337 return
336 else
338 else
337 TimeEntry.update_all("issue_id = #{reassign_to.id}", ['issue_id IN (?)', @issues])
339 TimeEntry.update_all("issue_id = #{reassign_to.id}", ['issue_id IN (?)', @issues])
338 end
340 end
339 else
341 else
340 # display the destroy form
342 # display the destroy form
341 return
343 return
342 end
344 end
343 end
345 end
344 @issues.each(&:destroy)
346 @issues.each(&:destroy)
345 redirect_to :action => 'index', :project_id => @project
347 redirect_to :action => 'index', :project_id => @project
346 end
348 end
347
349
348 def gantt
350 def gantt
349 @gantt = Redmine::Helpers::Gantt.new(params)
351 @gantt = Redmine::Helpers::Gantt.new(params)
350 retrieve_query
352 retrieve_query
351 if @query.valid?
353 if @query.valid?
352 events = []
354 events = []
353 # Issues that have start and due dates
355 # Issues that have start and due dates
354 events += @query.issues(:include => [:tracker, :assigned_to, :priority],
356 events += @query.issues(:include => [:tracker, :assigned_to, :priority],
355 :order => "start_date, due_date",
357 :order => "start_date, due_date",
356 :conditions => ["(((start_date>=? and start_date<=?) or (due_date>=? and due_date<=?) or (start_date<? and due_date>?)) and start_date is not null and due_date is not null)", @gantt.date_from, @gantt.date_to, @gantt.date_from, @gantt.date_to, @gantt.date_from, @gantt.date_to]
358 :conditions => ["(((start_date>=? and start_date<=?) or (due_date>=? and due_date<=?) or (start_date<? and due_date>?)) and start_date is not null and due_date is not null)", @gantt.date_from, @gantt.date_to, @gantt.date_from, @gantt.date_to, @gantt.date_from, @gantt.date_to]
357 )
359 )
358 # Issues that don't have a due date but that are assigned to a version with a date
360 # Issues that don't have a due date but that are assigned to a version with a date
359 events += @query.issues(:include => [:tracker, :assigned_to, :priority, :fixed_version],
361 events += @query.issues(:include => [:tracker, :assigned_to, :priority, :fixed_version],
360 :order => "start_date, effective_date",
362 :order => "start_date, effective_date",
361 :conditions => ["(((start_date>=? and start_date<=?) or (effective_date>=? and effective_date<=?) or (start_date<? and effective_date>?)) and start_date is not null and due_date is null and effective_date is not null)", @gantt.date_from, @gantt.date_to, @gantt.date_from, @gantt.date_to, @gantt.date_from, @gantt.date_to]
363 :conditions => ["(((start_date>=? and start_date<=?) or (effective_date>=? and effective_date<=?) or (start_date<? and effective_date>?)) and start_date is not null and due_date is null and effective_date is not null)", @gantt.date_from, @gantt.date_to, @gantt.date_from, @gantt.date_to, @gantt.date_from, @gantt.date_to]
362 )
364 )
363 # Versions
365 # Versions
364 events += @query.versions(:conditions => ["effective_date BETWEEN ? AND ?", @gantt.date_from, @gantt.date_to])
366 events += @query.versions(:conditions => ["effective_date BETWEEN ? AND ?", @gantt.date_from, @gantt.date_to])
365
367
366 @gantt.events = events
368 @gantt.events = events
367 end
369 end
368
370
369 basename = (@project ? "#{@project.identifier}-" : '') + 'gantt'
371 basename = (@project ? "#{@project.identifier}-" : '') + 'gantt'
370
372
371 respond_to do |format|
373 respond_to do |format|
372 format.html { render :template => "issues/gantt.rhtml", :layout => !request.xhr? }
374 format.html { render :template => "issues/gantt.rhtml", :layout => !request.xhr? }
373 format.png { send_data(@gantt.to_image, :disposition => 'inline', :type => 'image/png', :filename => "#{basename}.png") } if @gantt.respond_to?('to_image')
375 format.png { send_data(@gantt.to_image, :disposition => 'inline', :type => 'image/png', :filename => "#{basename}.png") } if @gantt.respond_to?('to_image')
374 format.pdf { send_data(gantt_to_pdf(@gantt, @project), :type => 'application/pdf', :filename => "#{basename}.pdf") }
376 format.pdf { send_data(gantt_to_pdf(@gantt, @project), :type => 'application/pdf', :filename => "#{basename}.pdf") }
375 end
377 end
376 end
378 end
377
379
378 def calendar
380 def calendar
379 if params[:year] and params[:year].to_i > 1900
381 if params[:year] and params[:year].to_i > 1900
380 @year = params[:year].to_i
382 @year = params[:year].to_i
381 if params[:month] and params[:month].to_i > 0 and params[:month].to_i < 13
383 if params[:month] and params[:month].to_i > 0 and params[:month].to_i < 13
382 @month = params[:month].to_i
384 @month = params[:month].to_i
383 end
385 end
384 end
386 end
385 @year ||= Date.today.year
387 @year ||= Date.today.year
386 @month ||= Date.today.month
388 @month ||= Date.today.month
387
389
388 @calendar = Redmine::Helpers::Calendar.new(Date.civil(@year, @month, 1), current_language, :month)
390 @calendar = Redmine::Helpers::Calendar.new(Date.civil(@year, @month, 1), current_language, :month)
389 retrieve_query
391 retrieve_query
390 if @query.valid?
392 if @query.valid?
391 events = []
393 events = []
392 events += @query.issues(:include => [:tracker, :assigned_to, :priority],
394 events += @query.issues(:include => [:tracker, :assigned_to, :priority],
393 :conditions => ["((start_date BETWEEN ? AND ?) OR (due_date BETWEEN ? AND ?))", @calendar.startdt, @calendar.enddt, @calendar.startdt, @calendar.enddt]
395 :conditions => ["((start_date BETWEEN ? AND ?) OR (due_date BETWEEN ? AND ?))", @calendar.startdt, @calendar.enddt, @calendar.startdt, @calendar.enddt]
394 )
396 )
395 events += @query.versions(:conditions => ["effective_date BETWEEN ? AND ?", @calendar.startdt, @calendar.enddt])
397 events += @query.versions(:conditions => ["effective_date BETWEEN ? AND ?", @calendar.startdt, @calendar.enddt])
396
398
397 @calendar.events = events
399 @calendar.events = events
398 end
400 end
399
401
400 render :layout => false if request.xhr?
402 render :layout => false if request.xhr?
401 end
403 end
402
404
403 def context_menu
405 def context_menu
404 @issues = Issue.find_all_by_id(params[:ids], :include => :project)
406 @issues = Issue.find_all_by_id(params[:ids], :include => :project)
405 if (@issues.size == 1)
407 if (@issues.size == 1)
406 @issue = @issues.first
408 @issue = @issues.first
407 @allowed_statuses = @issue.new_statuses_allowed_to(User.current)
409 @allowed_statuses = @issue.new_statuses_allowed_to(User.current)
408 end
410 end
409 projects = @issues.collect(&:project).compact.uniq
411 projects = @issues.collect(&:project).compact.uniq
410 @project = projects.first if projects.size == 1
412 @project = projects.first if projects.size == 1
411
413
412 @can = {:edit => (@project && User.current.allowed_to?(:edit_issues, @project)),
414 @can = {:edit => (@project && User.current.allowed_to?(:edit_issues, @project)),
413 :log_time => (@project && User.current.allowed_to?(:log_time, @project)),
415 :log_time => (@project && User.current.allowed_to?(:log_time, @project)),
414 :update => (@project && (User.current.allowed_to?(:edit_issues, @project) || (User.current.allowed_to?(:change_status, @project) && @allowed_statuses && !@allowed_statuses.empty?))),
416 :update => (@project && (User.current.allowed_to?(:edit_issues, @project) || (User.current.allowed_to?(:change_status, @project) && @allowed_statuses && !@allowed_statuses.empty?))),
415 :move => (@project && User.current.allowed_to?(:move_issues, @project)),
417 :move => (@project && User.current.allowed_to?(:move_issues, @project)),
416 :copy => (@issue && @project.trackers.include?(@issue.tracker) && User.current.allowed_to?(:add_issues, @project)),
418 :copy => (@issue && @project.trackers.include?(@issue.tracker) && User.current.allowed_to?(:add_issues, @project)),
417 :delete => (@project && User.current.allowed_to?(:delete_issues, @project))
419 :delete => (@project && User.current.allowed_to?(:delete_issues, @project))
418 }
420 }
419 if @project
421 if @project
420 @assignables = @project.assignable_users
422 @assignables = @project.assignable_users
421 @assignables << @issue.assigned_to if @issue && @issue.assigned_to && !@assignables.include?(@issue.assigned_to)
423 @assignables << @issue.assigned_to if @issue && @issue.assigned_to && !@assignables.include?(@issue.assigned_to)
422 end
424 end
423
425
426 @trackers = @project.trackers
424 @priorities = IssuePriority.all.reverse
427 @priorities = IssuePriority.all.reverse
425 @statuses = IssueStatus.find(:all, :order => 'position')
428 @statuses = IssueStatus.find(:all, :order => 'position')
426 @back = params[:back_url] || request.env['HTTP_REFERER']
429 @back = params[:back_url] || request.env['HTTP_REFERER']
427
430
428 render :layout => false
431 render :layout => false
429 end
432 end
430
433
431 def update_form
434 def update_form
432 if params[:id]
435 if params[:id]
433 @issue = @project.issues.visible.find(params[:id])
436 @issue = @project.issues.visible.find(params[:id])
434 else
437 else
435 @issue = Issue.new
438 @issue = Issue.new
436 @issue.project = @project
439 @issue.project = @project
437 end
440 end
438 @issue.attributes = params[:issue]
441 @issue.attributes = params[:issue]
439 @allowed_statuses = ([@issue.status] + @issue.status.find_new_statuses_allowed_to(User.current.roles_for_project(@project), @issue.tracker)).uniq
442 @allowed_statuses = ([@issue.status] + @issue.status.find_new_statuses_allowed_to(User.current.roles_for_project(@project), @issue.tracker)).uniq
440 @priorities = IssuePriority.all
443 @priorities = IssuePriority.all
441
444
442 render :partial => 'attributes'
445 render :partial => 'attributes'
443 end
446 end
444
447
445 def preview
448 def preview
446 @issue = @project.issues.find_by_id(params[:id]) unless params[:id].blank?
449 @issue = @project.issues.find_by_id(params[:id]) unless params[:id].blank?
447 @attachements = @issue.attachments if @issue
450 @attachements = @issue.attachments if @issue
448 @text = params[:notes] || (params[:issue] ? params[:issue][:description] : nil)
451 @text = params[:notes] || (params[:issue] ? params[:issue][:description] : nil)
449 render :partial => 'common/preview'
452 render :partial => 'common/preview'
450 end
453 end
451
454
452 private
455 private
453 def find_issue
456 def find_issue
454 @issue = Issue.find(params[:id], :include => [:project, :tracker, :status, :author, :priority, :category])
457 @issue = Issue.find(params[:id], :include => [:project, :tracker, :status, :author, :priority, :category])
455 @project = @issue.project
458 @project = @issue.project
456 rescue ActiveRecord::RecordNotFound
459 rescue ActiveRecord::RecordNotFound
457 render_404
460 render_404
458 end
461 end
459
462
460 # Filter for bulk operations
463 # Filter for bulk operations
461 def find_issues
464 def find_issues
462 @issues = Issue.find_all_by_id(params[:id] || params[:ids])
465 @issues = Issue.find_all_by_id(params[:id] || params[:ids])
463 raise ActiveRecord::RecordNotFound if @issues.empty?
466 raise ActiveRecord::RecordNotFound if @issues.empty?
464 projects = @issues.collect(&:project).compact.uniq
467 projects = @issues.collect(&:project).compact.uniq
465 if projects.size == 1
468 if projects.size == 1
466 @project = projects.first
469 @project = projects.first
467 else
470 else
468 # TODO: let users bulk edit/move/destroy issues from different projects
471 # TODO: let users bulk edit/move/destroy issues from different projects
469 render_error 'Can not bulk edit/move/destroy issues from different projects' and return false
472 render_error 'Can not bulk edit/move/destroy issues from different projects' and return false
470 end
473 end
471 rescue ActiveRecord::RecordNotFound
474 rescue ActiveRecord::RecordNotFound
472 render_404
475 render_404
473 end
476 end
474
477
475 def find_project
478 def find_project
476 @project = Project.find(params[:project_id])
479 @project = Project.find(params[:project_id])
477 rescue ActiveRecord::RecordNotFound
480 rescue ActiveRecord::RecordNotFound
478 render_404
481 render_404
479 end
482 end
480
483
481 def find_optional_project
484 def find_optional_project
482 @project = Project.find(params[:project_id]) unless params[:project_id].blank?
485 @project = Project.find(params[:project_id]) unless params[:project_id].blank?
483 allowed = User.current.allowed_to?({:controller => params[:controller], :action => params[:action]}, @project, :global => true)
486 allowed = User.current.allowed_to?({:controller => params[:controller], :action => params[:action]}, @project, :global => true)
484 allowed ? true : deny_access
487 allowed ? true : deny_access
485 rescue ActiveRecord::RecordNotFound
488 rescue ActiveRecord::RecordNotFound
486 render_404
489 render_404
487 end
490 end
488
491
489 # Retrieve query from session or build a new query
492 # Retrieve query from session or build a new query
490 def retrieve_query
493 def retrieve_query
491 if !params[:query_id].blank?
494 if !params[:query_id].blank?
492 cond = "project_id IS NULL"
495 cond = "project_id IS NULL"
493 cond << " OR project_id = #{@project.id}" if @project
496 cond << " OR project_id = #{@project.id}" if @project
494 @query = Query.find(params[:query_id], :conditions => cond)
497 @query = Query.find(params[:query_id], :conditions => cond)
495 @query.project = @project
498 @query.project = @project
496 session[:query] = {:id => @query.id, :project_id => @query.project_id}
499 session[:query] = {:id => @query.id, :project_id => @query.project_id}
497 sort_clear
500 sort_clear
498 else
501 else
499 if params[:set_filter] || session[:query].nil? || session[:query][:project_id] != (@project ? @project.id : nil)
502 if params[:set_filter] || session[:query].nil? || session[:query][:project_id] != (@project ? @project.id : nil)
500 # Give it a name, required to be valid
503 # Give it a name, required to be valid
501 @query = Query.new(:name => "_")
504 @query = Query.new(:name => "_")
502 @query.project = @project
505 @query.project = @project
503 if params[:fields] and params[:fields].is_a? Array
506 if params[:fields] and params[:fields].is_a? Array
504 params[:fields].each do |field|
507 params[:fields].each do |field|
505 @query.add_filter(field, params[:operators][field], params[:values][field])
508 @query.add_filter(field, params[:operators][field], params[:values][field])
506 end
509 end
507 else
510 else
508 @query.available_filters.keys.each do |field|
511 @query.available_filters.keys.each do |field|
509 @query.add_short_filter(field, params[field]) if params[field]
512 @query.add_short_filter(field, params[field]) if params[field]
510 end
513 end
511 end
514 end
512 @query.group_by = params[:group_by]
515 @query.group_by = params[:group_by]
513 @query.column_names = params[:query] && params[:query][:column_names]
516 @query.column_names = params[:query] && params[:query][:column_names]
514 session[:query] = {:project_id => @query.project_id, :filters => @query.filters, :group_by => @query.group_by, :column_names => @query.column_names}
517 session[:query] = {:project_id => @query.project_id, :filters => @query.filters, :group_by => @query.group_by, :column_names => @query.column_names}
515 else
518 else
516 @query = Query.find_by_id(session[:query][:id]) if session[:query][:id]
519 @query = Query.find_by_id(session[:query][:id]) if session[:query][:id]
517 @query ||= Query.new(:name => "_", :project => @project, :filters => session[:query][:filters], :group_by => session[:query][:group_by], :column_names => session[:query][:column_names])
520 @query ||= Query.new(:name => "_", :project => @project, :filters => session[:query][:filters], :group_by => session[:query][:group_by], :column_names => session[:query][:column_names])
518 @query.project = @project
521 @query.project = @project
519 end
522 end
520 end
523 end
521 end
524 end
522
525
523 # Rescues an invalid query statement. Just in case...
526 # Rescues an invalid query statement. Just in case...
524 def query_statement_invalid(exception)
527 def query_statement_invalid(exception)
525 logger.error "Query::StatementInvalid: #{exception.message}" if logger
528 logger.error "Query::StatementInvalid: #{exception.message}" if logger
526 session.delete(:query)
529 session.delete(:query)
527 sort_clear
530 sort_clear
528 render_error "An error occurred while executing the query and has been logged. Please report this error to your Redmine administrator."
531 render_error "An error occurred while executing the query and has been logged. Please report this error to your Redmine administrator."
529 end
532 end
530 end
533 end
@@ -1,58 +1,62
1 <h2><%= l(:label_bulk_edit_selected_issues) %></h2>
1 <h2><%= l(:label_bulk_edit_selected_issues) %></h2>
2
2
3 <ul><%= @issues.collect {|i| content_tag('li', link_to(h("#{i.tracker} ##{i.id}"), { :action => 'show', :id => i }) + h(": #{i.subject}")) }.join("\n") %></ul>
3 <ul><%= @issues.collect {|i| content_tag('li', link_to(h("#{i.tracker} ##{i.id}"), { :action => 'show', :id => i }) + h(": #{i.subject}")) }.join("\n") %></ul>
4
4
5 <% form_tag() do %>
5 <% form_tag() do %>
6 <%= @issues.collect {|i| hidden_field_tag('ids[]', i.id)}.join %>
6 <%= @issues.collect {|i| hidden_field_tag('ids[]', i.id)}.join %>
7 <div class="box">
7 <div class="box">
8 <fieldset>
8 <fieldset>
9 <legend><%= l(:label_change_properties) %></legend>
9 <legend><%= l(:label_change_properties) %></legend>
10 <p>
10 <p>
11 <label><%= l(:field_tracker) %>:
12 <%= select_tag('tracker_id', "<option value=\"\">#{l(:label_no_change_option)}</option>" + options_from_collection_for_select(@project.trackers, :id, :name)) %></label>
11 <% if @available_statuses.any? %>
13 <% if @available_statuses.any? %>
12 <label><%= l(:field_status) %>:
14 <label><%= l(:field_status) %>:
13 <%= select_tag('status_id', "<option value=\"\">#{l(:label_no_change_option)}</option>" + options_from_collection_for_select(@available_statuses, :id, :name)) %></label>
15 <%= select_tag('status_id', "<option value=\"\">#{l(:label_no_change_option)}</option>" + options_from_collection_for_select(@available_statuses, :id, :name)) %></label>
14 <% end %>
16 <% end %>
17 </p>
18 <p>
15 <label><%= l(:field_priority) %>:
19 <label><%= l(:field_priority) %>:
16 <%= select_tag('priority_id', "<option value=\"\">#{l(:label_no_change_option)}</option>" + options_from_collection_for_select(IssuePriority.all, :id, :name)) %></label>
20 <%= select_tag('priority_id', "<option value=\"\">#{l(:label_no_change_option)}</option>" + options_from_collection_for_select(IssuePriority.all, :id, :name)) %></label>
17 <label><%= l(:field_category) %>:
21 <label><%= l(:field_category) %>:
18 <%= select_tag('category_id', content_tag('option', l(:label_no_change_option), :value => '') +
22 <%= select_tag('category_id', content_tag('option', l(:label_no_change_option), :value => '') +
19 content_tag('option', l(:label_none), :value => 'none') +
23 content_tag('option', l(:label_none), :value => 'none') +
20 options_from_collection_for_select(@project.issue_categories, :id, :name)) %></label>
24 options_from_collection_for_select(@project.issue_categories, :id, :name)) %></label>
21 </p>
25 </p>
22 <p>
26 <p>
23 <label><%= l(:field_assigned_to) %>:
27 <label><%= l(:field_assigned_to) %>:
24 <%= select_tag('assigned_to_id', content_tag('option', l(:label_no_change_option), :value => '') +
28 <%= select_tag('assigned_to_id', content_tag('option', l(:label_no_change_option), :value => '') +
25 content_tag('option', l(:label_nobody), :value => 'none') +
29 content_tag('option', l(:label_nobody), :value => 'none') +
26 options_from_collection_for_select(@project.assignable_users, :id, :name)) %></label>
30 options_from_collection_for_select(@project.assignable_users, :id, :name)) %></label>
27 <label><%= l(:field_fixed_version) %>:
31 <label><%= l(:field_fixed_version) %>:
28 <%= select_tag('fixed_version_id', content_tag('option', l(:label_no_change_option), :value => '') +
32 <%= select_tag('fixed_version_id', content_tag('option', l(:label_no_change_option), :value => '') +
29 content_tag('option', l(:label_none), :value => 'none') +
33 content_tag('option', l(:label_none), :value => 'none') +
30 options_from_collection_for_select(@project.versions.open.sort, :id, :name)) %></label>
34 options_from_collection_for_select(@project.versions.open.sort, :id, :name)) %></label>
31 </p>
35 </p>
32
36
33 <p>
37 <p>
34 <label><%= l(:field_start_date) %>:
38 <label><%= l(:field_start_date) %>:
35 <%= text_field_tag 'start_date', '', :size => 10 %><%= calendar_for('start_date') %></label>
39 <%= text_field_tag 'start_date', '', :size => 10 %><%= calendar_for('start_date') %></label>
36 <label><%= l(:field_due_date) %>:
40 <label><%= l(:field_due_date) %>:
37 <%= text_field_tag 'due_date', '', :size => 10 %><%= calendar_for('due_date') %></label>
41 <%= text_field_tag 'due_date', '', :size => 10 %><%= calendar_for('due_date') %></label>
38 <label><%= l(:field_done_ratio) %>:
42 <label><%= l(:field_done_ratio) %>:
39 <%= select_tag 'done_ratio', options_for_select([[l(:label_no_change_option), '']] + (0..10).to_a.collect {|r| ["#{r*10} %", r*10] }) %></label>
43 <%= select_tag 'done_ratio', options_for_select([[l(:label_no_change_option), '']] + (0..10).to_a.collect {|r| ["#{r*10} %", r*10] }) %></label>
40 </p>
44 </p>
41
45
42 <% @custom_fields.each do |custom_field| %>
46 <% @custom_fields.each do |custom_field| %>
43 <p><label><%= h(custom_field.name) %></label>
47 <p><label><%= h(custom_field.name) %></label>
44 <%= select_tag "custom_field_values[#{custom_field.id}]", options_for_select([[l(:label_no_change_option), '']] + custom_field.possible_values) %></label>
48 <%= select_tag "custom_field_values[#{custom_field.id}]", options_for_select([[l(:label_no_change_option), '']] + custom_field.possible_values) %></label>
45 </p>
49 </p>
46 <% end %>
50 <% end %>
47
51
48 <%= call_hook(:view_issues_bulk_edit_details_bottom, { :issues => @issues }) %>
52 <%= call_hook(:view_issues_bulk_edit_details_bottom, { :issues => @issues }) %>
49 </fieldset>
53 </fieldset>
50
54
51 <fieldset><legend><%= l(:field_notes) %></legend>
55 <fieldset><legend><%= l(:field_notes) %></legend>
52 <%= text_area_tag 'notes', @notes, :cols => 60, :rows => 10, :class => 'wiki-edit' %>
56 <%= text_area_tag 'notes', @notes, :cols => 60, :rows => 10, :class => 'wiki-edit' %>
53 <%= wikitoolbar_for 'notes' %>
57 <%= wikitoolbar_for 'notes' %>
54 </fieldset>
58 </fieldset>
55 </div>
59 </div>
56
60
57 <p><%= submit_tag l(:button_submit) %>
61 <p><%= submit_tag l(:button_submit) %>
58 <% end %>
62 <% end %>
@@ -1,97 +1,106
1 <ul>
1 <ul>
2 <%= call_hook(:view_issues_context_menu_start, {:issues => @issues, :can => @can, :back => @back }) %>
2 <%= call_hook(:view_issues_context_menu_start, {:issues => @issues, :can => @can, :back => @back }) %>
3
3
4 <% if !@issue.nil? -%>
4 <% if !@issue.nil? -%>
5 <li><%= context_menu_link l(:button_edit), {:controller => 'issues', :action => 'edit', :id => @issue},
5 <li><%= context_menu_link l(:button_edit), {:controller => 'issues', :action => 'edit', :id => @issue},
6 :class => 'icon-edit', :disabled => !@can[:edit] %></li>
6 :class => 'icon-edit', :disabled => !@can[:edit] %></li>
7 <li class="folder">
7 <li class="folder">
8 <a href="#" class="submenu" onclick="return false;"><%= l(:field_status) %></a>
8 <a href="#" class="submenu" onclick="return false;"><%= l(:field_status) %></a>
9 <ul>
9 <ul>
10 <% @statuses.each do |s| -%>
10 <% @statuses.each do |s| -%>
11 <li><%= context_menu_link s.name, {:controller => 'issues', :action => 'edit', :id => @issue, :issue => {:status_id => s}, :back_to => @back}, :method => :post,
11 <li><%= context_menu_link s.name, {:controller => 'issues', :action => 'edit', :id => @issue, :issue => {:status_id => s}, :back_to => @back}, :method => :post,
12 :selected => (s == @issue.status), :disabled => !(@can[:update] && @allowed_statuses.include?(s)) %></li>
12 :selected => (s == @issue.status), :disabled => !(@can[:update] && @allowed_statuses.include?(s)) %></li>
13 <% end -%>
13 <% end -%>
14 </ul>
14 </ul>
15 </li>
15 </li>
16 <% else %>
16 <% else %>
17 <li><%= context_menu_link l(:button_edit), {:controller => 'issues', :action => 'bulk_edit', :ids => @issues.collect(&:id)},
17 <li><%= context_menu_link l(:button_edit), {:controller => 'issues', :action => 'bulk_edit', :ids => @issues.collect(&:id)},
18 :class => 'icon-edit', :disabled => !@can[:edit] %></li>
18 :class => 'icon-edit', :disabled => !@can[:edit] %></li>
19 <% end %>
19 <% end %>
20
20
21 <li class="folder">
21 <li class="folder">
22 <a href="#" class="submenu"><%= l(:field_tracker) %></a>
23 <ul>
24 <% @trackers.each do |t| -%>
25 <li><%= context_menu_link t.name, {:controller => 'issues', :action => 'bulk_edit', :ids => @issues.collect(&:id), 'tracker_id' => t, :back_to => @back}, :method => :post,
26 :selected => (@issue && t == @issue.tracker), :disabled => !@can[:edit] %></li>
27 <% end -%>
28 </ul>
29 </li>
30 <li class="folder">
22 <a href="#" class="submenu"><%= l(:field_priority) %></a>
31 <a href="#" class="submenu"><%= l(:field_priority) %></a>
23 <ul>
32 <ul>
24 <% @priorities.each do |p| -%>
33 <% @priorities.each do |p| -%>
25 <li><%= context_menu_link p.name, {:controller => 'issues', :action => 'bulk_edit', :ids => @issues.collect(&:id), 'priority_id' => p, :back_to => @back}, :method => :post,
34 <li><%= context_menu_link p.name, {:controller => 'issues', :action => 'bulk_edit', :ids => @issues.collect(&:id), 'priority_id' => p, :back_to => @back}, :method => :post,
26 :selected => (@issue && p == @issue.priority), :disabled => !@can[:edit] %></li>
35 :selected => (@issue && p == @issue.priority), :disabled => !@can[:edit] %></li>
27 <% end -%>
36 <% end -%>
28 </ul>
37 </ul>
29 </li>
38 </li>
30 <% unless @project.nil? || @project.versions.open.empty? -%>
39 <% unless @project.nil? || @project.versions.open.empty? -%>
31 <li class="folder">
40 <li class="folder">
32 <a href="#" class="submenu"><%= l(:field_fixed_version) %></a>
41 <a href="#" class="submenu"><%= l(:field_fixed_version) %></a>
33 <ul>
42 <ul>
34 <% @project.versions.open.sort.each do |v| -%>
43 <% @project.versions.open.sort.each do |v| -%>
35 <li><%= context_menu_link v.name, {:controller => 'issues', :action => 'bulk_edit', :ids => @issues.collect(&:id), 'fixed_version_id' => v, :back_to => @back}, :method => :post,
44 <li><%= context_menu_link v.name, {:controller => 'issues', :action => 'bulk_edit', :ids => @issues.collect(&:id), 'fixed_version_id' => v, :back_to => @back}, :method => :post,
36 :selected => (@issue && v == @issue.fixed_version), :disabled => !@can[:update] %></li>
45 :selected => (@issue && v == @issue.fixed_version), :disabled => !@can[:update] %></li>
37 <% end -%>
46 <% end -%>
38 <li><%= context_menu_link l(:label_none), {:controller => 'issues', :action => 'bulk_edit', :ids => @issues.collect(&:id), 'fixed_version_id' => 'none', :back_to => @back}, :method => :post,
47 <li><%= context_menu_link l(:label_none), {:controller => 'issues', :action => 'bulk_edit', :ids => @issues.collect(&:id), 'fixed_version_id' => 'none', :back_to => @back}, :method => :post,
39 :selected => (@issue && @issue.fixed_version.nil?), :disabled => !@can[:update] %></li>
48 :selected => (@issue && @issue.fixed_version.nil?), :disabled => !@can[:update] %></li>
40 </ul>
49 </ul>
41 </li>
50 </li>
42 <% end %>
51 <% end %>
43 <% unless @assignables.nil? || @assignables.empty? -%>
52 <% unless @assignables.nil? || @assignables.empty? -%>
44 <li class="folder">
53 <li class="folder">
45 <a href="#" class="submenu"><%= l(:field_assigned_to) %></a>
54 <a href="#" class="submenu"><%= l(:field_assigned_to) %></a>
46 <ul>
55 <ul>
47 <% @assignables.each do |u| -%>
56 <% @assignables.each do |u| -%>
48 <li><%= context_menu_link u.name, {:controller => 'issues', :action => 'bulk_edit', :ids => @issues.collect(&:id), 'assigned_to_id' => u, :back_to => @back}, :method => :post,
57 <li><%= context_menu_link u.name, {:controller => 'issues', :action => 'bulk_edit', :ids => @issues.collect(&:id), 'assigned_to_id' => u, :back_to => @back}, :method => :post,
49 :selected => (@issue && u == @issue.assigned_to), :disabled => !@can[:update] %></li>
58 :selected => (@issue && u == @issue.assigned_to), :disabled => !@can[:update] %></li>
50 <% end -%>
59 <% end -%>
51 <li><%= context_menu_link l(:label_nobody), {:controller => 'issues', :action => 'bulk_edit', :ids => @issues.collect(&:id), 'assigned_to_id' => 'none', :back_to => @back}, :method => :post,
60 <li><%= context_menu_link l(:label_nobody), {:controller => 'issues', :action => 'bulk_edit', :ids => @issues.collect(&:id), 'assigned_to_id' => 'none', :back_to => @back}, :method => :post,
52 :selected => (@issue && @issue.assigned_to.nil?), :disabled => !@can[:update] %></li>
61 :selected => (@issue && @issue.assigned_to.nil?), :disabled => !@can[:update] %></li>
53 </ul>
62 </ul>
54 </li>
63 </li>
55 <% end %>
64 <% end %>
56 <% unless @project.nil? || @project.issue_categories.empty? -%>
65 <% unless @project.nil? || @project.issue_categories.empty? -%>
57 <li class="folder">
66 <li class="folder">
58 <a href="#" class="submenu"><%= l(:field_category) %></a>
67 <a href="#" class="submenu"><%= l(:field_category) %></a>
59 <ul>
68 <ul>
60 <% @project.issue_categories.each do |u| -%>
69 <% @project.issue_categories.each do |u| -%>
61 <li><%= context_menu_link u.name, {:controller => 'issues', :action => 'bulk_edit', :ids => @issues.collect(&:id), 'category_id' => u, :back_to => @back}, :method => :post,
70 <li><%= context_menu_link u.name, {:controller => 'issues', :action => 'bulk_edit', :ids => @issues.collect(&:id), 'category_id' => u, :back_to => @back}, :method => :post,
62 :selected => (@issue && u == @issue.category), :disabled => !@can[:update] %></li>
71 :selected => (@issue && u == @issue.category), :disabled => !@can[:update] %></li>
63 <% end -%>
72 <% end -%>
64 <li><%= context_menu_link l(:label_none), {:controller => 'issues', :action => 'bulk_edit', :ids => @issues.collect(&:id), 'category_id' => 'none', :back_to => @back}, :method => :post,
73 <li><%= context_menu_link l(:label_none), {:controller => 'issues', :action => 'bulk_edit', :ids => @issues.collect(&:id), 'category_id' => 'none', :back_to => @back}, :method => :post,
65 :selected => (@issue && @issue.category.nil?), :disabled => !@can[:update] %></li>
74 :selected => (@issue && @issue.category.nil?), :disabled => !@can[:update] %></li>
66 </ul>
75 </ul>
67 </li>
76 </li>
68 <% end -%>
77 <% end -%>
69 <li class="folder">
78 <li class="folder">
70 <a href="#" class="submenu"><%= l(:field_done_ratio) %></a>
79 <a href="#" class="submenu"><%= l(:field_done_ratio) %></a>
71 <ul>
80 <ul>
72 <% (0..10).map{|x|x*10}.each do |p| -%>
81 <% (0..10).map{|x|x*10}.each do |p| -%>
73 <li><%= context_menu_link "#{p}%", {:controller => 'issues', :action => 'bulk_edit', :ids => @issues.collect(&:id), 'done_ratio' => p, :back_to => @back}, :method => :post,
82 <li><%= context_menu_link "#{p}%", {:controller => 'issues', :action => 'bulk_edit', :ids => @issues.collect(&:id), 'done_ratio' => p, :back_to => @back}, :method => :post,
74 :selected => (@issue && p == @issue.done_ratio), :disabled => !@can[:edit] %></li>
83 :selected => (@issue && p == @issue.done_ratio), :disabled => !@can[:edit] %></li>
75 <% end -%>
84 <% end -%>
76 </ul>
85 </ul>
77 </li>
86 </li>
78
87
79 <% if !@issue.nil? %>
88 <% if !@issue.nil? %>
80 <li><%= context_menu_link l(:button_copy), {:controller => 'issues', :action => 'new', :project_id => @project, :copy_from => @issue},
89 <li><%= context_menu_link l(:button_copy), {:controller => 'issues', :action => 'new', :project_id => @project, :copy_from => @issue},
81 :class => 'icon-copy', :disabled => !@can[:copy] %></li>
90 :class => 'icon-copy', :disabled => !@can[:copy] %></li>
82 <% if @can[:log_time] -%>
91 <% if @can[:log_time] -%>
83 <li><%= context_menu_link l(:button_log_time), {:controller => 'timelog', :action => 'edit', :issue_id => @issue},
92 <li><%= context_menu_link l(:button_log_time), {:controller => 'timelog', :action => 'edit', :issue_id => @issue},
84 :class => 'icon-time-add' %></li>
93 :class => 'icon-time-add' %></li>
85 <% end %>
94 <% end %>
86 <% if User.current.logged? %>
95 <% if User.current.logged? %>
87 <li><%= watcher_link(@issue, User.current) %></li>
96 <li><%= watcher_link(@issue, User.current) %></li>
88 <% end %>
97 <% end %>
89 <% end %>
98 <% end %>
90
99
91 <li><%= context_menu_link l(:button_move), {:controller => 'issues', :action => 'move', :ids => @issues.collect(&:id)},
100 <li><%= context_menu_link l(:button_move), {:controller => 'issues', :action => 'move', :ids => @issues.collect(&:id)},
92 :class => 'icon-move', :disabled => !@can[:move] %></li>
101 :class => 'icon-move', :disabled => !@can[:move] %></li>
93 <li><%= context_menu_link l(:button_delete), {:controller => 'issues', :action => 'destroy', :ids => @issues.collect(&:id)},
102 <li><%= context_menu_link l(:button_delete), {:controller => 'issues', :action => 'destroy', :ids => @issues.collect(&:id)},
94 :method => :post, :confirm => l(:text_issues_destroy_confirmation), :class => 'icon-del', :disabled => !@can[:delete] %></li>
103 :method => :post, :confirm => l(:text_issues_destroy_confirmation), :class => 'icon-del', :disabled => !@can[:delete] %></li>
95
104
96 <%= call_hook(:view_issues_context_menu_end, {:issues => @issues, :can => @can, :back => @back }) %>
105 <%= call_hook(:view_issues_context_menu_end, {:issues => @issues, :can => @can, :back => @back }) %>
97 </ul>
106 </ul>
General Comments 0
You need to be logged in to leave comments. Login now