diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2016-09-03 07:55:57 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2016-09-03 07:55:57 +0000 |
commit | dcf2e15b0617e4e0aa2cc4b7dde2c59b688c535a (patch) | |
tree | f7e9853abca29498ae65e2d46a4ce747eab07ec8 /app | |
parent | fa3a167cdf16eb4952fefc66850a01ccc0a06e7c (diff) | |
download | redmine-dcf2e15b0617e4e0aa2cc4b7dde2c59b688c535a.tar.gz redmine-dcf2e15b0617e4e0aa2cc4b7dde2c59b688c535a.zip |
Bulk edit form not show fields based on target tracker and status (#23755).
git-svn-id: http://svn.redmine.org/redmine/trunk@15815 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/issues_controller.rb | 25 | ||||
-rw-r--r-- | app/views/issues/bulk_edit.html.erb | 6 |
2 files changed, 25 insertions, 6 deletions
diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index d3dd2d504..779e85113 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -218,24 +218,41 @@ class IssuesController < ApplicationController end end + edited_issues = Issue.where(:id => @issues.map(&:id)).to_a + @allowed_projects = Issue.allowed_target_projects if params[:issue] @target_project = @allowed_projects.detect {|p| p.id.to_s == params[:issue][:project_id].to_s} if @target_project target_projects = [@target_project] + edited_issues.each {|issue| issue.project = @target_project} end end target_projects ||= @projects + @trackers = target_projects.map {|p| Issue.allowed_target_trackers(p) }.reduce(:&) + if params[:issue] + @target_tracker = @trackers.detect {|t| t.id.to_s == params[:issue][:tracker_id].to_s} + if @target_tracker + edited_issues.each {|issue| issue.tracker = @target_tracker} + end + end + if @copy # Copied issues will get their default statuses @available_statuses = [] else - @available_statuses = @issues.map(&:new_statuses_allowed_to).reduce(:&) + @available_statuses = edited_issues.map(&:new_statuses_allowed_to).reduce(:&) end - @custom_fields = @issues.map{|i|i.editable_custom_fields}.reduce(:&) + if params[:issue] + @target_status = @available_statuses.detect {|t| t.id.to_s == params[:issue][:status_id].to_s} + if @target_status + edited_issues.each {|issue| issue.status = @target_status} + end + end + + @custom_fields = edited_issues.map{|i|i.editable_custom_fields}.reduce(:&) @assignables = target_projects.map(&:assignable_users).reduce(:&) - @trackers = target_projects.map {|p| Issue.allowed_target_trackers(p) }.reduce(:&) @versions = target_projects.map {|p| p.shared_versions.open}.reduce(:&) @categories = target_projects.map {|p| p.issue_categories}.reduce(:&) if @copy @@ -243,7 +260,7 @@ class IssuesController < ApplicationController @subtasks_present = @issues.detect {|i| !i.leaf?}.present? end - @safe_attributes = @issues.map(&:safe_attribute_names).reduce(:&) + @safe_attributes = edited_issues.map(&:safe_attribute_names).reduce(:&) @issue_params = params[:issue] || {} @issue_params[:custom_field_values] ||= {} diff --git a/app/views/issues/bulk_edit.html.erb b/app/views/issues/bulk_edit.html.erb index 37bdb6d42..29b4881c7 100644 --- a/app/views/issues/bulk_edit.html.erb +++ b/app/views/issues/bulk_edit.html.erb @@ -43,14 +43,16 @@ <label for="issue_tracker_id"><%= l(:field_tracker) %></label> <%= select_tag('issue[tracker_id]', content_tag('option', l(:label_no_change_option), :value => '') + - options_from_collection_for_select(@trackers, :id, :name, @issue_params[:tracker_id])) %> + options_from_collection_for_select(@trackers, :id, :name, @issue_params[:tracker_id]), + :onchange => "updateBulkEditFrom('#{escape_javascript url_for(:action => 'bulk_edit', :format => 'js')}')") %> </p> <% if @available_statuses.any? %> <p> <label for='issue_status_id'><%= l(:field_status) %></label> <%= select_tag('issue[status_id]', content_tag('option', l(:label_no_change_option), :value => '') + - options_from_collection_for_select(@available_statuses, :id, :name, @issue_params[:status_id])) %> + options_from_collection_for_select(@available_statuses, :id, :name, @issue_params[:status_id]), + :onchange => "updateBulkEditFrom('#{escape_javascript url_for(:action => 'bulk_edit', :format => 'js')}')") %> </p> <% end %> |