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

use a helper class to find the baseline icon

bsatarnejadba4fad796e30
diff --git a/frontend/src/app/features/work-packages/components/wp-card-view/wp-single-card/wp-single-card.component.ts b/frontend/src/app/features/work-packages/components/wp-card-view/wp-single-card/wp-single-card.component.ts
index c0b75b437be..c6c767ade94 100644
--- a/frontend/src/app/features/work-packages/components/wp-card-view/wp-single-card/wp-single-card.component.ts
+++ b/frontend/src/app/features/work-packages/components/wp-card-view/wp-single-card/wp-single-card.component.ts
@@ -28,11 +28,12 @@ import { TimezoneService } from 'core-app/core/datetime/timezone.service';
import { StatusResource } from 'core-app/features/hal/resources/status-resource';
import { combineLatest } from 'rxjs';
import { map } from 'rxjs/operators';
-import { IWorkPackageTimestamp } from 'core-app/features/hal/resources/work-package-timestamp-resource';
-import { ISchemaProxy } from 'core-app/features/hal/schemas/schema-proxy';
import { SchemaCacheService } from 'core-app/core/schemas/schema-cache.service';
import { WorkPackageViewColumnsService } from 'core-app/features/work-packages/routing/wp-view-base/view-services/wp-view-columns.service';
import SpotDropAlignmentOption from 'core-app/spot/drop-alignment-options';
+import {
+ getBaselineState,
+} from 'core-app/features/work-packages/components/wp-baseline/baseline-helpers';
@Component({
selector: 'wp-single-card',
@@ -85,7 +86,7 @@ export class WorkPackageSingleCardComponent extends UntilDestroyedMixin implemen
public selected = false;
- public baselineMode = ''||'added'||'changed'||'removed';
+ public baselineMode = ''||'added'||'updated'||'removed';
public text = {
removeCard: this.I18n.t('js.card.remove_from_list'),
@@ -188,33 +189,10 @@ export class WorkPackageSingleCardComponent extends UntilDestroyedMixin implemen
}
public baselineIcon(workPackage:WorkPackageResource) {
- const schema = this.schemaCache.of(workPackage);
- const timestamps = workPackage.attributesByTimestamp || [];
- this.baselineMode = '';
- if (timestamps.length > 1) {
- const base = timestamps[0];
- const compare = timestamps[1];
- if ((!base._meta.exists && compare._meta.exists) || (!base._meta.matchesFilters && compare._meta.matchesFilters)) {
- this.baselineMode = 'added';
- } else if ((base._meta.exists && !compare._meta.exists) || (base._meta.matchesFilters && !compare._meta.matchesFilters)) {
- this.baselineMode = 'removed';
- } else if (this.visibleAttributeChanged(base, schema)) {
- this.baselineMode = 'changed';
- }
- }
+ this.baselineMode = getBaselineState(workPackage, this.schemaCache, this.wpTableColumns);
return this.baselineMode;
}
- private visibleAttributeChanged(base:IWorkPackageTimestamp, schema:ISchemaProxy):boolean {
- return !!this
- .wpTableColumns
- .getColumns()
- .find((column) => {
- const name = schema.mappedName(column.id);
- return Object.prototype.hasOwnProperty.call(base, name) || Object.prototype.hasOwnProperty.call(base.$links, name);
- });
- }
-
// eslint-disable-next-line class-methods-use-this
public wpTypeAttribute(wp:WorkPackageResource):string {
return wp.type.name;