By default, only show statuses that are used by the tracker on the workflow edit view.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3188 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
6a369f28dd
commit
6bf0723d06
|
@ -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
|
||||
|
|
|
@ -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])
|
||||
|
|
|
@ -11,8 +11,12 @@
|
|||
|
||||
<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 %>
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -886,3 +886,4 @@
|
|||
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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -856,3 +856,4 @@
|
|||
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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -876,3 +876,4 @@
|
|||
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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -954,3 +954,4 @@
|
|||
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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue