@@ -340,12 +340,13 class ProjectsController < ApplicationController | |||
|
340 | 340 | # Bulk edit issues |
|
341 | 341 | def bulk_edit_issues |
|
342 | 342 | if request.post? |
|
343 | status = IssueStatus.find_by_id(params[:status_id]) | |
|
343 | 344 | priority = Enumeration.find_by_id(params[:priority_id]) |
|
344 | 345 | assigned_to = User.find_by_id(params[:assigned_to_id]) |
|
345 | 346 | category = @project.issue_categories.find_by_id(params[:category_id]) |
|
346 | 347 | fixed_version = @project.versions.find_by_id(params[:fixed_version_id]) |
|
347 | 348 | issues = @project.issues.find_all_by_id(params[:issue_ids]) |
|
348 | unsaved_issue_ids = [] | |
|
349 | unsaved_issue_ids = [] | |
|
349 | 350 | issues.each do |issue| |
|
350 | 351 | journal = issue.init_journal(User.current, params[:notes]) |
|
351 | 352 | issue.priority = priority if priority |
@@ -355,10 +356,12 class ProjectsController < ApplicationController | |||
|
355 | 356 | issue.start_date = params[:start_date] unless params[:start_date].blank? |
|
356 | 357 | issue.due_date = params[:due_date] unless params[:due_date].blank? |
|
357 | 358 | issue.done_ratio = params[:done_ratio] unless params[:done_ratio].blank? |
|
358 | if issue.save | |
|
359 | # Don't save any change to the issue if the user is not authorized to apply the requested status | |
|
360 | if (status.nil? || (issue.status.new_status_allowed_to?(status, current_role, issue.tracker) && issue.status = status)) && issue.save | |
|
359 | 361 | # Send notification for each issue (if changed) |
|
360 | 362 | Mailer.deliver_issue_edit(journal) if journal.details.any? && Setting.notified_events.include?('issue_updated') |
|
361 | 363 | else |
|
364 | # Keep unsaved issue ids to display them in flash error | |
|
362 | 365 | unsaved_issue_ids << issue.id |
|
363 | 366 | end |
|
364 | 367 | end |
@@ -370,6 +373,11 class ProjectsController < ApplicationController | |||
|
370 | 373 | redirect_to :action => 'list_issues', :id => @project |
|
371 | 374 | return |
|
372 | 375 | end |
|
376 | if current_role && User.current.allowed_to?(:change_issue_status, @project) | |
|
377 | # Find potential statuses the user could be allowed to switch issues to | |
|
378 | @available_statuses = Workflow.find(:all, :include => :new_status, | |
|
379 | :conditions => {:role_id => current_role.id}).collect(&:new_status).compact.uniq | |
|
380 | end | |
|
373 | 381 | render :update do |page| |
|
374 | 382 | page.hide 'query_form' |
|
375 | 383 | page.replace_html 'bulk-edit', :partial => 'issues/bulk_edit_form' |
@@ -51,6 +51,12 class IssueStatus < ActiveRecord::Base | |||
|
51 | 51 | :conditions => ["role_id=? and tracker_id=?", role.id, tracker.id]).collect{ |w| w.new_status }.compact if role && tracker |
|
52 | 52 | new_statuses ? new_statuses.sort{|x, y| x.position <=> y.position } : [] |
|
53 | 53 | end |
|
54 | ||
|
55 | def new_status_allowed_to?(status, role, tracker) | |
|
56 | status && role && tracker ? | |
|
57 | !workflows.find(:first, :conditions => {:new_status_id => status.id, :role_id => role.id, :tracker_id => tracker.id}).nil? : | |
|
58 | false | |
|
59 | end | |
|
54 | 60 | |
|
55 | 61 | def to_s; name end |
|
56 | 62 |
@@ -2,12 +2,18 | |||
|
2 | 2 | <fieldset class="box"><legend><%= l(:label_bulk_edit_selected_issues) %></legend> |
|
3 | 3 | |
|
4 | 4 | <p> |
|
5 | <% if @available_statuses %> | |
|
6 | <label><%= l(:field_status) %>: | |
|
7 | <%= select_tag('status_id', "<option value=\"\">#{l(:label_no_change_option)}</option>" + options_from_collection_for_select(@available_statuses, :id, :name)) %></label> | |
|
8 | <% end %> | |
|
5 | 9 | <label><%= l(:field_priority) %>: |
|
6 | 10 | <%= select_tag('priority_id', "<option value=\"\">#{l(:label_no_change_option)}</option>" + options_from_collection_for_select(Enumeration.get_values('IPRI'), :id, :name)) %></label> |
|
7 | <label><%= l(:field_assigned_to) %>: | |
|
8 | <%= select_tag('assigned_to_id', "<option value=\"\">#{l(:label_no_change_option)}</option>" + options_from_collection_for_select(@project.assignable_users, :id, :name)) %></label> | |
|
9 | 11 | <label><%= l(:field_category) %>: |
|
10 | 12 | <%= select_tag('category_id', "<option value=\"\">#{l(:label_no_change_option)}</option>" + options_from_collection_for_select(@project.issue_categories, :id, :name)) %></label> |
|
13 | </p> | |
|
14 | <p> | |
|
15 | <label><%= l(:field_assigned_to) %>: | |
|
16 | <%= select_tag('assigned_to_id', "<option value=\"\">#{l(:label_no_change_option)}</option>" + options_from_collection_for_select(@project.assignable_users, :id, :name)) %></label> | |
|
11 | 17 | <label><%= l(:field_fixed_version) %>: |
|
12 | 18 | <%= select_tag('fixed_version_id', "<option value=\"\">#{l(:label_no_change_option)}</option>" + options_from_collection_for_select(@project.versions, :id, :name)) %></label> |
|
13 | 19 | </p> |
General Comments 0
You need to be logged in to leave comments.
Login now