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
[#62982] group correctly by phase definition
Tobias Dillmannb452e4498215
diff --git a/app/models/queries/work_packages/selects/project_phase_select.rb b/app/models/queries/work_packages/selects/project_phase_select.rbindex 12c5a13a915..84ff7e378b4 100644--- a/app/models/queries/work_packages/selects/project_phase_select.rb+++ b/app/models/queries/work_packages/selects/project_phase_select.rb@@ -31,8 +31,8 @@class Queries::WorkPackages::Selects::ProjectPhaseSelect < Queries::WorkPackages::Selects::WorkPackageSelectdef initializesuper(:project_phase,- association: "project_phase_definition",- group_by_column_name: "project_phase_definition",+ association: :project_phase_definition,+ group_by_column_name: :project_phase_definition,sortable: sortable_statement,groupable: group_by_statement,groupable_join: group_by_join_statement,diff --git a/docs/api/apiv3/tags/work_packages.yml b/docs/api/apiv3/tags/work_packages.ymlindex be9341d7576..809490e9625 100644--- a/docs/api/apiv3/tags/work_packages.yml+++ b/docs/api/apiv3/tags/work_packages.yml@@ -20,30 +20,31 @@ description: |-## Linked Properties- | Link | Description | Type | Constraints | Supported operations | Condition |- | :----------------: | ----------------------------------------------------------------------------------------------------------------------------------------------------- | ------------ | ------------ | --------------------- | ----------------------------------------- |- | self | This work package | WorkPackage | not null | READ | |- | schema | The schema of this work package | Schema | not null | READ | |- | ancestors | Array of all visible ancestors of the work package, with the root node being the first element | Collection | not null | READ | **Permission** view work packages |- | attachments | The files attached to this work package | Collection | not null | READ / WRITE | |- | author | The person that created the work package | User | not null | READ | |- | assignee | The person that is intended to work on the work package | User | | READ / WRITE | |- | availableWatchers | All users that can be added to the work package as watchers. | User | | READ | **Permission** add work package watchers |- | budget | The budget this work package is associated to | Budget | | READ / WRITE | **Permission** view cost objects |- | category | The category of the work package | Category | | READ / WRITE | |- | children | Array of all visible children of the work package | Collection | not null | READ | **Permission** view work packages |- | parent | Parent work package | WorkPackage | Needs to be visible (to the current user) | READ / WRITE | |- | priority | The priority of the work package | Priority | not null | READ / WRITE | |- | project | The project to which the work package belongs | Project | not null | READ / WRITE | |- | projectPhase | The project phase this work package is assigned to | ProjectPhase | | READ / WRITE | **Permission** view project phases. There has to be a project phase active in the project. |- | responsible | The person that is responsible for the overall outcome | User | | READ / WRITE | |- | relations | Relations this work package is involved in | Relation | | READ | **Permission** view work packages |- | revisions | Revisions that are referencing the work package | Revision | | READ | **Permission** view changesets |- | status | The current status of the work package | Status | not null | READ / WRITE | |- | timeEntries | All time entries logged on the work package. Please note that this is a link to an HTML resource for now and as such, the link is subject to change. | N/A | | READ | **Permission** view time entries |- | type | The type of the work package | Type | not null | READ / WRITE | |- | version | The version associated to the work package | Version | | READ / WRITE | |- | watchers | All users that are currently watching this work package | Collection | | READ | **Permission** view work package watchers |+ | Link | Description | Type | Constraints | Supported operations | Condition |+ | :--------------------: | ----------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------- | ----------------------------------------- | --------------------- | ----------------------------------------- |+ | self | This work package | WorkPackage | not null | READ | |+ | schema | The schema of this work package | Schema | not null | READ | |+ | ancestors | Array of all visible ancestors of the work package, with the root node being the first element | Collection | not null | READ | **Permission** view work packages |+ | attachments | The files attached to this work package | Collection | not null | READ / WRITE | |+ | author | The person that created the work package | User | not null | READ | |+ | assignee | The person that is intended to work on the work package | User | | READ / WRITE | |+ | availableWatchers | All users that can be added to the work package as watchers. | User | | READ | **Permission** add work package watchers |+ | budget | The budget this work package is associated to | Budget | | READ / WRITE | **Permission** view cost objects |+ | category | The category of the work package | Category | | READ / WRITE | |+ | children | Array of all visible children of the work package | Collection | not null | READ | **Permission** view work packages |+ | parent | Parent work package | WorkPackage | Needs to be visible (to the current user) | READ / WRITE | |+ | priority | The priority of the work package | Priority | not null | READ / WRITE | |+ | project | The project to which the work package belongs | Project | not null | READ / WRITE | |+ | projectPhase | The project phase this work package is assigned to | ProjectPhase | | READ / WRITE | **Permission** view project phases. There has to be a project phase active in the project. |+ | projectPhaseDefinition | The project phase definition for the project phase of this work package. | ProjectPhaseDefinition | | READ | **Permission** view project phases. The associated project phase has to be active. |+ | responsible | The person that is responsible for the overall outcome | User | | READ / WRITE | |+ | relations | Relations this work package is involved in | Relation | | READ | **Permission** view work packages |+ | revisions | Revisions that are referencing the work package | Revision | | READ | **Permission** view changesets |+ | status | The current status of the work package | Status | not null | READ / WRITE | |+ | timeEntries | All time entries logged on the work package. Please note that this is a link to an HTML resource for now and as such, the link is subject to change. | N/A | | READ | **Permission** view time entries |+ | type | The type of the work package | Type | not null | READ / WRITE | |+ | version | The version associated to the work package | Version | | READ / WRITE | |+ | watchers | All users that are currently watching this work package | Collection | | READ | **Permission** view work package watchers |## Local Propertiesdiff --git a/lib/api/v3/work_packages/work_package_representer.rb b/lib/api/v3/work_packages/work_package_representer.rbindex c86cffb3df7..ac59b26c33d 100644--- a/lib/api/v3/work_packages/work_package_representer.rb+++ b/lib/api/v3/work_packages/work_package_representer.rb@@ -523,9 +523,19 @@ module API.to_send- associated_resource :project_phase_definition,- v3_path: :project_phase_definition,- representer: ::API::V3::ProjectPhaseDefinitions::ProjectPhaseDefinitionRepresenter+ link :projectPhaseDefinition do+ if phase_set_and_active? && view_project_phase_allowed?+ {+ href: api_v3_paths.project_phase_definition(represented.project_phase_definition_id),+ title: project_phase.name+ }+ else+ {+ href: nil,+ title: nil+ }+ end+ endassociated_resource :statusdiff --git a/spec/lib/api/v3/work_packages/work_package_representer_spec.rb b/spec/lib/api/v3/work_packages/work_package_representer_spec.rbindex fce2ba8212e..25ae494f7ba 100644--- a/spec/lib/api/v3/work_packages/work_package_representer_spec.rb+++ b/spec/lib/api/v3/work_packages/work_package_representer_spec.rb@@ -1432,6 +1432,60 @@ RSpec.describe API::V3::WorkPackages::WorkPackageRepresenter doendend+ describe "projectPhaseDefinition" do+ context "with the feature flag being active", with_flag: { stages_and_gates: true } do+ context "with a phase being set" do+ it_behaves_like "has a titled link" do+ let(:link) { "projectPhaseDefinition" }+ let(:href) { "/api/v3/project_phase_definitions/#{work_package.project_phase_definition_id}" }+ let(:title) { work_package.project_phase_definition.name }+ end+ end++ context "without a phase being set" do+ before do+ work_package.project_phase_definition = nil+ end++ it_behaves_like "has a titled link" do+ let(:link) { "projectPhaseDefinition" }+ let(:href) { nil }+ let(:title) { nil }+ end+ end++ context "with the phase not existing in the project" do+ let(:project_phases) { [other_project_phase] }++ it_behaves_like "has a titled link" do+ let(:link) { "projectPhaseDefinition" }+ let(:href) { nil }+ let(:title) { nil }+ end+ end++ context "with the phase being inactive in the project" do+ let(:project_phase) { build_stubbed(:project_phase, active: false, definition: project_phase_definition) }++ it_behaves_like "has a titled link" do+ let(:link) { "projectPhaseDefinition" }+ let(:href) { nil }+ let(:title) { nil }+ end+ end++ context "without the user being allowed to see the reference" do+ let(:permissions) { all_permissions - [:view_project_phases] }++ it_behaves_like "has a titled link" do+ let(:link) { "projectPhaseDefinition" }+ let(:href) { nil }+ let(:title) { nil }+ end+ end+ end+ end+context "when passing timestamps" dolet(:timestamps) { [Timestamp.new(baseline_time), Timestamp.now] }let(:baseline_time) { Time.zone.parse("2022-01-01") }