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

adjusted toggle switch position according to feedback

Jonas Jabari26c91673c208
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 fb574113e04..de2b1c0e17c 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
@@ -1,49 +1,45 @@
<%=
component_wrapper do
- 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|
+ flex_layout(align_items: :center, classes: 'op-project-custom-field', data: {
+ qa_selector: "project-custom-field-#{@project_custom_field.id}"
+ }) do |custom_field_container|
# 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
- @project_custom_field.name
- end
+ custom_field_container.with_column(py: 1, mr: 2) 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: {
+ project_id: @project.id,
+ custom_field_id: @project_custom_field.id
+ }
+ ),
+ csrf_token: form_authenticity_token,
+ data: { 'turbo-method': :put, 'turbo-stream': true,
+ qa_selector: "toggle-project-custom-field-mapping-#{@project_custom_field.id}" },
+ checked: active_in_project?,
+ enabled: !@project_custom_field.required?, # required fields cannot be disabled
+ size: :small,
+ status_label_position: :start
+ ))
+ end
+ custom_field_container.with_column(pt: 1, mr: 2) do
+ render(Primer::Beta::Text.new) do
+ @project_custom_field.name
end
- description_container.with_column(mr: 2, data: { qa_selector: "custom-field-type" } ) do
- render(Primer::Beta::Text.new(font_size: :small, color: :subtle)) do
- @project_custom_field.field_format.capitalize
- end
+ end
+ custom_field_container.with_column(pt: 1, mr: 2, data: { qa_selector: "custom-field-type" } ) do
+ render(Primer::Beta::Text.new(font_size: :small, color: :subtle)) do
+ @project_custom_field.field_format.capitalize
end
end
- custom_field_container.with_column(align_items: :center, flex_layout: true) do |toggle_container|
- if @project_custom_field.required?
- toggle_container.with_column(data: { qa_selector: "custom-field-type" } ) do
- render(Primer::Beta::Label.new(scheme: :attention, size: :medium)) do
- t("label_required")
- end
+ if @project_custom_field.required?
+ custom_field_container.with_column(pt: 1) do
+ render(Primer::Beta::Label.new(scheme: :attention, size: :medium)) do
+ t("label_required")
end
end
- toggle_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: {
- project_id: @project.id,
- custom_field_id: @project_custom_field.id
- }
- ),
- csrf_token: form_authenticity_token,
- data: { 'turbo-method': :put, 'turbo-stream': true,
- qa_selector: "toggle-project-custom-field-mapping-#{@project_custom_field.id}" },
- checked: active_in_project?,
- enabled: !@project_custom_field.required?, # required fields cannot be disabled
- size: :small,
- status_label_position: :start
- ))
- end
end
end
end
diff --git a/app/models/project_custom_field.rb b/app/models/project_custom_field.rb
index accd5426120..539724a4ad3 100644
--- a/app/models/project_custom_field.rb
+++ b/app/models/project_custom_field.rb
@@ -48,7 +48,6 @@ class ProjectCustomField < CustomField
end
# TODO: write specs for this
- # TODO: write migrations for existing required custom fields
def activate_required_field_in_all_projects
return unless required?