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
display project phase in work package table
Tobias Dillmann8e62fd5b4b6a
diff --git a/app/helpers/colors_helper.rb b/app/helpers/colors_helper.rbindex 5effa615bc0..538bf8415e4 100644--- a/app/helpers/colors_helper.rb+++ b/app/helpers/colors_helper.rb@@ -81,12 +81,18 @@ module ColorsHelperresource_color_css("project_phase_definition", definition, inline_foreground: true)set_foreground_colors_for(- class_name: ".#{hl_inline_class('project_phase_definition', Base64.strict_encode64(definition.name).tr('=', '_'))}",+ class_name: ".#{project_phase_color_css_class_name(definition)}",color: definition.color)endend+ # @see #project_phase_color_css+ def project_phase_color_css_class_name(project_phase_definition)+ hl_inline_class("project_phase_definition",+ Base64.strict_encode64(project_phase_definition.name).tr("=", "_"))+ end+def resource_color_css(name, entry, inline_foreground: false)color = entry.colordiff --git a/app/models/project/phase_definition.rb b/app/models/project/phase_definition.rbindex 871040c07e5..13991c3461f 100644--- a/app/models/project/phase_definition.rb+++ b/app/models/project/phase_definition.rb@@ -48,4 +48,6 @@ class Project::PhaseDefinition < ApplicationRecorddefault_scope { order(:position) }scopes :with_project_count++ def to_s; name endenddiff --git a/app/models/queries/work_packages/selects/property_select.rb b/app/models/queries/work_packages/selects/property_select.rbindex 7a1bfd2bc22..4d781e33509 100644--- a/app/models/queries/work_packages/selects/property_select.rb+++ b/app/models/queries/work_packages/selects/property_select.rb@@ -51,6 +51,11 @@ class Queries::WorkPackages::Selects::PropertySelect < Queries::WorkPackages::Sesortable: "position",groupable: "#{WorkPackage.table_name}.type_id"},+ project_phase: {+ association: "project_phase_definition",+ sortable: "#{Project::PhaseDefinition.table_name}.position",+ groupable: "#{Project::PhaseDefinition.table_name}.id"+ },parent: {association: "ancestors_relations",sortable: falsediff --git a/app/models/query/results/group_by.rb b/app/models/query/results/group_by.rbindex 6ee9d9ef280..2ba1385d6ee 100644--- a/app/models/query/results/group_by.rb+++ b/app/models/query/results/group_by.rb@@ -158,7 +158,14 @@ module ::Query::Results::GroupByenddef transform_property_keys(groups)- association = WorkPackage.reflect_on_all_associations.detect { |a| a.name == query.group_by_column.name.to_sym }+ association = WorkPackage.reflect_on_all_associations.detect do |a|+ # FIXME: refactor this hack+ if a.name == :project_phase_definition+ query.group_by_column.name.to_sym == :project_phase+ else+ a.name == query.group_by_column.name.to_sym+ end+ endif associationtransform_association_property_keys(association, groups)diff --git a/frontend/src/app/features/hal/resources/project-phase-resource.ts b/frontend/src/app/features/hal/resources/project-phase-resource.tsindex 6cb6c2ed975..1f468f6f525 100644--- a/frontend/src/app/features/hal/resources/project-phase-resource.ts+++ b/frontend/src/app/features/hal/resources/project-phase-resource.ts@@ -30,7 +30,7 @@import { HalResource } from 'core-app/features/hal/resources/hal-resource';-/* This resource is currently a stub. It is only defined to the extend necessary for the implementation */+/* This resource is currently a stub. It is only defined to the extent necessary for the implementation */export class ProjectPhaseResource extends HalResource {definition:HalResource;}diff --git a/frontend/src/app/features/hal/resources/wp-collection-resource.ts b/frontend/src/app/features/hal/resources/wp-collection-resource.tsindex 873219821db..6a11195cf1e 100644--- a/frontend/src/app/features/hal/resources/wp-collection-resource.ts+++ b/frontend/src/app/features/hal/resources/wp-collection-resource.ts@@ -60,6 +60,7 @@ export interface WorkPackageCollectionResource extends WorkPackageCollectionReso*/export interface GroupObject {value:any;+ leadingIcon?:any;count:number;collapsed?:boolean;index:number;diff --git a/frontend/src/app/features/work-packages/components/wp-fast-table/builders/modes/grouped/group-header-builder.ts b/frontend/src/app/features/work-packages/components/wp-fast-table/builders/modes/grouped/group-header-builder.tsindex 1cd0ee4cd46..c174246341e 100644--- a/frontend/src/app/features/work-packages/components/wp-fast-table/builders/modes/grouped/group-header-builder.ts+++ b/frontend/src/app/features/work-packages/components/wp-fast-table/builders/modes/grouped/group-header-builder.ts@@ -1,9 +1,40 @@+/*+ * -- copyright+ * OpenProject is an open source project management software.+ * Copyright (C) the OpenProject GmbH+ *+ * This program is free software; you can redistribute it and/or+ * modify it under the terms of the GNU General Public License version 3.+ *+ * OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+ * Copyright (C) 2006-2013 Jean-Philippe Lang+ * Copyright (C) 2010-2013 the ChiliProject Team+ *+ * This program is free software; you can redistribute it and/or+ * modify it under the terms of the GNU General Public License+ * as published by the Free Software Foundation; either version 2+ * of the License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU General Public License for more details.+ *+ * You should have received a copy of the GNU General Public License+ * along with this program; if not, write to the Free Software+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+ *+ * See COPYRIGHT and LICENSE files for more details.+ * +++ */+import { Injector } from '@angular/core';import { I18nService } from 'core-app/core/i18n/i18n.service';import { rowGroupClassName } from 'core-app/features/work-packages/components/wp-fast-table/builders/modes/grouped/grouped-classes.constants';import { InjectField } from 'core-app/shared/helpers/angular/inject-field.decorator';import { GroupObject } from 'core-app/features/hal/resources/wp-collection-resource';import { groupName } from './grouped-rows-helpers';+import { ProjectPhaseDisplayField } from 'core-app/shared/components/fields/display/field-types/project-phase-display-field.module';export function groupClassNameFor(group:GroupObject) {return `group-${group.identifier}`;@@ -23,8 +54,8 @@ export class GroupHeaderBuilder {public buildGroupRow(group:GroupObject, colspan:number) {const row = document.createElement('tr');- let togglerIconClass; let- text;+ let togglerIconClass;+ let text;if (group.collapsed) {text = this.text.expand;@@ -34,6 +65,10 @@ export class GroupHeaderBuilder {togglerIconClass = 'icon-minus2';}+ const leadingIcon = this.leadingIcon(group);+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument+ const groupTitle = _.escape((groupName(group)));+row.classList.add(rowGroupClassName, groupClassNameFor(group));row.id = `wp-table-rowgroup-${group.index}`;row.dataset.groupIndex = (group.index).toString();@@ -44,7 +79,8 @@ export class GroupHeaderBuilder {<span class="hidden-for-sighted">${_.escape(text)}</span></div><div class="group--value" data-test-selector="op-group--value">- ${_.escape(groupName(group))}+ ${leadingIcon ? leadingIcon.outerHTML : ''}+ ${groupTitle}<span class="count">(${group.count})</span>@@ -54,4 +90,13 @@ export class GroupHeaderBuilder {return row;}++ private leadingIcon(group:GroupObject) {+ if (group.leadingIcon === 'projectPhaseDefinition') {+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument+ return ProjectPhaseDisplayField.phaseIconByName(groupName(group), false);+ }++ return null;+ }}diff --git a/frontend/src/app/shared/components/fields/display/display-field.initializer.ts b/frontend/src/app/shared/components/fields/display/display-field.initializer.tsindex c33d0b26de1..4ddda61022f 100644--- a/frontend/src/app/shared/components/fields/display/display-field.initializer.ts+++ b/frontend/src/app/shared/components/fields/display/display-field.initializer.ts@@ -110,6 +110,7 @@ export function initializeCoreDisplayFields(displayFieldService:DisplayFieldServ'CustomField::Hierarchy::Item','CustomOption']).addFieldType(ProjectPhaseDisplayField, 'projectPhase', ['ProjectPhase'])+ .addFieldType(ProjectPhaseDisplayField, 'projectPhaseDefinition', ['ProjectPhaseDefinition']).addFieldType(ResourcesDisplayField, 'resources', ['[]CustomOption', '[]CustomField::Hierarchy::Item']).addFieldType(ResourcesDisplayField, 'resources', ['[]Version']).addFieldType(MultipleUserFieldModule, 'users', ['[]User'])diff --git a/frontend/src/app/shared/components/fields/display/field-types/project-phase-display-field.module.ts b/frontend/src/app/shared/components/fields/display/field-types/project-phase-display-field.module.tsindex e875c214fcc..647496e70bc 100644--- a/frontend/src/app/shared/components/fields/display/field-types/project-phase-display-field.module.ts+++ b/frontend/src/app/shared/components/fields/display/field-types/project-phase-display-field.module.ts@@ -52,13 +52,15 @@ export class ProjectPhaseDisplayField extends DisplayField {* the icon in the color defined for the definition.** @return {HTMLElement} The HTML span element containing the project phase icon.+ * @see phaseIcon*/- protected phaseIcon():HTMLElement {- const projectPhase = this.attribute as ProjectPhaseResource;+ public static phaseIconByName(phaseName?:string, addPadding = true) {const icon = document.createElement('span');- if (projectPhase) {- icon.classList.add('mr-1');+ if (phaseName) {+ if (addPadding) {+ icon.classList.add('mr-1');+ }icon.innerHTML = toDOMString(opPhaseIconData,@@ -71,9 +73,18 @@ export class ProjectPhaseDisplayField extends DisplayField {// The name is guaranteed to be unique.// The = signs at the end of the base64 string are replaced with _ to make it a valid class name.// This needs to be kept in sync with the ColorsHelper#project_phase_color_css method in the backend.- icon.classList.add(`__hl_inline_project_phase_definition_${btoa(projectPhase.name).replace(/=/g, '_')}`);+ icon.classList.add(`__hl_inline_project_phase_definition_${btoa(phaseName).replace(/=/g, '_')}`);}return icon;}++ /**+ * @see phaseIconByName+ */+ protected phaseIcon():HTMLElement {+ const projectPhase = this.attribute as ProjectPhaseResource;++ return ProjectPhaseDisplayField.phaseIconByName(projectPhase?.name);+ }}diff --git a/lib/api/decorators/aggregation_group.rb b/lib/api/decorators/aggregation_group.rbindex ce2763211e4..cca77c26667 100644--- a/lib/api/decorators/aggregation_group.rb+++ b/lib/api/decorators/aggregation_group.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -65,6 +67,11 @@ module APIgetter: ->(*) { count },render_nil: true+ property :leading_icon,+ exec_context: :decorator,+ getter: ->(*) { leading_icon },+ render_nil: false+def model_required?falseend@@ -83,6 +90,12 @@ module APIendend+ def leading_icon+ if represented.is_a?(Project::PhaseDefinition)+ "projectPhaseDefinition"+ end+ end+def convert_attribute(attribute)::API::Utilities::PropertyNameConverter.from_ar_name(attribute)enddiff --git a/lib/api/v3/work_packages/work_package_aggregation_group.rb b/lib/api/v3/work_packages/work_package_aggregation_group.rbindex 6c6746fbb9d..817a6ee7bbe 100644--- a/lib/api/v3/work_packages/work_package_aggregation_group.rb+++ b/lib/api/v3/work_packages/work_package_aggregation_group.rb@@ -48,6 +48,11 @@ module APIlink :groupBy doconverted_name = convert_attribute(query.group_by_column.name)+ # FIXME: there must be a better place to define this conversion+ if converted_name == "projectPhase"+ converted_name = "projectPhaseDefinition"+ end+{href: api_v3_paths.query_group_by(converted_name),title: query.group_by_column.captiondiff --git a/lib/api/v3/work_packages/work_package_representer.rb b/lib/api/v3/work_packages/work_package_representer.rbindex b16687cce4c..8ad6edb7cd8 100644--- a/lib/api/v3/work_packages/work_package_representer.rb+++ b/lib/api/v3/work_packages/work_package_representer.rb@@ -523,6 +523,10 @@ module API.to_send+ associated_resource :project_phase_definition,+ v3_path: :project_phase_definition,+ representer: ::API::V3::ProjectPhaseDefinitions::ProjectPhaseDefinitionRepresenter+associated_resource :statusassociated_resource :author,@@ -685,6 +689,10 @@ module API@project_phase ||= represented.project_phaseend+ def project_phase_definition+ @project_phase_definition ||= represented.project_phase_definition+ end+def phase_set_and_active?project_phase&.active?end