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 the colored project phase icon before the linked phase
ulferts75c975b45a69
diff --git a/frontend/src/app/features/hal/resources/project-phase-resource.ts b/frontend/src/app/features/hal/resources/project-phase-resource.tsnew file mode 100644index 00000000000..6cb6c2ed975--- /dev/null+++ b/frontend/src/app/features/hal/resources/project-phase-resource.ts@@ -0,0 +1,36 @@+/*+ * -- 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 { 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 */+export class ProjectPhaseResource extends HalResource {+ definition:HalResource;+}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 8d590f9bebb..c33d0b26de1 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@@ -86,6 +86,9 @@ import {WorkPackageSpentTimeDisplayField,} from 'core-app/shared/components/fields/display/field-types/wp-spent-time-display-field.module';import { LinkDisplayField } from 'core-app/shared/components/fields/display/field-types/link-display-field.module';+import {+ ProjectPhaseDisplayField,+} from 'core-app/shared/components/fields/display/field-types/project-phase-display-field.module';export function initializeCoreDisplayFields(displayFieldService:DisplayFieldService) {return () => {@@ -101,12 +104,12 @@ export function initializeCoreDisplayFields(displayFieldService:DisplayFieldServ.addFieldType(TypeDisplayField, 'type', ['Type']).addFieldType(ResourceDisplayField, 'resource', ['Project',- 'ProjectPhase','TimeEntriesActivity','Version','Category','CustomField::Hierarchy::Item','CustomOption'])+ .addFieldType(ProjectPhaseDisplayField, 'projectPhase', ['ProjectPhase']).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.tsnew file mode 100644index 00000000000..0bc690b452f--- /dev/null+++ b/frontend/src/app/shared/components/fields/display/field-types/project-phase-display-field.module.ts@@ -0,0 +1,72 @@+/*+ * -- 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 { opPhaseIconData, toDOMString } from '@openproject/octicons-angular';+import { DisplayField } from 'core-app/shared/components/fields/display/display-field.module';+import { ProjectPhaseResource } from 'core-app/features/hal/resources/project-phase-resource';++export class ProjectPhaseDisplayField extends DisplayField {+ public get value():string|null {+ if (this.schema && this.attribute) {+ return (this.attribute as ProjectPhaseResource).name;+ }+ return null;+ }++ public render(element:HTMLElement, displayText:string):void {+ super.render(element, displayText);++ element.prepend(this.phaseIcon());+ }++ /**+ * Creates and returns an HTML element representing the icon for a project phase.+ * The icon is wrapped in a span element with the correct css class set for coloring+ * the icon in the color defined for the definition.+ *+ * @return {HTMLElement} The HTML span element containing the project phase icon.+ */+ protected phaseIcon():HTMLElement {+ const projectPhase = this.attribute as ProjectPhaseResource;+ const icon = document.createElement('span');++ if (projectPhase && projectPhase.definition) {+ icon.classList.add(`__hl_inline_project_phase_definition_${projectPhase.definition.id}`, 'mr-1');++ icon.innerHTML = toDOMString(+ opPhaseIconData,+ 'small',+ { 'aria-hidden': 'true', class: 'octicon' },+ );+ }++ return icon;+ }+}