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

Always use the current project if it is part of the filters. Only if it is not included (e.g in the embedded table), use the first filter value.

Henriette Darge1ae0554f5be4
diff --git a/frontend/src/app/features/work-packages/components/wp-edit-form/work-package-filter-values.ts b/frontend/src/app/features/work-packages/components/wp-edit-form/work-package-filter-values.ts
index 2d65e001676..c24f35fd24a 100644
--- a/frontend/src/app/features/work-packages/components/wp-edit-form/work-package-filter-values.ts
+++ b/frontend/src/app/features/work-packages/components/wp-edit-form/work-package-filter-values.ts
@@ -7,12 +7,15 @@ import { WorkPackageChangeset } from 'core-app/features/work-packages/components
import { InjectField } from 'core-app/shared/helpers/angular/inject-field.decorator';
import { FilterOperator } from 'core-app/shared/helpers/api-v3/api-v3-filter-builder';
import { QueryFilterInstanceResource } from 'core-app/features/hal/resources/query-filter-instance-resource';
+import { CurrentProjectService } from 'core-app/core/current-project/current-project.service';
export class WorkPackageFilterValues {
@InjectField() currentUser:CurrentUserService;
@InjectField() halResourceService:HalResourceService;
+ @InjectField() currentProject:CurrentProjectService;
+
handlers:Partial<Record<FilterOperator, (filter:QueryFilterInstanceResource) => void>> = {
'=': this.applyFirstValue.bind(this),
'!*': this.setToNull.bind(this),
@@ -31,6 +34,18 @@ export class WorkPackageFilterValues {
return;
}
+ // Special case due to the introduction of the project include dropdown
+ // If we are in a project, we want the create wp to be part of that project.
+ // Only for embedded tables, there might be different filter values necessary.
+ if (filter.id === 'project') {
+ const projectFilter = _.find(filter.values, (resource:HalResource|string) => {
+ return ((resource instanceof HalResource) ? resource.href : resource) === this.currentProject.apiv3Path;
+ });
+ this.setValue(change, 'project', projectFilter || filter.values[0]);
+
+ return;
+ }
+
// Look for a handler with the filter's operator
const operator = filter.operator.id as FilterOperator;
const handler = this.handlers[operator];
diff --git a/frontend/src/app/features/work-packages/components/wp-new/wp-create.service.ts b/frontend/src/app/features/work-packages/components/wp-new/wp-create.service.ts
index 4ce7ffd1d46..94a50dbf2b2 100644
--- a/frontend/src/app/features/work-packages/components/wp-new/wp-create.service.ts
+++ b/frontend/src/app/features/work-packages/components/wp-new/wp-create.service.ts
@@ -59,7 +59,6 @@ import { SchemaResource } from 'core-app/features/hal/resources/schema-resource'
import { SchemaCacheService } from 'core-app/core/schemas/schema-cache.service';
import { HalResourceService } from 'core-app/features/hal/services/hal-resource.service';
import { ResourceChangeset } from 'core-app/shared/components/fields/changeset/resource-changeset';
-import { CurrentProjectService } from 'core-app/core/current-project/current-project.service';
export const newWorkPackageHref = '/api/v3/work_packages/new';
@@ -80,7 +79,6 @@ export class WorkPackageCreateService extends UntilDestroyedMixin {
protected halEditing:HalResourceEditingService,
protected schemaCache:SchemaCacheService,
protected halEvents:HalEventsService,
- protected currentProject:CurrentProjectService,
) {
super();
@@ -193,18 +191,9 @@ export class WorkPackageCreateService extends UntilDestroyedMixin {
public createOrContinueWorkPackage(projectIdentifier:string|null|undefined, type?:number, defaults?:HalSource):Promise<WorkPackageChangeset> {
let changePromise = this.continueExistingEdit(type);
- const extendedDefaults:HalSource = defaults || { _links: {} };
- const projectId = this.currentProject.id;
-
- // Special case due to the introduction of the project include dropdown
- // If we are in a project, we want the create wp to be part of that project.
- // Only on the global WP page, the filters should be applied.
- if (projectId) {
- extendedDefaults._links.project = { href: this.apiV3Service.projects.id(projectId).path };
- }
if (!changePromise) {
- changePromise = this.createNewWithDefaults(projectIdentifier, extendedDefaults);
+ changePromise = this.createNewWithDefaults(projectIdentifier, defaults);
}
return changePromise.then((change:WorkPackageChangeset) => {
diff --git a/spec/features/work_packages/details/query_groups/relation_query_group_spec.rb b/spec/features/work_packages/details/query_groups/relation_query_group_spec.rb
index 1b49dd4e44e..0ff1ee8b5e9 100644
--- a/spec/features/work_packages/details/query_groups/relation_query_group_spec.rb
+++ b/spec/features/work_packages/details/query_groups/relation_query_group_spec.rb
@@ -148,7 +148,6 @@ describe 'Work package with relation query group', js: true, selenium: true do
end
it 'can load the query and inline create' do
- pending("needs to be fixed in 12.2 as it is only a temporary accepted failure")
full_wp.visit!
full_wp.ensure_page_loaded