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

[Op#57515]: Set up first base view for custom field projects

Kabiru Mwenja96bf91acf6da
diff --git a/app/controllers/admin/custom_fields/custom_field_projects_controller.rb b/app/controllers/admin/custom_fields/custom_field_projects_controller.rb
index 1e067876492..99b51b37db2 100644
--- a/app/controllers/admin/custom_fields/custom_field_projects_controller.rb
+++ b/app/controllers/admin/custom_fields/custom_field_projects_controller.rb
@@ -38,7 +38,15 @@ class Admin::CustomFields::CustomFieldProjectsController < ApplicationController
menu_item :custom_fields
- def index; end
+ def index
+ @available_project_custom_fields_query = ProjectQuery.new(
+ name: "custom-fields-projects-#{@custom_field.id}"
+ ) do |query|
+ query.where(:available_project_custom_fields, "=", [@custom_field.id])
+ query.select(:name)
+ query.order("lft" => "asc")
+ end
+ end
private
diff --git a/app/views/admin/custom_fields/custom_field_projects/index.html.erb b/app/views/admin/custom_fields/custom_field_projects/index.html.erb
index d5f9e0d0ff7..2c081b199f4 100644
--- a/app/views/admin/custom_fields/custom_field_projects/index.html.erb
+++ b/app/views/admin/custom_fields/custom_field_projects/index.html.erb
@@ -33,3 +33,18 @@ See COPYRIGHT and LICENSE files for more details.
render(Admin::CustomFields::EditFormHeaderComponent.new(custom_field: @custom_field,
selected: :custom_field_projects))
%>
+
+<%=
+ if @custom_field.is_for_all?
+ render Primer::Beta::Blankslate.new(border: true) do |component|
+ component.with_visual_icon(icon: :checklist)
+ component.with_heading(tag: :h2).with_content(I18n.t("projects.settings.project_custom_fields.is_required_blank_slate.heading"))
+ component.with_description { I18n.t("projects.settings.project_custom_fields.is_required_blank_slate.description") }
+ end
+ else
+ render(Admin::CustomFields::CustomFieldProjects::TableComponent.new(
+ query: @available_project_custom_fields_query,
+ params: params.merge({ custom_field: @custom_field }))
+ )
+ end
+%>