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

refined empty section behavior as requested

Jonas Jabarife77f6bb1a3b
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 e87bee27605..bde18fd9458 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
@@ -39,7 +39,24 @@
end
if @project_custom_fields.empty?
component.with_row(data: { 'empty-list-item': true }) do
- render(Primer::Beta::Text.new(color: :subtle)) { t("settings.project_attributes.label_no_project_custom_fields") }
+ flex_layout(align_items: :center, justify_content: :space_between) do |empty_list_container|
+ empty_list_container.with_column(ml: 4, mr: 2) do
+ 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
+ ),
+ scheme: :secondary,
+ data: { turbo: "false"}
+ )) do |button|
+ button.with_leading_visual_icon(icon: :plus)
+ t('settings.project_attributes.label_new_attribute')
+ end
+ end
+ end
end
else
@project_custom_fields.each do |project_custom_field|
diff --git a/app/controllers/admin/settings/project_custom_fields_controller.rb b/app/controllers/admin/settings/project_custom_fields_controller.rb
index 430712d7a35..67317050e22 100644
--- a/app/controllers/admin/settings/project_custom_fields_controller.rb
+++ b/app/controllers/admin/settings/project_custom_fields_controller.rb
@@ -54,7 +54,7 @@ module Admin::Settings
end
def new
- @custom_field = ProjectCustomField.new
+ @custom_field = ProjectCustomField.new(custom_field_section_id: params[:custom_field_section_id])
respond_to :html
end
diff --git a/config/locales/en.yml b/config/locales/en.yml
index ecf07ecdd56..e84bba3711c 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -2963,6 +2963,7 @@ Project attributes and sections are defined in the <a href=%{admin_settings_url}
label_section_actions: "Section actions"
heading_description: "These project attributes appear in the project overview of each project. You can add new attributes and group them into sections. Individual attributes can be enabled or disabled at a project level."
label_project_custom_field_actions: "Project attribute actions"
+ label_no_project_custom_fields: "No project attributes defined in this section"
edit:
description: "Set the details of the project attribute that will be selectable by project administrators in each individual project settings."
new: