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
Address CR comments.
Dombi Attila43f612f1d119
diff --git a/docs/api/apiv3/components/schemas/projects_schema_model.yml b/docs/api/apiv3/components/schemas/projects_schema_model.ymlindex f920c6e9ea4..4e2cf39eaa7 100644--- a/docs/api/apiv3/components/schemas/projects_schema_model.yml+++ b/docs/api/apiv3/components/schemas/projects_schema_model.yml@@ -21,6 +21,9 @@ properties:type: stringenum: [ProjectFormCustomFieldSection]description: The type identifier for this resource+ id:+ type: integer+ description: The unique identifier of the custom field sectionname:type: stringdescription: The human-readable name of the custom field sectiondiff --git a/docs/development/concepts/resource-schemas/README.md b/docs/development/concepts/resource-schemas/README.mdindex fb3fe11f487..b430db4831f 100644--- a/docs/development/concepts/resource-schemas/README.md+++ b/docs/development/concepts/resource-schemas/README.md@@ -72,10 +72,10 @@ This results in work package schemas being defined per project and type combinatAn exemplary schema response on the Community for the OpenProject project (`ID=14`) and the Bug type (`ID=1`) is [community.openproject.org/api/v3/work_packages/schemas/14-1](https://community.openproject.org/api/v3/work_packages/schemas/14-1)-The work package schema also contains the reference to the attribute groups from the form configuration in the `_attributeGroups` property.--The project schema also contains the reference the project attribute sections and their project attributes in the `_attributeGroups` property.+Work package and project schemas contain references to their respective attribute groups in the `_attributeGroups` property:+- Work package schemas reference attribute groups from the form configuration+- Project schemas reference project attribute sections and their project attributes## Frontend usagediff --git a/lib/api/v3/projects/schemas/project_custom_field_section_representer.rb b/lib/api/v3/projects/schemas/project_custom_field_section_representer.rbindex c73a92e6b5c..0f86302c85b 100644--- a/lib/api/v3/projects/schemas/project_custom_field_section_representer.rb+++ b/lib/api/v3/projects/schemas/project_custom_field_section_representer.rb@@ -33,6 +33,9 @@ module APImodule Projectsmodule Schemasclass ProjectCustomFieldSectionRepresenter < ::API::Decorators::Single+ property :id,+ exec_context: :decorator+property :name,exec_context: :decorator@@ -43,7 +46,7 @@ module API"ProjectFormCustomFieldSection"end- delegate :name, to: :represented+ delegate :id, :name, to: :representeddef attributesrepresented.custom_fields.map do |cf|@@ -51,8 +54,8 @@ module APIendend- def convert_property(attribute)- ::API::Utilities::PropertyNameConverter.from_ar_name(attribute)+ def convert_property(attribute_name)+ ::API::Utilities::PropertyNameConverter.from_ar_name(attribute_name)endendenddiff --git a/lib/api/v3/projects/schemas/project_schema_representer.rb b/lib/api/v3/projects/schemas/project_schema_representer.rbindex d2744a762c6..b9e412d592c 100644--- a/lib/api/v3/projects/schemas/project_schema_representer.rb+++ b/lib/api/v3/projects/schemas/project_schema_representer.rb@@ -113,7 +113,6 @@ module API# However caching is still applied further down in the `section_representation` method.property :attribute_groups,name_source: ->(*) { I18n.t("activerecord.attributes.project.attribute_groups") },- type: "[]String",as: "_attributeGroups",exec_context: :decorator,uncacheable: true@@ -122,13 +121,6 @@ module APIdef represented_class::Projectend-- def attribute_group(property)- lambda do- key = property.to_s- attribute_group_map key- end- endenddef attribute_groups@@ -137,20 +129,6 @@ module APIendend- ##- # Return a map of attribute => group name- def attribute_group_map(key)- return nil if project_custom_field_sections.empty?-- @attribute_group_map ||= project_custom_field_sections.each_with_object({}) do |section, hash|- section.custom_fields.each do |cf|- hash[cf.attribute_name(:camel_case)] = section.name- end- end-- @attribute_group_map[key]- end-privatedef project_custom_field_sections@@ -164,9 +142,8 @@ module APIdef section_representation(section)OpenProject::Cache.fetch(*section_cache_key(section)) do- ::JSON::parse(::API::V3::Projects::Schemas::ProjectCustomFieldSectionRepresenter- .new(section, current_user:, embed_links: true)- .to_json)+ ::API::V3::Projects::Schemas::ProjectCustomFieldSectionRepresenter+ .new(section, current_user:)endenddiff --git a/spec/lib/api/v3/projects/schemas/project_schema_representer_spec.rb b/spec/lib/api/v3/projects/schemas/project_schema_representer_spec.rbindex 287e076df1a..498d9cbdc85 100644--- a/spec/lib/api/v3/projects/schemas/project_schema_representer_spec.rb+++ b/spec/lib/api/v3/projects/schemas/project_schema_representer_spec.rb@@ -131,13 +131,16 @@ RSpec.describe API::V3::Projects::Schemas::ProjectSchemaRepresenter doit "renders section attribute group elements of the schema" doexpect(subject).to be_json_eql(- {- _type: "ProjectFormCustomFieldSection",- name: "Common Project Attributes",- attributes: ["customField#{user_custom_field.id}"]- }.to_json+ [+ {+ _type: "ProjectFormCustomFieldSection",+ id: user_section.id,+ name: "Common Project Attributes",+ attributes: ["customField#{user_custom_field.id}"]+ }+ ].to_json)- .at_path("_attributeGroups/0")+ .at_path("_attributeGroups")endend@@ -147,23 +150,22 @@ RSpec.describe API::V3::Projects::Schemas::ProjectSchemaRepresenter doit "renders section attribute group elements of the schema" doexpect(subject).to be_json_eql(- {- _type: "ProjectFormCustomFieldSection",- name: "Common Project Attributes",- attributes: ["customField#{user_custom_field.id}"]- }.to_json+ [+ {+ _type: "ProjectFormCustomFieldSection",+ id: user_section.id,+ name: "Common Project Attributes",+ attributes: ["customField#{user_custom_field.id}"]+ },+ {+ _type: "ProjectFormCustomFieldSection",+ id: admin_section.id,+ name: "Admin Project Attributes",+ attributes: ["customField#{admin_custom_field.id}"]+ }+ ].to_json)- .at_path("_attributeGroups/0")-- expect(subject)- .to be_json_eql(- {- _type: "ProjectFormCustomFieldSection",- name: "Admin Project Attributes",- attributes: ["customField#{admin_custom_field.id}"]- }.to_json- )- .at_path("_attributeGroups/1")+ .at_path("_attributeGroups")endendend