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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
switched to primer's toggle component on mapping UI
Jonas Jabari87c79792ba4e
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.erbindex 279fd228417..7e671f3d0ff 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,14 +3,25 @@flex_layout(align_items: :center, classes: 'op-project-custom-field', data: {qa_selector: "project-custom-field-#{@project_custom_field.id}"}) do |custom_field_container|- custom_field_container.with_column(mr: 1) do- toggle_button- end- custom_field_container.with_column(data: { qa_selector: "custom-field-type" } ) do- render(Primer::Beta::Text.new(font_size: :small, color: :subtle)) do- @project_custom_field.field_format.capitalize+ # prototypical implementation of the toggle button in order to review with the team+ # TODO: once finally decided, it needs refactoring+ custom_field_container.with_column(style: "width: 245px;", flex_layout: true) do |description_container|+ description_container.with_column(mr: 2) do+ render(Primer::Beta::Truncate.new) do |component|+ component.with_item(max_width: 170) do+ @project_custom_field.name+ end+ end+ end+ description_container.with_column(data: { qa_selector: "custom-field-type" } ) do+ render(Primer::Beta::Text.new(font_size: :small, color: :subtle)) do+ @project_custom_field.field_format.capitalize+ endendend+ custom_field_container.with_column do+ toggle_button+ endendend%>diff --git a/app/components/projects/settings/project_custom_field_sections/custom_field_row_component.rb b/app/components/projects/settings/project_custom_field_sections/custom_field_row_component.rbindex 4139e73509a..551cbec465e 100644--- a/app/components/projects/settings/project_custom_field_sections/custom_field_row_component.rb+++ b/app/components/projects/settings/project_custom_field_sections/custom_field_row_component.rb@@ -55,21 +55,20 @@ module Projectsenddef toggle_button- render(Primer::Beta::Button.new(- tag: :a,- href: toggle_project_settings_project_custom_fields_path(+ render(Primer::Alpha::ToggleSwitch.new(+ src: toggle_project_settings_project_custom_fields_path(project_custom_field_project_mapping: {project_id: @project.id,custom_field_id: @project_custom_field.id}),- scheme: :invisible,+ csrf_token: form_authenticity_token,data: { 'turbo-method': :put, 'turbo-stream': true,- qa_selector: "toggle-project-custom-field-mapping-#{@project_custom_field.id}" }- )) do |button|- button.with_leading_visual_icon(icon: (active_in_project? ? 'check-circle' : 'circle'))- @project_custom_field.name- end+ qa_selector: "toggle-project-custom-field-mapping-#{@project_custom_field.id}" },+ checked: active_in_project?,+ size: :small,+ status_label_position: :end+ ))endendenddiff --git a/config/routes.rb b/config/routes.rbindex 60da8f8b193..a615d1313e5 100644--- a/config/routes.rb+++ b/config/routes.rb@@ -191,7 +191,7 @@ OpenProject::Application.routes.draw doresource :types, only: %i[show update]resource :project_custom_fields, only: %i[show] domember do- put :toggle+ post :toggleendcollection doput :enable_all_of_sectiondiff --git a/spec/features/projects/project_custom_fields/settings/mapping_spec.rb b/spec/features/projects/project_custom_fields/settings/mapping_spec.rbindex f1bf221ad04..a3ef7368c56 100644--- a/spec/features/projects/project_custom_fields/settings/mapping_spec.rb+++ b/spec/features/projects/project_custom_fields/settings/mapping_spec.rb@@ -106,7 +106,7 @@ RSpec.describe 'Projects custom fields mapping via project settings', :js, :withvisit project_settings_general_path(project)within '#menu-sidebar' do- expect(page).not_to have_css("li[data-name='settings_project_custom_fields']")+ expect(page).to have_no_css("li[data-name='settings_project_custom_fields']")endend@@ -128,7 +128,7 @@ RSpec.describe 'Projects custom fields mapping via project settings', :js, :withvisit project_settings_general_path(project)within '#menu-sidebar' do- expect(page).not_to have_css("li[data-name='settings_project_custom_fields']")+ expect(page).to have_no_css("li[data-name='settings_project_custom_fields']")endendend@@ -182,7 +182,7 @@ RSpec.describe 'Projects custom fields mapping via project settings', :js, :withwithin_custom_field_container(boolean_project_custom_field) doexpect_unchecked_state- page.find("[data-qa-selector='toggle-project-custom-field-mapping-#{boolean_project_custom_field.id}']").click+ page.find("[data-qa-selector='toggle-project-custom-field-mapping-#{boolean_project_custom_field.id}'] > button").clickexpect_checked_state # without reloading the pageend@@ -275,15 +275,15 @@ RSpec.describe 'Projects custom fields mapping via project settings', :js, :withwithin_custom_field_section_container(section_for_input_fields) doexpect(page).to have_content('Boolean field')- expect(page).not_to have_content('String field')+ expect(page).to have_no_content('String field')endwithin_custom_field_section_container(section_for_select_fields) do- expect(page).not_to have_content('List field')+ expect(page).to have_no_content('List field')endwithin_custom_field_section_container(section_for_multi_select_fields) do- expect(page).not_to have_content('Multi list field')+ expect(page).to have_no_content('Multi list field')endend@@ -346,11 +346,11 @@ RSpec.describe 'Projects custom fields mapping via project settings', :js, :withenddef expect_checked_state- expect(page).to have_css('.octicon-check-circle')+ expect(page).to have_css('.ToggleSwitch-statusOn')enddef expect_unchecked_state- expect(page).to have_css('.octicon-circle')+ expect(page).to have_css('.ToggleSwitch-statusOff')enddef within_custom_field_section_container(section, &)