]> source.dussan.org Git - redmine.git/commitdiff
Adds option for displaying all statuses on workflow permissions.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 15 Jul 2012 15:46:14 +0000 (15:46 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 15 Jul 2012 15:46:14 +0000 (15:46 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9995 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/workflows_controller.rb
app/views/workflows/permissions.html.erb
test/functional/workflows_controller_test.rb

index 727bde68f2a3a91c27b08b8ffb78dd377931513e..7f397bc4ec3456d48ab67be1861bb37780792210 100644 (file)
@@ -62,17 +62,19 @@ class WorkflowsController < ApplicationController
     @role = Role.find_by_id(params[:role_id]) if params[:role_id]
     @tracker = Tracker.find_by_id(params[:tracker_id]) if params[:tracker_id]
 
-    if @role && @tracker
-      if request.post?
-        WorkflowPermission.replace_permissions(@tracker, @role, params[:permissions] || {})
-        redirect_to :action => 'permissions', :role_id => @role, :tracker_id => @tracker
-        return
-      end
+    if request.post? && @role && @tracker
+      WorkflowPermission.replace_permissions(@tracker, @role, params[:permissions] || {})
+      redirect_to :action => 'permissions', :role_id => @role, :tracker_id => @tracker
+      return
+    end
 
+    @used_statuses_only = (params[:used_statuses_only] == '0' ? false : true)
+    if @tracker && @used_statuses_only && @tracker.issue_statuses.any?
       @statuses = @tracker.issue_statuses
-      if @statuses.empty?
-        @statuses = IssueStatus.sorted.all
-      end
+    end
+    @statuses ||= IssueStatus.sorted.all
+
+    if @role && @tracker
       @fields = (Tracker::CORE_FIELDS_ALL - @tracker.disabled_core_fields).map {|field| [field, l("field_"+field.sub(/_id$/, ''))]}
       @custom_fields = @tracker.custom_fields
 
index 3f9ea21815ca147f12c1655704b08319956800cb..2e7c4e0922c8b0f9bd3354edd27fd8dd8031d838 100644 (file)
@@ -20,6 +20,9 @@
   <%= select_tag 'tracker_id', options_from_collection_for_select(@trackers, "id", "name", @tracker && @tracker.id) %></label>
 
   <%= submit_tag l(:button_edit), :name => nil %>
+
+  <%= hidden_field_tag 'used_statuses_only', '0' %>
+  <label><%= check_box_tag 'used_statuses_only', '1', @used_statuses_only %> <%= l(:label_display_used_statuses_only) %></label>
 </p>
 <% end %>
 
index 84250d346e0b8aeff652b4cf64b6ce2a2c48eea0..0a35df5df3c72127437d02203aa2ba7825c3695a 100644 (file)
@@ -191,6 +191,14 @@ class WorkflowsControllerTest < ActionController::TestCase
     end
   end
 
+  def test_get_permissions_with_role_and_tracker_and_all_statuses
+    WorkflowTransition.delete_all
+
+    get :permissions, :role_id => 1, :tracker_id => 2, :used_statuses_only => '0'
+    assert_response :success
+    assert_equal IssueStatus.sorted.all, assigns(:statuses)
+  end
+
   def test_post_permissions
     WorkflowPermission.delete_all