Skip to content

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

Add link to derived done ratio query

Aaron Contreras9758e5c5946f
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.ts
index 9c7b51b01aa..978b713e2f1 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
@@ -26,10 +26,19 @@
// See COPYRIGHT and LICENSE files for more details.
//++
+import { ApiV3Service } from 'core-app/core/apiv3/api-v3.service';
import { DisplayField } from 'core-app/shared/components/fields/display/display-field.module';
+import { InjectField } from 'core-app/shared/helpers/angular/inject-field.decorator';
+import { PathHelperService } from 'core-app/core/path-helper/path-helper.service';
+import { ProjectResource } from 'core-app/features/hal/resources/project-resource';
import { uiStateLinkClass } from 'core-app/features/work-packages/components/wp-fast-table/builders/ui-state-link-builder';
+import * as URI from 'urijs';
export class CompoundProgressDisplayField extends DisplayField {
+ @InjectField() PathHelper:PathHelperService;
+
+ @InjectField() apiV3Service:ApiV3Service;
+
private derivedText = this.I18n.t('js.label_value_derived_from_children');
public render(element:HTMLElement, displayText:string):void {
@@ -61,6 +70,8 @@ export class CompoundProgressDisplayField extends DisplayField {
link.title = `${displayText} ${this.derivedText}`;
link.classList.add('-derived-value', uiStateLinkClass);
+ this.addURLToViewWorkPackageChildren(link);
+
element.appendChild(link);
}
@@ -74,6 +85,31 @@ export class CompoundProgressDisplayField extends DisplayField {
element.appendChild(span);
}
+ private addURLToViewWorkPackageChildren(link:HTMLAnchorElement):void {
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
+ if (this.resource && this.resource.id && this.resource.project) {
+ const wpID = this.resource.id.toString();
+ this
+ .apiV3Service
+ .projects
+ .id(this.resource.project as ProjectResource)
+ .get()
+ .subscribe((project:ProjectResource) => {
+ const props = {
+ c: ['id', 'subject', 'type', 'status', 'estimatedTime', 'remainingTime', 'percentageDone'],
+ hi: true,
+ is: true,
+ f: [{ n: 'parent', o: '=', v: [wpID] }],
+ };
+ const href = URI(this.PathHelper.projectWorkPackagesPath(project.identifier as string))
+ .query({ query_props: JSON.stringify(props) })
+ .toString();
+
+ link.href = href;
+ });
+ }
+ }
+
public get value():number {
return this.resource[this.name] as number || 0;
}