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

[#61619] removed error banner for work package type forms

Eric Schubert18b9352e9473
diff --git a/app/components/work_packages/types/settings_component.rb b/app/components/work_packages/types/settings_component.rb
index 948af9a38df..97699f45cf6 100644
--- a/app/components/work_packages/types/settings_component.rb
+++ b/app/components/work_packages/types/settings_component.rb
@@ -56,7 +56,7 @@ module WorkPackages
end
def update_form_options
- { url: type_path(id: model.id), method: :patch, model: }
+ { url: update_tab_type_path(id: model.id, tab: :settings), method: :patch, model: }
end
end
end
diff --git a/app/controllers/types_controller.rb b/app/controllers/types_controller.rb
index 57f61b72196..b7f5af4f812 100644
--- a/app/controllers/types_controller.rb
+++ b/app/controllers/types_controller.rb
@@ -53,11 +53,7 @@ class TypesController < ApplicationController
if params[:tab].blank?
redirect_to tab: :settings
else
- type = ::Type
- .includes(:projects,
- :custom_fields)
- .find(params[:id])
-
+ type = ::Type.includes(:projects, :custom_fields).find(params[:id])
render_edit_tab(type)
end
end
@@ -82,14 +78,8 @@ class TypesController < ApplicationController
UpdateTypeService
.new(@type, current_user)
.call(permitted_type_params) do |call|
- call.on_success do
- redirect_to_type_tab_path(@type, t(:notice_successful_update))
- end
-
- call.on_failure do |result|
- flash[:error] = result.errors.full_messages.join("\n")
- render_edit_tab(@type, status: :unprocessable_entity)
- end
+ call.on_success { redirect_to_type_tab_path(@type, t(:notice_successful_update)) }
+ call.on_failure { render_edit_tab(@type, status: :unprocessable_entity) }
end
end
diff --git a/app/controllers/work_packages/types/subject_configuration_controller.rb b/app/controllers/work_packages/types/subject_configuration_controller.rb
index 240686626aa..4c5d8a6d322 100644
--- a/app/controllers/work_packages/types/subject_configuration_controller.rb
+++ b/app/controllers/work_packages/types/subject_configuration_controller.rb
@@ -48,7 +48,7 @@ module WorkPackages
end
call.on_failure do
- @default_tab = "subject_configuration"
+ params[:tab] = "subject_configuration"
render template: "types/edit", status: :unprocessable_entity
end
end
diff --git a/app/helpers/tabs_helper.rb b/app/helpers/tabs_helper.rb
index df8228f2e6f..bbb1ed2e6c6 100644
--- a/app/helpers/tabs_helper.rb
+++ b/app/helpers/tabs_helper.rb
@@ -39,10 +39,8 @@ module TabsHelper
end
end
- def selected_tab(tabs, default_tab = nil)
- tabs.detect { |t| t[:name] == params[:tab] } ||
- tabs.detect { |t| t[:name] == default_tab } ||
- tabs.first
+ def selected_tab(tabs)
+ tabs.detect { |t| t[:name] == params[:tab] } || tabs.first
end
def tabs_for_key(key, params = {})
diff --git a/app/views/types/edit.html.erb b/app/views/types/edit.html.erb
index abc54020da3..d8f4a99c7d9 100644
--- a/app/views/types/edit.html.erb
+++ b/app/views/types/edit.html.erb
@@ -31,10 +31,10 @@ See COPYRIGHT and LICENSE files for more details.
<% tabs = types_tabs %>
-<%= render ::Types::EditPageHeaderComponent.new(type: @type, tabs: tabs) %>
+<%= render Types::EditPageHeaderComponent.new(type: @type, tabs:) %>
<%=
- selected_tab = selected_tab(tabs, @default_tab)
+ selected_tab = selected_tab(tabs)
if selected_tab.key?(:view_component)
render selected_tab[:view_component].new(@type)
@@ -47,6 +47,3 @@ See COPYRIGHT and LICENSE files for more details.
end
end
%>
-
-<!-- Remove those once all tab contents are using view components -->
-<%= error_messages_for "type" %>