Permalink
Browse files

[#6310] Change how project_level and rollup works

They are now two separate options so you can now:

* show each project (no rollup)
* roll up sub-project to a higher level (rollup and project_level > 0)
* roll up all project into a single project (rollup and project_level = 0)
  • Loading branch information...
edavis10 committed Aug 15, 2011
1 parent 447d447 commit f11108cba050ada120e9f7df35e5f73bbcd0cf87
View
@@ -223,6 +223,8 @@ def projects
def has_issues_for_project_and_user?(project, user)
opts = {:user => user, :project => project}
+ return true if opts[:project].respond_to?("fake_root?") && opts[:project].fake_root?
+
# TODO: should be refactored to use enum#any?
return true if testing_issues_for(opts).length > 0
return true if active_issues_for(opts).length > 0
@@ -249,7 +251,8 @@ def project_level
end
def roll_up_projects?
- project_level > 0
+ rollup = Setting.plugin_redmine_kanban['rollup'].to_i if Setting.plugin_redmine_kanban['rollup'].present?
+ rollup == 1
end
def filter_issues(issues, filters = {})
@@ -377,7 +380,8 @@ def move_current_user_to_front
#
# Recursive
def roll_up_projects_to_project_level(projects)
- return projects if project_level == 0
+ return projects unless roll_up_projects?
+ return [root_project] if project_level == 0
projects.inject([]) {|filtered, project|
if project.level >= project_level
@@ -389,4 +393,24 @@ def roll_up_projects_to_project_level(projects)
}
end
+ # Returns a mock project that acts as the "root" project, where
+ # every other project descends from
+ def root_project
+ # Using a large rgt so this project wraps everything
+ root_project = Project.new(:name => 'Projects',
+ :lft => 1, :rgt => 2147483647)
+ def root_project.fake_root?
+ true
+ end
+ def root_project.is_descendant_of?(project)
+ false
+ end
+ def root_project.left
+ 1
+ end
+ def root_project.right
+ 2147483647
+ end
+ root_project
+ end
end
@@ -20,12 +20,29 @@
</p>
<p>
+ <%= content_tag(:label, l(:kanban_label_enable_rollup)) %>
+ <%= check_box_tag("settings[rollup]", "1", @settings['rollup'].to_s == "1" ) %>
+ </p>
+
+ <p id="rollup">
<%= content_tag(:label, l(:kanban_label_project_level)) %>
<%= text_field_tag("settings[project_level]", @settings['project_level']) %>
<br />
<%= content_tag(:span, l(:kanban_text_project_level_help)) %>
</p>
-
+ <script type="text/javascript">
+ function toggleRollUp() {
+ if ($('settings_rollup').checked) {
+ $('rollup').slideDown();
+ $("settings_project_level").enable();
+ } else {
+ $('rollup').slideUp();
+ $("settings_project_level").disable();
+ }
+ }
+ toggleRollUp();
+ </script>
+ <%= observe_field('settings_rollup', :function => "toggleRollUp();") %>
<p>
<%= content_tag(:label, l(:kanban_label_simple_issue_popup_form)) %>
<%= check_box_tag("settings[simple_issue_popup_form]", "1", @settings['simple_issue_popup_form'].to_s == "1" ) %>
View
@@ -77,3 +77,4 @@ en:
kanban_label_reverse_pane_order: "Reverse pane order"
field_kanban_reverse_pane_order: "Reverse Kanban pane order"
kanban_text_reverse_pane_order_help: "Reverses the workflow so it goes from Right to Left (default is Left to Right)"
+ kanban_label_enable_rollup: "Enable project rollup?"
View
@@ -57,6 +57,7 @@
'staff_role' => nil,
'user_help' => "_Each list is a Pane of issues. The issues can be dragged and dropped onto other panes based on Roles and Permissions settings._",
'project_level' => 0,
+ 'rollup' => 0,
'simple_issue_popup_form' => 0,
'reverse_pane_order' => 0,
'panels' => {
@@ -3,7 +3,7 @@
class MyRequestsTest < ActionController::IntegrationTest
def setup
Setting.clear_cache
- configure_plugin
+ configure_plugin({'rollup' => "0", 'project_level' => '0'})
setup_kanban_issues
end
@@ -221,8 +221,97 @@ def setup
end
end
+ should "group issues under the all project with a project_level of 0 (one bucket)" do
+ configure_plugin({'rollup' => "1", 'project_level' => '0'})
+
+ @subproject = Project.generate!
+ assert @subproject.set_parent!(@project)
+ assert_equal @project, @subproject.parent
+ @project.reload
+ @subproject.reload
+ Member.generate!({:principal => @user, :project => @subproject, :roles => [@role]})
+
+ @new_issue1 = Issue.generate_for_project!(@subproject, :author => @user, :status => @new_status)
+ @testing_issue1 = Issue.generate_for_project!(@subproject, :author => @user, :status => @testing_status)
+ @active_issue1 = Issue.generate_for_project!(@subproject, :author => @user, :status => @active_status)
+ @selected_issue1 = Issue.generate_for_project!(@subproject, :author => @user, :status => @selected_status)
+ @backlog_issue1 = Issue.generate_for_project!(@subproject, :author => @user, :status => @unstaffed_status, :estimated_hours => 5)
+ @finished_issue = Issue.generate_for_project!(@subproject, :author => @user, :status => @finished_status)
+ @canceled_issue = Issue.generate_for_project!(@subproject, :author => @user, :status => @canceled_status)
+
+ login_as
+ visit_my_kanban_requests
+
+ # Don't show any projects
+ assert_select '#kanban' do
+ assert_select '.project-lane h2.project-name', :text => /#{@project.name}/, :count => 0
+ assert_select '.project-lane h2.project-name', :text => /#{@subproject.name}/, :count => 0
+ end
+
+ # New lane
+ assert_select '#new-requests' do
+ assert_select "#user-kanban-show-incoming" do
+ assert_select 'span.loading'
+ end
+ end
+
+ # Testing lane
+ assert_select '#kanban' do
+ assert_select '.project-lane' do
+ assert_select "#user-kanban-show-testing-project-" do
+ assert_select 'span.loading'
+ end
+ end
+ end
+
+ # Active lane
+ assert_select '#kanban' do
+ assert_select '.project-lane' do
+ assert_select "#user-kanban-show-active-project-" do
+ assert_select 'span.loading'
+ end
+ end
+ end
+
+ # Selected lane
+ assert_select '#kanban' do
+ assert_select '.project-lane' do
+ assert_select "#user-kanban-show-selected-project-" do
+ assert_select 'span.loading'
+ end
+ end
+ end
+
+ # Backlog lane
+ assert_select '#kanban' do
+ assert_select '.project-lane' do
+ assert_select "#user-kanban-show-backlog-project-" do
+ assert_select 'span.loading'
+ end
+ end
+ end
+
+ # Finished lane
+ assert_select '#kanban' do
+ assert_select '.project-lane' do
+ assert_select "#finished-issues-user-#{@user.id}-project-.finished-issues" do
+ assert_select "li#issue_#{@finished_issue.id}", :count => 1
+ end
+ end
+ end
+
+ # Canceled lane
+ assert_select '#kanban' do
+ assert_select '.project-lane' do
+ assert_select "#canceled-issues-user-#{@user.id}-project-.canceled-issues" do
+ assert_select "li#issue_#{@canceled_issue.id}", :count => 1
+ end
+ end
+ end
+ end
+
should "group issues under the parent project with a project_level of 1" do
- configure_plugin({'project_level' => '1'})
+ configure_plugin({'rollup' => "1", 'project_level' => '1'})
@subproject = Project.generate!
assert @subproject.set_parent!(@project)
@@ -314,7 +403,7 @@ def setup
end
end
-
+
should "group each horizontal lane by project" do
login_as
Issue.generate_for_project!(@project, :author => @user, :status => @active_status)
View
@@ -72,6 +72,7 @@ def configure_plugin(configuration_change = {})
"staff_role"=> make_kanban_role.id,
"management_group"=> @management_group.id.to_s,
"project_level" => "0",
+ "rollup" => "0",
"reverse_pane_order" => "0",
"panels" =>
{

0 comments on commit f11108c

Please sign in to comment.