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

Convert Project Board creation modals to Rails form

Aaron Contrerasfb06f719e0dc
diff --git a/frontend/src/app/features/boards/boards-sidebar/boards-menu.component.ts b/frontend/src/app/features/boards/boards-sidebar/boards-menu.component.ts
index 231529b0843..b52de0fca4d 100644
--- a/frontend/src/app/features/boards/boards-sidebar/boards-menu.component.ts
+++ b/frontend/src/app/features/boards/boards-sidebar/boards-menu.component.ts
@@ -14,7 +14,6 @@ import { ApiV3Service } from 'core-app/core/apiv3/api-v3.service';
import { MainMenuNavigationService } from 'core-app/core/main-menu/main-menu-navigation.service';
import { CurrentUserService } from 'core-app/core/current-user/current-user.service';
import { I18nService } from 'core-app/core/i18n/i18n.service';
-import { NewBoardModalComponent } from 'core-app/features/boards/new-board-modal/new-board-modal.component';
import { OpModalService } from 'core-app/shared/components/modal/modal.service';
import { IOpSidemenuItem } from 'core-app/shared/components/sidemenu/sidemenu.component';
@@ -88,7 +87,11 @@ export class BoardsMenuComponent extends UntilDestroyedMixin implements OnInit {
}
showNewBoardModal():void {
- this.opModalService.show(NewBoardModalComponent, this.injector);
+ const newBoardFormPath = (this.currentProject && this.currentProject.identifier)
+ ? `${window.appBasePath}/projects/${this.currentProject.identifier}/boards/new`
+ : `${window.appBasePath}/boards/new`;
+
+ window.location.href = newBoardFormPath;
}
private focusBackArrow():void {
diff --git a/modules/boards/app/components/boards/add_button_component.rb b/modules/boards/app/components/boards/add_button_component.rb
index d1c122852c2..b07bfdd11bc 100644
--- a/modules/boards/app/components/boards/add_button_component.rb
+++ b/modules/boards/app/components/boards/add_button_component.rb
@@ -40,7 +40,7 @@ module Boards
end
def dynamic_path
- new_work_package_board_path
+ polymorphic_path([:new, current_project, :work_package_board])
end
def id
diff --git a/modules/boards/app/components/boards/row_component.rb b/modules/boards/app/components/boards/row_component.rb
index 5256834460c..f0236e53b6e 100644
--- a/modules/boards/app/components/boards/row_component.rb
+++ b/modules/boards/app/components/boards/row_component.rb
@@ -35,7 +35,7 @@ module Boards
end
def name
- link_to model.name, project_work_package_boards_path(model.project, model)
+ link_to model.name, project_work_package_board_path(model.project, model)
end
def created_at
diff --git a/modules/boards/app/helpers/boards_helper.rb b/modules/boards/app/helpers/boards_helper.rb
index 339650e1706..fdcbf1d6a99 100644
--- a/modules/boards/app/helpers/boards_helper.rb
+++ b/modules/boards/app/helpers/boards_helper.rb
@@ -25,4 +25,8 @@ module BoardsHelper
"assets/images/board_creation_modal/#{image_name}.svg",
disabled)
end
+
+ def global_board_create_context?
+ request.path == new_work_package_board_path
+ 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 34ebc8c3b24..dd3de65dde6 100644
--- a/modules/boards/app/views/boards/boards/_form.html.erb
+++ b/modules/boards/app/views/boards/boards/_form.html.erb
@@ -38,24 +38,26 @@ See COPYRIGHT and LICENSE files for more details.
container_class: '-wide' %>
</div>
- <div class="form--field -required">
- <label class="form--label" for="project_id"><%= Query.human_attribute_name(:project) %>:</label>
- <div class="form--field-container">
- <%= angular_component_tag 'op-project-autocompleter',
- inputs: {
- apiFilters: [['user_action', '=', ['boards/create']]],
- name: 'project_id',
- value: @project,
- appendTo: 'body',
- },
- id: 'project_id',
- class: 'form--select-container -wide remote-field--input',
- data: {
- 'qa-selector': 'project_id'
- }
- %>
+ <% if global_board_create_context? %>
+ <div class="form--field -required">
+ <label class="form--label" for="project_id"><%= Query.human_attribute_name(:project) %>:</label>
+ <div class="form--field-container">
+ <%= angular_component_tag 'op-project-autocompleter',
+ inputs: {
+ apiFilters: [['user_action', '=', ['boards/create']]],
+ name: 'project_id',
+ value: @project,
+ appendTo: 'body',
+ },
+ id: 'project_id',
+ class: 'form--select-container -wide remote-field--input',
+ data: {
+ 'qa-selector': 'project_id'
+ }
+ %>
+ </div>
</div>
- </div>
+ <% end %>
<div class="form--field -required -align-start">
<label class="form--label" for="board_type"><%= t('boards.label_board_type') %></label>
diff --git a/modules/boards/app/views/boards/boards/new.html.erb b/modules/boards/app/views/boards/boards/new.html.erb
index d7fad258621..921875a654a 100644
--- a/modules/boards/app/views/boards/boards/new.html.erb
+++ b/modules/boards/app/views/boards/boards/new.html.erb
@@ -29,9 +29,9 @@ See COPYRIGHT and LICENSE files for more details.
<% html_title t('boards.label_create_new_board') %>
<%= toolbar title: t('boards.label_create_new_board') %>
-<%= labelled_tabular_form_for @board_grid, url: { controller: '/boards/boards', action: 'create' }, :html => {:id => 'board-form'} do |f| -%>
+<%= labelled_tabular_form_for @board_grid, url: { controller: '/boards/boards', action: 'create', project_id: @project }, :html => {:id => 'board-form'} do |f| -%>
<%= render :partial => 'form', :locals => {:f => f} %>
<%= styled_button_tag t(:button_create), class: '-highlight' %>
- <%= link_to t(:button_cancel), { controller: 'boards/boards', action: 'overview' },
+ <%= link_to t(:button_cancel), { controller: 'boards/boards', action: (@project ? 'index' : 'overview') },
class: 'button' %>
<% end %>