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

[#65074] Offer project attribute format selection for section

Tobias Dillmann521b60c138d3
diff --git a/app/components/settings/project_custom_field_sections/show_component.html.erb b/app/components/settings/project_custom_field_sections/show_component.html.erb
index 704d7e22a8d..1128d8b2698 100644
--- a/app/components/settings/project_custom_field_sections/show_component.html.erb
+++ b/app/components/settings/project_custom_field_sections/show_component.html.erb
@@ -46,18 +46,22 @@
render(Primer::Beta::Text.new(color: :subtle)) { t("settings.project_attributes.label_no_project_custom_fields") }
end
empty_list_container.with_column do
- render(
- Primer::Beta::Button.new(
- tag: :a,
- href: new_admin_settings_project_custom_field_path(
- type: "ProjectCustomField", custom_field_section_id: @project_custom_field_section.id
- ),
+ render(Primer::Alpha::ActionMenu.new(data: { test_selector: "new-project-custom-field-button" })) do |menu|
+ menu.with_show_button(
scheme: :secondary,
- data: { turbo: "false", test_selector: "new-project-custom-field-button" }
- )
- ) do |button|
- button.with_leading_visual_icon(icon: :plus)
- t("settings.project_attributes.label_new_attribute")
+ "aria-label": t("settings.project_attributes.label_new_attribute")
+ ) do |btn|
+ btn.with_leading_visual_icon(icon: :plus)
+ btn.with_trailing_visual_icon(icon: :"triangle-down")
+
+ t("settings.project_attributes.label_new_attribute")
+ end
+
+ OpenProject::CustomFieldFormat.available_for_class_name("Project")
+ .sort_by(&:name)
+ .map do |format|
+ action_menu_item_for_custom_field_format(menu, format)
+ end
end
end
end
diff --git a/app/components/settings/project_custom_field_sections/show_component.rb b/app/components/settings/project_custom_field_sections/show_component.rb
index d2e1ee86a50..f41488640c4 100644
--- a/app/components/settings/project_custom_field_sections/show_component.rb
+++ b/app/components/settings/project_custom_field_sections/show_component.rb
@@ -137,6 +137,19 @@ module Settings
@project_custom_field_section.last?
end
end
+
+ def action_menu_item_for_custom_field_format(menu, format)
+ menu.with_item(
+ label: helpers.label_for_custom_field_format(format.name),
+ tag: :a,
+ href: new_admin_settings_project_custom_field_path(
+ field_format: format.name,
+ custom_field_section_id: @project_custom_field_section.id
+ ),
+ content_arguments: { data: { turbo: "false",
+ test_selector: "new-project-custom-field-button" } }
+ )
+ end
end
end
end