]> source.dussan.org Git - redmine.git/commitdiff
By default, only show statuses that are used by the tracker on the workflow edit...
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Fri, 18 Dec 2009 15:41:32 +0000 (15:41 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Fri, 18 Dec 2009 15:41:32 +0000 (15:41 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3188 e93f8b46-1217-0410-a6f0-8f06a7374b81

40 files changed:
app/controllers/workflows_controller.rb
app/models/tracker.rb
app/views/workflows/edit.rhtml
config/locales/bg.yml
config/locales/bs.yml
config/locales/ca.yml
config/locales/cs.yml
config/locales/da.yml
config/locales/de.yml
config/locales/el.yml
config/locales/en.yml
config/locales/es.yml
config/locales/fi.yml
config/locales/fr.yml
config/locales/gl.yml
config/locales/he.yml
config/locales/hu.yml
config/locales/it.yml
config/locales/ja.yml
config/locales/ko.yml
config/locales/lt.yml
config/locales/nl.yml
config/locales/no.yml
config/locales/pl.yml
config/locales/pt-BR.yml
config/locales/pt.yml
config/locales/ro.yml
config/locales/ru.yml
config/locales/sk.yml
config/locales/sl.yml
config/locales/sr.yml
config/locales/sv.yml
config/locales/th.yml
config/locales/tr.yml
config/locales/uk.yml
config/locales/vi.yml
config/locales/zh-TW.yml
config/locales/zh.yml
test/functional/workflows_controller_test.rb
test/unit/tracker_test.rb

index 6e7c58e26b4729927137d5718fc3c7f7885917a5..fd28767696722f2ca17566bc0b44eedeef45b03a 100644 (file)
@@ -42,7 +42,12 @@ class WorkflowsController < ApplicationController
     end
     @roles = Role.find(:all, :order => 'builtin, position')
     @trackers = Tracker.find(:all, :order => 'position')
-    @statuses = IssueStatus.find(:all, :order => 'position')
+    
+    @used_statuses_only = (params[:used_statuses_only] == '0' ? false : true)
+    if @tracker && @used_statuses_only && @tracker.issue_statuses.any?
+      @statuses = @tracker.issue_statuses
+    end
+    @statuses ||= IssueStatus.find(:all, :order => 'position')
   end
   
   def copy
index 8f7a98c39a2e0c874631499dc14fd974f8d7c9d4..9ee045ce14ad9a0fd95ad36159055960fab85e73 100644 (file)
@@ -43,6 +43,23 @@ class Tracker < ActiveRecord::Base
     find(:all, :order => 'position')
   end
   
+  # Returns an array of IssueStatus that are used
+  # in the tracker's workflows
+  def issue_statuses
+    if @issue_statuses
+      return @issue_statuses 
+    elsif new_record?
+      return []
+    end
+    
+    ids = Workflow.
+            connection.select_rows("SELECT DISTINCT old_status_id, new_status_id FROM #{Workflow.table_name} WHERE tracker_id = #{id}").
+            flatten.
+            uniq
+    
+    @issue_statuses = IssueStatus.find_all_by_id(ids).sort
+  end
+  
 private
   def check_integrity
     raise "Can't delete tracker" if Issue.find(:first, :conditions => ["tracker_id=?", self.id])
index 4feaf3a7c3a3ec1a9e45fd40ab2392a23dedf7ef..d7343fa2b1164259ee7c1ff319ca0925d7eb07a9 100644 (file)
 
   <label><%=l(:label_tracker)%>:</label>
        <%= select_tag 'tracker_id', options_from_collection_for_select(@trackers, "id", "name", @tracker && @tracker.id) %>
-       
-       <%= 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>
+<p>
+<%= submit_tag l(:button_edit), :name => nil %>
 </p>
 <% end %>
 
index 300bd38687cbac7144c664dd14b0842bb92a5854..4302542ceeb8b4bfdcd123f85124652ae63d7d89 100644 (file)
@@ -855,3 +855,4 @@ bg:
   label_update_issue_done_ratios: Update issue done ratios
   setting_start_of_week: Start calendars on
   permission_view_issues: View Issues
+  label_display_used_statuses_only: Only display statuses that are used by this tracker
index d2bd1800fdab86dc43917280772a7bc59c074070..5e33bb8ade0623a38777fa71f7d1461a55ad1991 100644 (file)
@@ -879,3 +879,4 @@ bs:
   label_update_issue_done_ratios: Update issue done ratios
   setting_start_of_week: Start calendars on
   permission_view_issues: View Issues
+  label_display_used_statuses_only: Only display statuses that are used by this tracker
index 0019a5f37312a1842b3c0262a35840998a503b10..c5120180d5c336017863af0a861cdc4b67b4366a 100644 (file)
@@ -858,3 +858,4 @@ ca:
   label_update_issue_done_ratios: Update issue done ratios
   setting_start_of_week: Start calendars on
   permission_view_issues: View Issues
+  label_display_used_statuses_only: Only display statuses that are used by this tracker
index 03d6d90b5b34d6742218c2c40f5fb8a6dadeaddd..4ad8ad62a7102df6e636e2d8db0b7afb3e3c8258 100644 (file)
@@ -861,3 +861,4 @@ cs:
   label_update_issue_done_ratios: Update issue done ratios
   setting_start_of_week: Start calendars on
   permission_view_issues: View Issues
+  label_display_used_statuses_only: Only display statuses that are used by this tracker
index c627f735358991c16ea2104027be5e0995bc255e..246855811f9238204914faaa94b9e1ca548d625f 100644 (file)
@@ -881,3 +881,4 @@ da:
   label_update_issue_done_ratios: Update issue done ratios
   setting_start_of_week: Start calendars on
   permission_view_issues: View Issues
+  label_display_used_statuses_only: Only display statuses that are used by this tracker
index e936faf87faa42126905ce6884ad33946c7d143d..e11ffb52589bff1fdf61be1c9b38ad5ba50acc93 100644 (file)
@@ -881,3 +881,4 @@ de:
   label_update_issue_done_ratios: Update issue done ratios
   setting_start_of_week: Start calendars on
   permission_view_issues: View Issues
+  label_display_used_statuses_only: Only display statuses that are used by this tracker
index 76825d896c13645ad4e4067a5dfdc607aef5f021..13f8f37c7b88d84d5960a79e0675221c601c65b7 100644 (file)
@@ -861,3 +861,4 @@ el:
   label_update_issue_done_ratios: Update issue done ratios
   setting_start_of_week: Start calendars on
   permission_view_issues: View Issues
+  label_display_used_statuses_only: Only display statuses that are used by this tracker
index 1be78ebcd0d8c2cd296b7333a2690ed0798e0a23..3eee529d1500c9ef603fa10d1ae5717b0dbe662b 100644 (file)
@@ -727,6 +727,7 @@ en:
   label_copy_source: Source
   label_copy_target: Target
   label_copy_same_as_target: Same as target
+  label_display_used_statuses_only: Only display statuses that are used by this tracker
   
   button_login: Login
   button_submit: Submit
index 7a22b7384ca7e0adc9cf7f103d0d6b1791a984a9..c0aa91dba001f7d0164ace70cf6e0dd3199e567e 100644 (file)
@@ -902,3 +902,4 @@ es:
   label_update_issue_done_ratios: Update issue done ratios
   setting_start_of_week: Start calendars on
   permission_view_issues: View Issues
+  label_display_used_statuses_only: Only display statuses that are used by this tracker
index 7b2e754efb23c559c695a226c8ea74e00b0c13c8..93d354dc4ed622a9db75923c34dad17b9f9136f0 100644 (file)
@@ -891,3 +891,4 @@ fi:
   label_update_issue_done_ratios: Update issue done ratios
   setting_start_of_week: Start calendars on
   permission_view_issues: View Issues
+  label_display_used_statuses_only: Only display statuses that are used by this tracker
index fd32c6b691d11b36a98f5da974d689be665217c1..aa7fdafa9e3774c7473b9e5d60389001c6840574 100644 (file)
@@ -742,6 +742,7 @@ fr:
   label_copy_target: Cible
   label_copy_same_as_target: Comme la cible
   label_update_issue_done_ratios: Mettre à jour l'avancement des demandes
+  label_display_used_statuses_only: N'afficher que les statuts utilisés dans ce tracker
   
   button_login: Connexion
   button_submit: Soumettre
index 77698bd2e8c67e8b6d6cfcd717eafad76ed742ef..363a54ef3d374282fdc743ac3495968bac4ea768 100644 (file)
@@ -881,3 +881,4 @@ gl:
   label_update_issue_done_ratios: Update issue done ratios
   setting_start_of_week: Start calendars on
   permission_view_issues: View Issues
+  label_display_used_statuses_only: Only display statuses that are used by this tracker
index b7df4fbd3562d728c5f49eacf377480fcf461661..bc17238267ff51b1fd9083e36b658717181831c0 100644 (file)
@@ -865,3 +865,4 @@ he:
   label_update_issue_done_ratios: Update issue done ratios
   setting_start_of_week: Start calendars on
   permission_view_issues: View Issues
+  label_display_used_statuses_only: Only display statuses that are used by this tracker
index 71023e70398a617ca370f4e53ead2115d2568db1..8c9f289f9a0b17450ed87f9e82973e9aa8de7279 100644 (file)
   label_update_issue_done_ratios: Update issue done ratios
   setting_start_of_week: Start calendars on
   permission_view_issues: View Issues
+  label_display_used_statuses_only: Only display statuses that are used by this tracker
index 6ec67fee3e6e53b0300fed7a254abeeb1d998599..627daf3473ffa1aa77546a5f4dc075f60beb6776 100644 (file)
@@ -868,3 +868,4 @@ it:
   label_update_issue_done_ratios: Update issue done ratios
   setting_start_of_week: Start calendars on
   permission_view_issues: View Issues
+  label_display_used_statuses_only: Only display statuses that are used by this tracker
index 24127d8e50f09d3008f0f194d3b248d999620885..1257db2608a594ce938875fdcf48a19991689d69 100644 (file)
@@ -890,3 +890,4 @@ ja:
   label_update_issue_done_ratios: Update issue done ratios
   setting_start_of_week: Start calendars on
   permission_view_issues: View Issues
+  label_display_used_statuses_only: Only display statuses that are used by this tracker
index 5402fc1915ac1c9c7963bd42993590b192bd8c23..081c3acd4b962753c542b132c546f6cea64a3853 100644 (file)
@@ -921,3 +921,4 @@ ko:
   label_update_issue_done_ratios: Update issue done ratios
   setting_start_of_week: Start calendars on
   permission_view_issues: View Issues
+  label_display_used_statuses_only: Only display statuses that are used by this tracker
index b7d6eece3d633a6ae55ca7ae0e80b9b258ccfdca..b21fb5c3160b9683cd18deefed8db0d5c189fa55 100644 (file)
@@ -929,3 +929,4 @@ lt:
   error_workflow_copy_source: Please select a source tracker or role
   label_update_issue_done_ratios: Update issue done ratios
   permission_view_issues: View Issues
+  label_display_used_statuses_only: Only display statuses that are used by this tracker
index 2b50fd8380c3c9f45dc1a6d789481027d0358b7d..3acefe89f279737ee0d2befcd297e2a41c4ad40a 100644 (file)
@@ -843,3 +843,4 @@ nl:
   label_update_issue_done_ratios: Update issue done ratios
   setting_start_of_week: Start calendars on
   permission_view_issues: View Issues
+  label_display_used_statuses_only: Only display statuses that are used by this tracker
index 6eda0fa71f26f44483c38af277302e36252221ee..a8b064c0e7ab957b23afc169086facc203d87632 100644 (file)
   label_update_issue_done_ratios: Update issue done ratios
   setting_start_of_week: Start calendars on
   permission_view_issues: View Issues
+  label_display_used_statuses_only: Only display statuses that are used by this tracker
index 1eb0c0ee906842aeec94fe88614f126e1e8a6b33..d3e5021963ba7c64917eac6ac6bc971cb601aa80 100644 (file)
@@ -884,3 +884,4 @@ pl:
   label_update_issue_done_ratios: Update issue done ratios
   setting_start_of_week: Start calendars on
   permission_view_issues: View Issues
+  label_display_used_statuses_only: Only display statuses that are used by this tracker
index 98fcf1d2602ad5d508858f07a7bd95d72b13ccf7..6491b0c5468ffaf0fc4ed2ab1a758195c66bce96 100644 (file)
@@ -889,3 +889,4 @@ pt-BR:
   field_watcher: Observador
 
   permission_view_issues: View Issues
+  label_display_used_statuses_only: Only display statuses that are used by this tracker
index 2a61405804290305f20b336bf084e57686949dd6..24c24190c6417930d6708045e136e145926bcb56 100644 (file)
@@ -873,3 +873,4 @@ pt:
   label_update_issue_done_ratios: Update issue done ratios
   setting_start_of_week: Start calendars on
   permission_view_issues: View Issues
+  label_display_used_statuses_only: Only display statuses that are used by this tracker
index 4f098e8d6fa7d3e041b1e05ea76e607895732d63..9a089118a2eedff4e62b7214ce8b59eb163c23c5 100644 (file)
@@ -858,3 +858,4 @@ ro:
   label_update_issue_done_ratios: Update issue done ratios
   setting_start_of_week: Start calendars on
   permission_view_issues: View Issues
+  label_display_used_statuses_only: Only display statuses that are used by this tracker
index 08141371dd3231686147027faf0e44164957ad37..c01e52a64f8fdf5cddd9e6e06bf89291117cc52d 100644 (file)
@@ -969,3 +969,4 @@ ru:
   label_update_issue_done_ratios: Update issue done ratios
   setting_start_of_week: Start calendars on
   permission_view_issues: View Issues
+  label_display_used_statuses_only: Only display statuses that are used by this tracker
index 5798a48d6be838b77095f2aeb2fee7b713bcf3df..a20630837746fc62dbee3203164f261310013b29 100644 (file)
@@ -860,3 +860,4 @@ sk:
   label_update_issue_done_ratios: Update issue done ratios
   setting_start_of_week: Start calendars on
   permission_view_issues: View Issues
+  label_display_used_statuses_only: Only display statuses that are used by this tracker
index 30c2e3777680476b75b85427a5dbf72ee065e651..61f84ad8b561ce335e4c9daef0add1c4ae540561 100644 (file)
@@ -857,3 +857,4 @@ sl:
   label_update_issue_done_ratios: Update issue done ratios
   setting_start_of_week: Start calendars on
   permission_view_issues: View Issues
+  label_display_used_statuses_only: Only display statuses that are used by this tracker
index f7af3d4a4e946fe73835667c96af2a8e8217bc4b..b58df8c60061ab6346914a05ace464021c7511ec 100644 (file)
   label_update_issue_done_ratios: Update issue done ratios
   setting_start_of_week: Start calendars on
   permission_view_issues: View Issues
+  label_display_used_statuses_only: Only display statuses that are used by this tracker
index 7a188009b226828de7f5acdc8ce85c731ae650ac..c73a756882ad7ea820a6bbc1ede3ec61df3a5707 100644 (file)
@@ -910,3 +910,4 @@ sv:
   label_update_issue_done_ratios: Update issue done ratios
   setting_start_of_week: Start calendars on
   permission_view_issues: View Issues
+  label_display_used_statuses_only: Only display statuses that are used by this tracker
index 1e88942b1ab589d8df363964609531833cc7dfa6..8ad86d00aea339b3ffb4059d280a0989cfac425e 100644 (file)
@@ -858,3 +858,4 @@ th:
   label_update_issue_done_ratios: Update issue done ratios
   setting_start_of_week: Start calendars on
   permission_view_issues: View Issues
+  label_display_used_statuses_only: Only display statuses that are used by this tracker
index 1135fc3789186edc60155fce87fced51e2589665..e98b53f02e957d6440a356e725fe81769eefd69f 100644 (file)
@@ -888,3 +888,4 @@ tr:
   label_update_issue_done_ratios: Update issue done ratios
   setting_start_of_week: Start calendars on
   permission_view_issues: View Issues
+  label_display_used_statuses_only: Only display statuses that are used by this tracker
index f6288f6683e7da246659d74b3c054feba607fd10..55dc50c56e3eb33f163ea0906f49af5479519945 100644 (file)
@@ -857,3 +857,4 @@ uk:
   label_update_issue_done_ratios: Update issue done ratios
   setting_start_of_week: Start calendars on
   permission_view_issues: View Issues
+  label_display_used_statuses_only: Only display statuses that are used by this tracker
index 76e28e8b6d891eb5bed0db9d03a0ed4445b54fe8..d498cb53c1e9674d96405cce6da95680290e257b 100644 (file)
@@ -920,3 +920,4 @@ vi:
   label_update_issue_done_ratios: Update issue done ratios
   setting_start_of_week: Start calendars on
   permission_view_issues: View Issues
+  label_display_used_statuses_only: Only display statuses that are used by this tracker
index f026719c3a641bb4ad75651d9ed0c2761d38a6a9..b315d370aa719a2ce2a0a6cdc3d8249d0346bfac 100644 (file)
   error_workflow_copy_source: Please select a source tracker or role
   label_update_issue_done_ratios: Update issue done ratios
   permission_view_issues: View Issues
+  label_display_used_statuses_only: Only display statuses that are used by this tracker
index 389ec4a0db92e5f85d2385b5e61392201cbe82cb..e34c5c3f391580afb901388632834ec1d9ddd7c7 100644 (file)
@@ -885,3 +885,4 @@ zh:
   label_update_issue_done_ratios: Update issue done ratios
   setting_start_of_week: Start calendars on
   permission_view_issues: View Issues
+  label_display_used_statuses_only: Only display statuses that are used by this tracker
index 2b5216f55e1bae6ace9d2abf01e1df06d99acef0..802d10d6c0e38c00336057209d9466dc94479c7f 100644 (file)
@@ -22,7 +22,7 @@ require 'workflows_controller'
 class WorkflowsController; def rescue_action(e) raise e end; end
 
 class WorkflowsControllerTest < ActionController::TestCase
-  fixtures :roles, :trackers, :workflows, :users
+  fixtures :roles, :trackers, :workflows, :users, :issue_statuses
   
   def setup
     @controller = WorkflowsController.new
@@ -51,18 +51,46 @@ class WorkflowsControllerTest < ActionController::TestCase
   end
   
   def test_get_edit_with_role_and_tracker
+    Workflow.delete_all
+    Workflow.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 2, :new_status_id => 3)
+    Workflow.create!(:role_id => 2, :tracker_id => 1, :old_status_id => 3, :new_status_id => 5)
+    
     get :edit, :role_id => 2, :tracker_id => 1
     assert_response :success
     assert_template 'edit'
+    
+    # used status only
+    assert_not_nil assigns(:statuses)
+    assert_equal [2, 3, 5], assigns(:statuses).collect(&:id)
+    
     # allowed transitions
     assert_tag :tag => 'input', :attributes => { :type => 'checkbox',
-                                                 :name => 'issue_status[2][]',
-                                                 :value => '1',
+                                                 :name => 'issue_status[3][]',
+                                                 :value => '5',
                                                  :checked => 'checked' }
     # not allowed
     assert_tag :tag => 'input', :attributes => { :type => 'checkbox',
-                                                 :name => 'issue_status[2][]',
-                                                 :value => '3',
+                                                 :name => 'issue_status[3][]',
+                                                 :value => '2',
+                                                 :checked => nil }
+    # unused
+    assert_no_tag :tag => 'input', :attributes => { :type => 'checkbox',
+                                                    :name => 'issue_status[4][]' }
+  end
+  
+  def test_get_edit_with_role_and_tracker_and_all_statuses
+    Workflow.delete_all
+    
+    get :edit, :role_id => 2, :tracker_id => 1, :used_statuses_only => '0'
+    assert_response :success
+    assert_template 'edit'
+    
+    assert_not_nil assigns(:statuses)
+    assert_equal IssueStatus.count, assigns(:statuses).size
+    
+    assert_tag :tag => 'input', :attributes => { :type => 'checkbox',
+                                                 :name => 'issue_status[1][]',
+                                                 :value => '1',
                                                  :checked => nil }
   end
   
index efc2aa7ed3e0248885acf0346aa63ee59c383904..f27550aa6d84eec930ff08cc5c88bf75ad5d507f 100644 (file)
@@ -18,7 +18,7 @@
 require File.dirname(__FILE__) + '/../test_helper'
 
 class TrackerTest < ActiveSupport::TestCase
-  fixtures :trackers, :workflows
+  fixtures :trackers, :workflows, :issue_statuses, :roles
 
   def test_copy_workflows
     source = Tracker.find(1)
@@ -30,4 +30,20 @@ class TrackerTest < ActiveSupport::TestCase
     target.reload
     assert_equal 89, target.workflows.size
   end
+  
+  def test_issue_statuses
+    tracker = Tracker.find(1)
+    Workflow.delete_all
+    Workflow.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 2, :new_status_id => 3)
+    Workflow.create!(:role_id => 2, :tracker_id => 1, :old_status_id => 3, :new_status_id => 5)
+    
+    assert_kind_of Array, tracker.issue_statuses
+    assert_kind_of IssueStatus, tracker.issue_statuses.first
+    assert_equal [2, 3, 5], Tracker.find(1).issue_statuses.collect(&:id)
+  end
+  
+  def test_issue_statuses_empty
+    Workflow.delete_all("tracker_id = 1")
+    assert_equal [], Tracker.find(1).issue_statuses
+  end
 end