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

cleanup

Jonas Jabari8eb4c1578dc1
diff --git a/app/components/projects/settings/project_custom_field_sections/custom_field_row_component.html.erb b/app/components/projects/settings/project_custom_field_sections/custom_field_row_component.html.erb
index 27115cc850f..bc485e076a4 100644
--- a/app/components/projects/settings/project_custom_field_sections/custom_field_row_component.html.erb
+++ b/app/components/projects/settings/project_custom_field_sections/custom_field_row_component.html.erb
@@ -3,8 +3,7 @@
flex_layout(align_items: :center, justify_content: :space_between, classes: 'op-project-custom-field', data: {
qa_selector: "project-custom-field-#{@project_custom_field.id}"
}) do |custom_field_container|
- # prototypical implementation of the toggle button in order to review with the team
- # TODO: once finally decided, it needs refactoring
+ # py: 1 quick fix: prevents the row from bouncing as the toggle switch currently changes height while toggling
custom_field_container.with_column(py: 1, flex_layout: true) do |description_container|
description_container.with_column(mr: 2) do
render(Primer::Beta::Text.new) do
@@ -17,7 +16,10 @@
end
end
end
- custom_field_container.with_column() do
+ custom_field_container.with_column() do
+ # buggy currently:
+ # small variant + status_label_position: :start leads to a small bounce while toggling
+ # behavior can be seen on primer's viewbook as well -> https://view-components-storybook.eastus.cloudapp.azure.com/view-components/lookbook/inspect/primer/alpha/toggle_switch/small
render(Primer::Alpha::ToggleSwitch.new(
src: toggle_project_settings_project_custom_fields_path(
project_custom_field_project_mapping: {
diff --git a/app/controllers/projects/settings/project_custom_fields_controller.rb b/app/controllers/projects/settings/project_custom_fields_controller.rb
index d5c64d2349b..728fd88f106 100644
--- a/app/controllers/projects/settings/project_custom_fields_controller.rb
+++ b/app/controllers/projects/settings/project_custom_fields_controller.rb
@@ -37,7 +37,6 @@ class Projects::Settings::ProjectCustomFieldsController < Projects::SettingsCont
before_action :eager_load_project_custom_field_project_mappings,
only: %i[show toggle enable_all_of_section disable_all_of_section]
- before_action :set_project_custom_field, only: %i[toggle]
before_action :set_project_custom_field_section, only: %i[enable_all_of_section disable_all_of_section]
def show; end
@@ -47,15 +46,12 @@ class Projects::Settings::ProjectCustomFieldsController < Projects::SettingsCont
.new(user: current_user)
.call(permitted_params.project_custom_field_project_mapping)
+ # we don't need to rerender a component as the toggle switch shows the correct state base on a successful response
if call.success?
- eager_load_project_custom_field_project_mappings # reload mappings
-
- update_custom_field_row_via_turbo_stream
+ render json: {}, status: :ok
else
- # TODO: handle error
+ render json: {}, status: :unprocessable_entity
end
-
- respond_with_turbo_streams
end
def enable_all_of_section
@@ -105,13 +101,6 @@ class Projects::Settings::ProjectCustomFieldsController < Projects::SettingsCont
.to_a
end
- def set_project_custom_field
- # required for component rerenderings
- @project_custom_field = ProjectCustomField.find(
- permitted_params.project_custom_field_project_mapping[:custom_field_id]
- )
- end
-
def set_project_custom_field_section
@project_custom_field_section = ProjectCustomFieldSection.find(
permitted_params.project_custom_field_project_mapping[:custom_field_section_id]