Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Add ability to create "Subproject" boards globally

Aaron Contreras6e0f4b2edb7a
diff --git a/modules/boards/app/controllers/boards/boards_controller.rb b/modules/boards/app/controllers/boards/boards_controller.rb
index 2b01c9d8b8f..a983bcf8973 100644
--- a/modules/boards/app/controllers/boards/boards_controller.rb
+++ b/modules/boards/app/controllers/boards/boards_controller.rb
@@ -74,7 +74,8 @@ module ::Boards
'basic' => Boards::BasicBoardCreateService,
'status' => Boards::StatusBoardCreateService,
'assignee' => Boards::AssigneeBoardCreateService,
- 'version' => Boards::VersionBoardCreateService
+ 'version' => Boards::VersionBoardCreateService,
+ 'subproject' => Boards::SubprojectBoardCreateService
}.fetch(board_grid_params[:attribute])
end
diff --git a/modules/boards/app/services/boards/subproject_board_create_service.rb b/modules/boards/app/services/boards/subproject_board_create_service.rb
new file mode 100644
index 00000000000..4f3bccbfb15
--- /dev/null
+++ b/modules/boards/app/services/boards/subproject_board_create_service.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+module Boards
+ class SubprojectBoardCreateService < BaseCreateService
+ private
+
+ def grid_lacks_query?(_params)
+ true
+ end
+
+ def options_for_widgets(_params)
+ []
+ end
+ end
+end
diff --git a/modules/boards/app/views/boards/boards/_form.html.erb b/modules/boards/app/views/boards/boards/_form.html.erb
index 9ea40828dde..5995a733398 100644
--- a/modules/boards/app/views/boards/boards/_form.html.erb
+++ b/modules/boards/app/views/boards/boards/_form.html.erb
@@ -91,5 +91,14 @@ See COPYRIGHT and LICENSE files for more details.
no_label: true,
container_class: '-wide'%>
</div>
+
+ <div class="form--field">
+ <%= f.label 'attribute', t('boards.board_type_attributes.subproject'), value: 'subproject' %>
+ <%= styled_radio_button_tag 'boards_grid[attribute]',
+ 'subproject',
+ no_label: true,
+ container_class: '-wide'%>
+ <%= %>
+ </div>
</div>
</section>
diff --git a/modules/boards/spec/features/boards_global_create_spec.rb b/modules/boards/spec/features/boards_global_create_spec.rb
index 98a41db6bf4..fd4948004d6 100644
--- a/modules/boards/spec/features/boards_global_create_spec.rb
+++ b/modules/boards/spec/features/boards_global_create_spec.rb
@@ -113,6 +113,27 @@ RSpec.describe 'Boards',
end
end
end
+
+ context 'when creating a "Subproject" board' do
+ before do
+ new_board_page.set_board_type 'Subproject'
+ new_board_page.click_on_submit
+
+ wait_for_reload
+ end
+
+ it 'creates the board and redirects me to it' do
+ expect(page).to have_text(I18n.t(:notice_successful_create))
+ expect(page).to have_current_path("/projects/#{project.identifier}/boards/#{Boards::Grid.last.id}")
+ expect(page).to have_text "Gotham Renewal Board"
+ end
+ end
+ it 'creates the board and redirects me to it', :aggregate_failures do
+ expect(page).to have_text(I18n.t(:notice_successful_create))
+ expect(page).to have_current_path("/projects/#{project.identifier}/boards/#{Boards::Grid.last.id}")
+ expect(page).to have_text "Gotham Renewal Board"
+ end
+ end
end
end
end