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 wpViewTimestamps service

Oliver Günther56a8514c3e14
diff --git a/frontend/src/app/features/hal/resources/query-resource.ts b/frontend/src/app/features/hal/resources/query-resource.ts
index c979ca1b246..edade8e9793 100644
--- a/frontend/src/app/features/hal/resources/query-resource.ts
+++ b/frontend/src/app/features/hal/resources/query-resource.ts
@@ -88,6 +88,8 @@ export class QueryResource extends HalResource {
public timelineLabels:TimelineLabels;
+ public timestamps:string[];
+
public showHierarchies:boolean;
public public:boolean;
diff --git a/frontend/src/app/features/work-packages/components/wp-list/wp-states-initialization.service.ts b/frontend/src/app/features/work-packages/components/wp-list/wp-states-initialization.service.ts
index 978df3cc022..82c2af5a35d 100644
--- a/frontend/src/app/features/work-packages/components/wp-list/wp-states-initialization.service.ts
+++ b/frontend/src/app/features/work-packages/components/wp-list/wp-states-initialization.service.ts
@@ -25,6 +25,7 @@ import { QuerySchemaResource } from 'core-app/features/hal/resources/query-schem
import { WorkPackageCollectionResource } from 'core-app/features/hal/resources/wp-collection-resource';
import { SchemaResource } from 'core-app/features/hal/resources/schema-resource';
import { WorkPackagesListChecksumService } from './wp-list-checksum.service';
+import { WorkPackageViewTimestampsService } from 'core-app/features/work-packages/routing/wp-view-base/view-services/wp-view-timestamps.service';
@Injectable()
export class WorkPackageStatesInitializationService {
@@ -49,6 +50,7 @@ export class WorkPackageStatesInitializationService {
protected authorisationService:AuthorisationService,
protected wpDisplayRepresentation:WorkPackageViewDisplayRepresentationService,
protected wpIncludeSubprojects:WorkPackageViewIncludeSubprojectsService,
+ protected wpTimestamps:WorkPackageViewTimestampsService,
) { }
/**
@@ -133,6 +135,8 @@ export class WorkPackageStatesInitializationService {
this.wpIncludeSubprojects.initialize(query, results);
+ this.wpTimestamps.initialize(query, results);
+
this.querySpace.additionalRequiredWorkPackages
.values$()
.pipe(take(1))
diff --git a/frontend/src/app/features/work-packages/components/wp-query/url-params-helper.ts b/frontend/src/app/features/work-packages/components/wp-query/url-params-helper.ts
index 0f1d0c53d55..d3303d77401 100644
--- a/frontend/src/app/features/work-packages/components/wp-query/url-params-helper.ts
+++ b/frontend/src/app/features/work-packages/components/wp-query/url-params-helper.ts
@@ -77,6 +77,9 @@ export interface QueryProps {
tv?:boolean;
tzl?:string;
tll?:string;
+
+ // Timestamps options
+ ts?:string;
}
@Injectable({ providedIn: 'root' })
@@ -127,6 +130,7 @@ export class UrlParamsHelperService {
...this.encodeHighlightedAttributes(query),
...this.encodeSortBy(query),
...this.encodeFilters(query.filters),
+ ...this.encodeTimestamps(query),
};
if (typeof extender === 'function') {
@@ -179,6 +183,14 @@ export class UrlParamsHelperService {
return {};
}
+ private encodeTimestamps(query:QueryResource):Partial<QueryProps> {
+ if (query.timestamps) {
+ return { ts: query.timestamps.join(",") };
+ }
+
+ return {};
+ }
+
public encodeFilters(filters:QueryFilterInstanceResource[]):Pick<QueryProps, 'f'> {
if (filters && filters.length > 0) {
const filterProps:QueryPropsFilter[] = filters.map((filter) => ({
@@ -289,6 +301,10 @@ export class UrlParamsHelperService {
queryData.sortBy = JSON.stringify(properties.t.split(',').map((sort:any) => sort.split(':')));
}
+ if (properties.ts) {
+ queryData.timestamps = properties.ts;
+ }
+
// Pagination
if (properties.pa) {
queryData.offset = properties.pa;
@@ -333,6 +349,7 @@ export class UrlParamsHelperService {
// Sortation
queryData.sortBy = this.buildV3GetSortByFromQuery(query);
+ queryData.timestamps = query.timestamps.join(',');
return _.extend(additionalParams, queryData);
}
diff --git a/frontend/src/app/features/work-packages/directives/query-space/wp-isolated-query-space.directive.ts b/frontend/src/app/features/work-packages/directives/query-space/wp-isolated-query-space.directive.ts
index f9138051d40..8720f2bc4d2 100644
--- a/frontend/src/app/features/work-packages/directives/query-space/wp-isolated-query-space.directive.ts
+++ b/frontend/src/app/features/work-packages/directives/query-space/wp-isolated-query-space.directive.ts
@@ -66,6 +66,7 @@ import { WorkPackageNotificationService } from 'core-app/features/work-packages/
import { TimeEntryCreateService } from 'core-app/shared/components/time_entries/create/create.service';
import { WorkPackageViewCollapsedGroupsService } from 'core-app/features/work-packages/routing/wp-view-base/view-services/wp-view-collapsed-groups.service';
import { WorkPackageService } from 'core-app/features/work-packages/services/work-package.service';
+import { WorkPackageViewTimestampsService } from 'core-app/features/work-packages/routing/wp-view-base/view-services/wp-view-timestamps.service';
/**
* Directive to open a work package query 'space', an isolated injector hierarchy
@@ -105,6 +106,7 @@ import { WorkPackageService } from 'core-app/features/work-packages/services/wor
WorkPackageViewIncludeSubprojectsService,
WorkPackageViewOrderService,
WorkPackageViewHierarchyIdentationService,
+ WorkPackageViewTimestampsService,
CausedUpdatesService,
WorkPackageService,
diff --git a/frontend/src/app/features/work-packages/routing/wp-view-base/view-services/wp-view-timestamps.service.ts b/frontend/src/app/features/work-packages/routing/wp-view-base/view-services/wp-view-timestamps.service.ts
new file mode 100644
index 00000000000..57c1e5c1aa9
--- /dev/null
+++ b/frontend/src/app/features/work-packages/routing/wp-view-base/view-services/wp-view-timestamps.service.ts
@@ -0,0 +1,69 @@
+// -- copyright
+// OpenProject is an open source project management software.
+// Copyright (C) 2012-2023 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 { QueryResource } from 'core-app/features/hal/resources/query-resource';
+import { IsolatedQuerySpace } from 'core-app/features/work-packages/directives/query-space/isolated-query-space';
+import { States } from 'core-app/core/states/states.service';
+import { PathHelperService } from 'core-app/core/path-helper/path-helper.service';
+import { WorkPackageQueryStateService } from './wp-view-base.service';
+
+export const DEFAULT_TIMESTAMP = 'PT0S';
+
+@Injectable()
+export class WorkPackageViewTimestampsService extends WorkPackageQueryStateService<string[]> {
+ constructor(
+ protected readonly states:States,
+ protected readonly querySpace:IsolatedQuerySpace,
+ protected readonly pathHelper:PathHelperService,
+ ) {
+ super(querySpace);
+ }
+
+ public showChanges():boolean {
+ return this.current.length >= 1 && this.current[0] !== DEFAULT_TIMESTAMP;
+ }
+
+ public valueFromQuery(query:QueryResource):string[] {
+ return query.timestamps as string[];
+ }
+
+ public hasChanged(query:QueryResource) {
+ return !_.isEqual(query.timestamps, this.current);
+ }
+
+ public applyToQuery(query:QueryResource):boolean {
+ query.timestamps = [...this.current];
+
+ return true;
+ }
+
+ public get current():string[] {
+ return this.lastUpdatedState.getValueOr([DEFAULT_TIMESTAMP]);
+ }
+}
diff --git a/frontend/src/app/features/work-packages/routing/wp-view-base/work-packages-view.base.ts b/frontend/src/app/features/work-packages/routing/wp-view-base/work-packages-view.base.ts
index 3aecdfe04c1..3cdc3a42352 100644
--- a/frontend/src/app/features/work-packages/routing/wp-view-base/work-packages-view.base.ts
+++ b/frontend/src/app/features/work-packages/routing/wp-view-base/work-packages-view.base.ts
@@ -58,6 +58,7 @@ import { DeviceService } from 'core-app/core/browser/device.service';
import { InjectField } from 'core-app/shared/helpers/angular/inject-field.decorator';
import { CurrentProjectService } from 'core-app/core/current-project/current-project.service';
import { UntilDestroyedMixin } from 'core-app/shared/helpers/angular/until-destroyed.mixin';
+import { WorkPackageViewBaselineService } from 'core-app/features/work-packages/routing/wp-view-base/view-services/wp-view-baseline.service';
@Directive()
export abstract class WorkPackagesViewBase extends UntilDestroyedMixin implements OnInit, OnDestroy {
@@ -109,6 +110,8 @@ export abstract class WorkPackagesViewBase extends UntilDestroyedMixin implement
@InjectField() wpIncludeSubprojects:WorkPackageViewIncludeSubprojectsService;
+ @InjectField() wpTableBaseline:WorkPackageViewBaselineService;
+
@InjectField() halEvents:HalEventsService;
@InjectField() deviceService:DeviceService;
@@ -160,6 +163,7 @@ export abstract class WorkPackagesViewBase extends UntilDestroyedMixin implement
this.setupChangeObserver(this.wpTableOrder);
this.setupChangeObserver(this.wpDisplayRepresentation);
this.setupChangeObserver(this.wpIncludeSubprojects);
+ this.setupChangeObserver(this.wpTableBaseline);
}
/**