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
[49409] Add icon to progress fields if status is excluded from totals
Christophe Bliard15005eea6bcf
diff --git a/frontend/src/app/features/hal/resources/status-resource.ts b/frontend/src/app/features/hal/resources/status-resource.tsindex 504aaf093d2..d2a5694de3c 100644--- a/frontend/src/app/features/hal/resources/status-resource.ts+++ b/frontend/src/app/features/hal/resources/status-resource.ts@@ -36,6 +36,8 @@ export class StatusResource extends HalResource {isReadonly:boolean;+ excludedFromTotals:boolean;+public get state():InputState<this> {return this.states.statuses.get(this.href as string) as any;}diff --git a/frontend/src/app/features/hal/resources/work-package-resource.ts b/frontend/src/app/features/hal/resources/work-package-resource.tsindex 0be3adcfeb4..89fce7c137f 100644--- a/frontend/src/app/features/hal/resources/work-package-resource.ts+++ b/frontend/src/app/features/hal/resources/work-package-resource.ts@@ -44,6 +44,7 @@ import { HalResource } from 'core-app/features/hal/resources/hal-resource';import { CollectionResource } from 'core-app/features/hal/resources/collection-resource';import { TypeResource } from 'core-app/features/hal/resources/type-resource';import { RelationResource } from 'core-app/features/hal/resources/relation-resource';+import { StatusResource } from 'core-app/features/hal/resources/status-resource';import { FormResource } from 'core-app/features/hal/resources/form-resource';import { Attachable } from 'core-app/features/hal/resources/mixins/attachable-mixin';import { ICKEditorContext } from 'core-app/shared/components/editor/components/ckeditor/ckeditor.types';@@ -67,7 +68,7 @@ export interface WorkPackageResourceEmbedded {relations:CollectionResource;responsible:HalResource|any;revisions:CollectionResource|any;- status:HalResource|any;+ status:StatusResource|any;timeEntries:HalResource[]|any[];type:TypeResource;version:HalResource|any;diff --git a/frontend/src/app/shared/components/fields/display/field-types/compound-progress-display-field.module.ts b/frontend/src/app/shared/components/fields/display/field-types/compound-progress-display-field.module.tsindex 4a7d283fcb2..57a29f7ac85 100644--- a/frontend/src/app/shared/components/fields/display/field-types/compound-progress-display-field.module.ts+++ b/frontend/src/app/shared/components/fields/display/field-types/compound-progress-display-field.module.ts@@ -36,12 +36,16 @@ import {import {HierarchyQueryLinkHelperService,} from 'core-app/shared/components/fields/display/field-types/hierarchy-query-link-helper.service';+import { ExcludedIconHelperService } from 'core-app/shared/components/fields/display/field-types/excluded-icon-helper.service';+import { WorkPackageResource } from 'core-app/features/hal/resources/work-package-resource';export class CompoundProgressDisplayField extends DisplayField {@InjectField() PathHelper:PathHelperService;@InjectField() apiV3Service:ApiV3Service;+ @InjectField() excludedIconHelperService:ExcludedIconHelperService;+@InjectField() hierarchyQueryLinkHelper:HierarchyQueryLinkHelperService;private derivedText = this.I18n.t('js.label_value_derived_from_children');@@ -65,6 +69,8 @@ export class CompoundProgressDisplayField extends DisplayField {span.title = this.valueString;span.classList.add('-actual-value');+ this.excludedIconHelperService.addIconIfExcludedFromTotals(span, this.resource as WorkPackageResource);+element.appendChild(span);}diff --git a/frontend/src/app/shared/components/fields/display/field-types/excluded-icon-helper.service.ts b/frontend/src/app/shared/components/fields/display/field-types/excluded-icon-helper.service.tsnew file mode 100644index 00000000000..a2202934023--- /dev/null+++ b/frontend/src/app/shared/components/fields/display/field-types/excluded-icon-helper.service.ts@@ -0,0 +1,64 @@+// -- copyright+// OpenProject is an open source project management software.+// Copyright (C) 2012-2024 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 { Injectable } from '@angular/core';+import { ApiV3Service } from 'core-app/core/apiv3/api-v3.service';+import { WorkPackageResource } from 'core-app/features/hal/resources/work-package-resource';+import { StatusResource } from 'core-app/features/hal/resources/status-resource';++@Injectable({ providedIn: 'root' })++export class ExcludedIconHelperService {+ constructor(+ private apiV3Service:ApiV3Service,+ ) {}++ public addIconIfExcludedFromTotals(element:HTMLElement, resource:WorkPackageResource):void {+ if (resource?.status) {+ this.apiV3Service.statuses.id(resource.status as StatusResource).get().subscribe(+ (status:StatusResource) => {+ if (status.excludedFromTotals) {+ this.addExcludedInfoIcon(element);+ }+ },+ );+ }+ }++ public addExcludedInfoIcon(element:HTMLElement):void {+ // This should work, but does not work when adding it through javascript+ // <svg+ // info-icon+ // class="button--icon"+ // size="small"+ // ></svg>+ const icon = document.createElement('i');+ icon.classList.add('icon-info1', 'excluded-from-totals');+ element.appendChild(icon);+ }+}diff --git a/frontend/src/app/shared/components/fields/display/field-types/work-display-field.module.ts b/frontend/src/app/shared/components/fields/display/field-types/work-display-field.module.tsindex bb7414126d0..b9965281529 100644--- a/frontend/src/app/shared/components/fields/display/field-types/work-display-field.module.ts+++ b/frontend/src/app/shared/components/fields/display/field-types/work-display-field.module.ts@@ -32,7 +32,9 @@ import { TimezoneService } from 'core-app/core/datetime/timezone.service';import { ApiV3Service } from 'core-app/core/apiv3/api-v3.service';import { PathHelperService } from 'core-app/core/path-helper/path-helper.service';import { uiStateLinkClass } from 'core-app/features/work-packages/components/wp-fast-table/builders/ui-state-link-builder';+import { ExcludedIconHelperService } from 'core-app/shared/components/fields/display/field-types/excluded-icon-helper.service';import { HierarchyQueryLinkHelperService } from 'core-app/shared/components/fields/display/field-types/hierarchy-query-link-helper.service';+import { WorkPackageResource } from 'core-app/features/hal/resources/work-package-resource';export class WorkDisplayField extends DisplayField {@InjectField() timezoneService:TimezoneService;@@ -41,6 +43,8 @@ export class WorkDisplayField extends DisplayField {@InjectField() apiV3Service:ApiV3Service;+ @InjectField() excludedIconHelperService:ExcludedIconHelperService;+@InjectField() hierarchyQueryLinkHelper:HierarchyQueryLinkHelperService;private derivedText = this.I18n.t('js.label_value_derived_from_children');@@ -98,6 +102,9 @@ export class WorkDisplayField extends DisplayField {}span.classList.add('-actual-value');+ if (this.value) {+ this.excludedIconHelperService.addIconIfExcludedFromTotals(span, this.resource as WorkPackageResource);+ }element.appendChild(span);}diff --git a/frontend/src/global_styles/content/work_packages/inplace_editing/_display_fields.sass b/frontend/src/global_styles/content/work_packages/inplace_editing/_display_fields.sassindex 7bb82b87431..03a2802913f 100644--- a/frontend/src/global_styles/content/work_packages/inplace_editing/_display_fields.sass+++ b/frontend/src/global_styles/content/work_packages/inplace_editing/_display_fields.sass@@ -51,7 +51,6 @@ display-fieldpadding-right: 0.25remtext-align: center-// READ value of edit fields.inline-edit--display-fielddisplay: inline-block@@ -101,6 +100,12 @@ display-field.-actual-value@include wp-table--actual-time-values+ .excluded-from-totals+ padding-left: 0.25rem+ color: var(--fgColor-muted)+ &:hover+ color: var(--fgColor-default)+.-separatordisplay: inline-blockwidth: 1remdiff --git a/lib/api/v3/statuses/status_representer.rb b/lib/api/v3/statuses/status_representer.rbindex 7012a529324..1c5b041882a 100644--- a/lib/api/v3/statuses/status_representer.rb+++ b/lib/api/v3/statuses/status_representer.rb@@ -42,6 +42,7 @@ module APIrender_nil: trueproperty :is_default, render_nil: trueproperty :is_readonly, render_nil: true+ property :excluded_from_totals, render_nil: trueproperty :default_done_ratio, render_nil: trueproperty :position, render_nil: truediff --git a/spec/lib/api/v3/statuses/status_representer_spec.rb b/spec/lib/api/v3/statuses/status_representer_spec.rbindex 799a822cc11..e704992c071 100644--- a/spec/lib/api/v3/statuses/status_representer_spec.rb+++ b/spec/lib/api/v3/statuses/status_representer_spec.rb@@ -30,9 +30,9 @@ require "spec_helper"RSpec.describe API::V3::Statuses::StatusRepresenter dolet(:status) { build_stubbed(:status) }- let(:representer) { described_class.new(status, current_user: double("current_user")) }+ let(:representer) { described_class.new(status, current_user: instance_double(User)) }- context "generation" do+ describe "generation" dosubject(:generated) { representer.to_json }it { is_expected.to include_json("Status".to_json).at_path("_type") }@@ -43,6 +43,7 @@ RSpec.describe API::V3::Statuses::StatusRepresenter doit { is_expected.to have_json_path("isClosed") }it { is_expected.to have_json_path("isDefault") }it { is_expected.to have_json_path("isReadonly") }+ it { is_expected.to have_json_path("excludedFromTotals") }it { is_expected.to have_json_path("position") }it { is_expected.to have_json_path("defaultDoneRatio") }@@ -52,6 +53,7 @@ RSpec.describe API::V3::Statuses::StatusRepresenter doit { is_expected.to be_json_eql(status.is_closed.to_json).at_path("isClosed") }it { is_expected.to be_json_eql(status.is_default.to_json).at_path("isDefault") }it { is_expected.to be_json_eql(status.is_readonly.to_json).at_path("isReadonly") }+ it { is_expected.to be_json_eql(status.excluded_from_totals.to_json).at_path("excludedFromTotals") }it { is_expected.to be_json_eql(status.position.to_json).at_path("position") }it {@@ -74,12 +76,15 @@ RSpec.describe API::V3::Statuses::StatusRepresenter dodescribe "caching" doit "is based on the representer's cache_key" do- expect(OpenProject::Cache)+ allow(OpenProject::Cache).to receive(:fetch)- .with(representer.json_cache_key).and_call_originalrepresenter.to_json++ expect(OpenProject::Cache)+ .to have_received(:fetch)+ .with(representer.json_cache_key)enddescribe "#json_cache_key" do@@ -98,7 +103,7 @@ RSpec.describe API::V3::Statuses::StatusRepresenter doendit "changes when the status is updated" do- status.updated_at = Time.now + 20.seconds+ status.updated_at = 20.seconds.from_nowexpect(representer.json_cache_key).not_to eql former_cache_key