@@ -340,12 +340,13 class ProjectsController < ApplicationController | |||||
340 | # Bulk edit issues |
|
340 | # Bulk edit issues | |
341 | def bulk_edit_issues |
|
341 | def bulk_edit_issues | |
342 | if request.post? |
|
342 | if request.post? | |
|
343 | status = IssueStatus.find_by_id(params[:status_id]) | |||
343 | priority = Enumeration.find_by_id(params[:priority_id]) |
|
344 | priority = Enumeration.find_by_id(params[:priority_id]) | |
344 | assigned_to = User.find_by_id(params[:assigned_to_id]) |
|
345 | assigned_to = User.find_by_id(params[:assigned_to_id]) | |
345 | category = @project.issue_categories.find_by_id(params[:category_id]) |
|
346 | category = @project.issue_categories.find_by_id(params[:category_id]) | |
346 | fixed_version = @project.versions.find_by_id(params[:fixed_version_id]) |
|
347 | fixed_version = @project.versions.find_by_id(params[:fixed_version_id]) | |
347 | issues = @project.issues.find_all_by_id(params[:issue_ids]) |
|
348 | issues = @project.issues.find_all_by_id(params[:issue_ids]) | |
348 | unsaved_issue_ids = [] |
|
349 | unsaved_issue_ids = [] | |
349 | issues.each do |issue| |
|
350 | issues.each do |issue| | |
350 | journal = issue.init_journal(User.current, params[:notes]) |
|
351 | journal = issue.init_journal(User.current, params[:notes]) | |
351 | issue.priority = priority if priority |
|
352 | issue.priority = priority if priority | |
@@ -355,10 +356,12 class ProjectsController < ApplicationController | |||||
355 | issue.start_date = params[:start_date] unless params[:start_date].blank? |
|
356 | issue.start_date = params[:start_date] unless params[:start_date].blank? | |
356 | issue.due_date = params[:due_date] unless params[:due_date].blank? |
|
357 | issue.due_date = params[:due_date] unless params[:due_date].blank? | |
357 | issue.done_ratio = params[:done_ratio] unless params[:done_ratio].blank? |
|
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 | # Send notification for each issue (if changed) |
|
361 | # Send notification for each issue (if changed) | |
360 | Mailer.deliver_issue_edit(journal) if journal.details.any? && Setting.notified_events.include?('issue_updated') |
|
362 | Mailer.deliver_issue_edit(journal) if journal.details.any? && Setting.notified_events.include?('issue_updated') | |
361 | else |
|
363 | else | |
|
364 | # Keep unsaved issue ids to display them in flash error | |||
362 | unsaved_issue_ids << issue.id |
|
365 | unsaved_issue_ids << issue.id | |
363 | end |
|
366 | end | |
364 | end |
|
367 | end | |
@@ -370,6 +373,11 class ProjectsController < ApplicationController | |||||
370 | redirect_to :action => 'list_issues', :id => @project |
|
373 | redirect_to :action => 'list_issues', :id => @project | |
371 | return |
|
374 | return | |
372 | end |
|
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 | render :update do |page| |
|
381 | render :update do |page| | |
374 | page.hide 'query_form' |
|
382 | page.hide 'query_form' | |
375 | page.replace_html 'bulk-edit', :partial => 'issues/bulk_edit_form' |
|
383 | page.replace_html 'bulk-edit', :partial => 'issues/bulk_edit_form' |
@@ -51,6 +51,12 class IssueStatus < ActiveRecord::Base | |||||
51 | :conditions => ["role_id=? and tracker_id=?", role.id, tracker.id]).collect{ |w| w.new_status }.compact if role && tracker |
|
51 | :conditions => ["role_id=? and tracker_id=?", role.id, tracker.id]).collect{ |w| w.new_status }.compact if role && tracker | |
52 | new_statuses ? new_statuses.sort{|x, y| x.position <=> y.position } : [] |
|
52 | new_statuses ? new_statuses.sort{|x, y| x.position <=> y.position } : [] | |
53 | end |
|
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 | def to_s; name end |
|
61 | def to_s; name end | |
56 |
|
62 |
@@ -2,12 +2,18 | |||||
2 | <fieldset class="box"><legend><%= l(:label_bulk_edit_selected_issues) %></legend> |
|
2 | <fieldset class="box"><legend><%= l(:label_bulk_edit_selected_issues) %></legend> | |
3 |
|
3 | |||
4 | <p> |
|
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 | <label><%= l(:field_priority) %>: |
|
9 | <label><%= l(:field_priority) %>: | |
6 | <%= select_tag('priority_id', "<option value=\"\">#{l(:label_no_change_option)}</option>" + options_from_collection_for_select(Enumeration.get_values('IPRI'), :id, :name)) %></label> |
|
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 | <label><%= l(:field_category) %>: |
|
11 | <label><%= l(:field_category) %>: | |
10 | <%= select_tag('category_id', "<option value=\"\">#{l(:label_no_change_option)}</option>" + options_from_collection_for_select(@project.issue_categories, :id, :name)) %></label> |
|
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 | <label><%= l(:field_fixed_version) %>: |
|
17 | <label><%= l(:field_fixed_version) %>: | |
12 | <%= select_tag('fixed_version_id', "<option value=\"\">#{l(:label_no_change_option)}</option>" + options_from_collection_for_select(@project.versions, :id, :name)) %></label> |
|
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 | </p> |
|
19 | </p> |
General Comments 0
You need to be logged in to leave comments.
Login now