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
dirty implementation for action menu custom field format selection
ulfertsee0e78c69b2d
diff --git a/app/components/settings/project_custom_fields/header_component.html.erb b/app/components/settings/project_custom_fields/header_component.html.erbindex f422563940c..0e247a94b75 100644--- a/app/components/settings/project_custom_fields/header_component.html.erb+++ b/app/components/settings/project_custom_fields/header_component.html.erb@@ -28,13 +28,19 @@content_arguments: { data: { controller: "async-dialog" } })- menu.with_item(- label: t("settings.project_attributes.label_new_attribute"),- tag: :a,- href: new_admin_settings_project_custom_field_path(type: "ProjectCustomField"),- content_arguments: { data: { turbo: "false",- test_selector: "new-project-custom-field-button" } }- )+ menu.with_divider++ OpenProject::CustomFieldFormat.all_for_class_name("Project")+ .sort_by(&:name)+ .map do |format|+ menu.with_item(+ label: "#{t('settings.project_attributes.label_new_attribute')}: #{helpers.label_for_custom_field_format(format.name)}",+ tag: :a,+ href: new_admin_settings_project_custom_field_path(field_format: format.name),+ content_arguments: { data: { turbo: "false",+ test_selector: "new-project-custom-field-button" } }+ )+ endendend%>diff --git a/app/components/settings/project_custom_fields/header_component.rb b/app/components/settings/project_custom_fields/header_component.rbindex 80ef7e28952..317c6fa5555 100644--- a/app/components/settings/project_custom_fields/header_component.rb+++ b/app/components/settings/project_custom_fields/header_component.rb@@ -32,6 +32,7 @@ module Settingsinclude ApplicationHelperinclude OpPrimer::ComponentHelpersinclude OpTurbo::Streamable+ include CustomFieldsHelperdef breadcrumbs_items[{ href: admin_index_path, text: t("label_administration") },diff --git a/app/controllers/admin/settings/project_custom_fields_controller.rb b/app/controllers/admin/settings/project_custom_fields_controller.rbindex 8a2b082630f..26ad1d3caf7 100644--- a/app/controllers/admin/settings/project_custom_fields_controller.rb+++ b/app/controllers/admin/settings/project_custom_fields_controller.rb@@ -59,7 +59,8 @@ module Admin::Settingsenddef new- @custom_field = ProjectCustomField.new(custom_field_section_id: params[:custom_field_section_id])+ @custom_field = ProjectCustomField.new(custom_field_section_id: params[:custom_field_section_id],+ field_format: params[:field_format])respond_to :htmlenddiff --git a/app/controllers/concerns/custom_fields/shared_actions.rb b/app/controllers/concerns/custom_fields/shared_actions.rbindex 0c1b9553772..d02ad148891 100644--- a/app/controllers/concerns/custom_fields/shared_actions.rb+++ b/app/controllers/concerns/custom_fields/shared_actions.rb@@ -116,7 +116,9 @@ module CustomFieldsenddef new_custom_field- ::CustomFields::CreateService.careful_new_custom_field(permitted_params.custom_field_type)+ field = ::CustomFields::CreateService.careful_new_custom_field(permitted_params.custom_field_type)+ field.field_format = params[:field_format]+ fieldenddef get_custom_field_paramsdiff --git a/app/views/custom_fields/index.html.erb b/app/views/custom_fields/index.html.erbindex 8ad43c64e81..1938c80f811 100644--- a/app/views/custom_fields/index.html.erb+++ b/app/views/custom_fields/index.html.erb@@ -33,14 +33,25 @@ See COPYRIGHT and LICENSE files for more details.<%=render(Primer::OpenProject::SubHeader.new) do |subheader|- subheader.with_action_button(+ subheader.with_action_menu(scheme: :primary,leading_icon: :plus,- label: t(:label_custom_field_new),- tag: :a,- href: new_custom_field_path(type: selected_tab(custom_fields_tabs)[:name])- ) do- t("activerecord.models.custom_field")+ trailing_icon: :"triangle-down",+ label: I18n.t(:label_custom_field_new),+ button_arguments: {+ scheme: :primary,+ aria: { label: I18n.t(:label_custom_field_new) }+ }+ ) do |menu|+ OpenProject::CustomFieldFormat.all_for_class_name(@tab.delete_suffix("CustomField"))+ .sort_by(&:name)+ .map do |format|+ menu.with_item(+ label: label_for_custom_field_format(format.name),+ tag: :a,+ href: new_custom_field_path(type: selected_tab(custom_fields_tabs)[:name], field_format: format.name)+ )+ endendend%>