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

Merge release/11.4 into dev

Oliver Günther202bd63ebbac
diff --git a/frontend/src/app/core/setup/globals/tree-menu.ts b/frontend/src/app/core/setup/globals/tree-menu.ts
index 502362b146d..a0e7ba303f6 100644
--- a/frontend/src/app/core/setup/globals/tree-menu.ts
+++ b/frontend/src/app/core/setup/globals/tree-menu.ts
@@ -35,7 +35,7 @@
if (selectedPage) {
const selected = $(`[slug="${selectedPage}"]`, tree);
selected.toggleClass('-selected', true);
- if (selected.length > 1) {
+ if (selected.length > 0) {
selected[0].scrollIntoView();
}
}
diff --git a/frontend/src/app/core/states/states.service.ts b/frontend/src/app/core/states/states.service.ts
index ff9ab6c5760..218146f2594 100644
--- a/frontend/src/app/core/states/states.service.ts
+++ b/frontend/src/app/core/states/states.service.ts
@@ -1,21 +1,14 @@
-import {
- input, InputState, multiInput, MultiInputState, StatesGroup,
-} from 'reactivestates';
-import { HalResource } from 'core-app/features/hal/resources/hal-resource';
+import { InputState, multiInput, MultiInputState, StatesGroup } from 'reactivestates';
import { Subject } from 'rxjs';
-import { WorkPackageDisplayRepresentationValue } from 'core-app/features/work-packages/routing/wp-view-base/view-services/wp-view-display-representation.service';
-import { QueryColumn } from 'core-app/features/work-packages/components/wp-query/query-column';
-import { CapabilityResource } from 'core-app/features/hal/resources/capability-resource';
import { TypeResource } from 'core-app/features/hal/resources/type-resource';
import { TimeEntryResource } from 'core-app/features/hal/resources/time-entry-resource';
import { WorkPackageResource } from 'core-app/features/hal/resources/work-package-resource';
import { UserResource } from 'core-app/features/hal/resources/user-resource';
import { VersionResource } from 'core-app/features/hal/resources/version-resource';
-import { QueryFilterInstanceSchemaResource } from 'core-app/features/hal/resources/query-filter-instance-schema-resource';
+import { HalResource } from 'core-app/features/hal/resources/hal-resource';
import { StatusResource } from 'core-app/features/hal/resources/status-resource';
-import { QuerySortByResource } from 'core-app/features/hal/resources/query-sort-by-resource';
+import { CapabilityResource } from 'core-app/features/hal/resources/capability-resource';
import { PlaceholderUserResource } from 'core-app/features/hal/resources/placeholder-user-resource';
-import { QueryGroupByResource } from 'core-app/features/hal/resources/query-group-by-resource';
import { RoleResource } from 'core-app/features/hal/resources/role-resource';
import { ProjectResource } from 'core-app/features/hal/resources/project-resource';
import { PostResource } from 'core-app/features/hal/resources/post-resource';
@@ -60,11 +53,11 @@ export class States extends StatesGroup {
/* /api/v3/roles */
roles = multiInput<RoleResource>();
- // Work Package query states
- queries = new QueryAvailableDataStates();
-
// Global events to isolated changes
- changes = new GlobalStateChanges();
+ changes = {
+ // Global subject on changes to the given query ID
+ queries: new Subject(),
+ };
// Additional state map that can be dynamically registered.
additional:{ [id:string]:MultiInputState<unknown> } = {};
@@ -90,25 +83,3 @@ export class States extends StatesGroup {
this.additional[name] = state;
}
}
-
-export class GlobalStateChanges {
- // Global subject on changes to the given query ID
- queries = new Subject();
-}
-
-export class QueryAvailableDataStates {
- // Available columns
- columns = input<QueryColumn[]>();
-
- // Available SortBy Columns
- sortBy = input<QuerySortByResource[]>();
-
- // Available GroupBy columns
- groupBy = input<QueryGroupByResource[]>();
-
- // Available filter schemas (derived from their schema)
- filters = input<QueryFilterInstanceSchemaResource[]>();
-
- // Display of the WP results
- displayRepresentation = input<WorkPackageDisplayRepresentationValue|null>();
-}
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 235afb7e44f..093a9eb748e 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
@@ -91,10 +91,10 @@ export class WorkPackageStatesInitializationService {
this.wpTableFilters.initializeFilters(query, schema);
this.querySpace.queryForm.putValue(form);
- this.states.queries.columns.putValue(schema.columns.allowedValues);
- this.states.queries.sortBy.putValue(schema.sortBy.allowedValues);
- this.states.queries.groupBy.putValue(schema.groupBy.allowedValues);
- this.states.queries.displayRepresentation.putValue(schema.displayRepresentation.allowedValues);
+ this.querySpace.available.columns.putValue(schema.columns.allowedValues);
+ this.querySpace.available.sortBy.putValue(schema.sortBy.allowedValues);
+ this.querySpace.available.groupBy.putValue(schema.groupBy.allowedValues);
+ this.querySpace.available.displayRepresentation.putValue(schema.displayRepresentation.allowedValues);
}
public updateQuerySpace(query:QueryResource, results:WorkPackageCollectionResource) {
diff --git a/frontend/src/app/features/work-packages/components/wp-table/embedded/wp-embedded-table.component.ts b/frontend/src/app/features/work-packages/components/wp-table/embedded/wp-embedded-table.component.ts
index 7d4c153c717..ecbd8aaa06e 100644
--- a/frontend/src/app/features/work-packages/components/wp-table/embedded/wp-embedded-table.component.ts
+++ b/frontend/src/app/features/work-packages/components/wp-table/embedded/wp-embedded-table.component.ts
@@ -101,11 +101,7 @@ export class WorkPackageEmbeddedTableComponent extends WorkPackageEmbeddedBaseCo
}
protected initializeStates(query:QueryResource) {
- // If the configuration requests filters, we need to load the query form as well.
- if (this.configuration.withFilters) {
- this.loadForm(query);
- }
-
+ void this.loadForm(query);
super.initializeStates(query);
this.querySpace
diff --git a/frontend/src/app/features/work-packages/directives/query-space/isolated-query-space.ts b/frontend/src/app/features/work-packages/directives/query-space/isolated-query-space.ts
index 4291e82f042..daaea2d562d 100644
--- a/frontend/src/app/features/work-packages/directives/query-space/isolated-query-space.ts
+++ b/frontend/src/app/features/work-packages/directives/query-space/isolated-query-space.ts
@@ -4,17 +4,20 @@ import {
import { Subject } from 'rxjs';
import { Injectable } from '@angular/core';
import { map } from 'rxjs/operators';
+import { QueryColumn } from 'core-app/features/work-packages/components/wp-query/query-column';
+import {
+ GroupObject,
+ WorkPackageCollectionResource,
+} from 'core-app/features/hal/resources/wp-collection-resource';
import { QueryResource } from 'core-app/features/hal/resources/query-resource';
+import { WorkPackageDisplayRepresentationValue } from 'core-app/features/work-packages/routing/wp-view-base/view-services/wp-view-display-representation.service';
+import { QueryFilterInstanceSchemaResource } from 'core-app/features/hal/resources/query-filter-instance-schema-resource';
import { QueryFormResource } from 'core-app/features/hal/resources/query-form-resource';
-import { QueryColumn } from 'core-app/features/work-packages/components/wp-query/query-column';
-import { GroupObject, WorkPackageCollectionResource } from 'core-app/features/hal/resources/wp-collection-resource';
+import { QuerySortByResource } from 'core-app/features/hal/resources/query-sort-by-resource';
+import { QueryGroupByResource } from 'core-app/features/hal/resources/query-group-by-resource';
@Injectable()
export class IsolatedQuerySpace extends StatesGroup {
- constructor() {
- super();
- }
-
name = 'IsolatedQuerySpace';
// The query that results in this table state
@@ -57,4 +60,22 @@ export class IsolatedQuerySpace extends StatesGroup {
// Input state that emits whenever table services have initialized
initialized = input<unknown>();
+
+ // Available states
+ available = {
+ // Available columns
+ columns: input<QueryColumn[]>(),
+
+ // Available SortBy Columns
+ sortBy: input<QuerySortByResource[]>(),
+
+ // Available GroupBy columns
+ groupBy: input<QueryGroupByResource[]>(),
+
+ // Available filter schemas (derived from their schema)
+ filters: input<QueryFilterInstanceSchemaResource[]>(),
+
+ // Display of the WP results
+ displayRepresentation: input<WorkPackageDisplayRepresentationValue|null>(),
+ };
}
diff --git a/frontend/src/app/features/work-packages/routing/wp-view-base/view-services/wp-view-columns.service.ts b/frontend/src/app/features/work-packages/routing/wp-view-base/view-services/wp-view-columns.service.ts
index 5025f9203e6..bf4a57aa95f 100644
--- a/frontend/src/app/features/work-packages/routing/wp-view-base/view-services/wp-view-columns.service.ts
+++ b/frontend/src/app/features/work-packages/routing/wp-view-base/view-services/wp-view-columns.service.ts
@@ -245,7 +245,7 @@ export class WorkPackageViewColumnsService extends WorkPackageQueryStateService<
// Get the available state
protected get availableState() {
- return this.states.queries.columns;
+ return this.querySpace.available.columns;
}
/**
diff --git a/frontend/src/app/features/work-packages/routing/wp-view-base/view-services/wp-view-filters.service.ts b/frontend/src/app/features/work-packages/routing/wp-view-base/view-services/wp-view-filters.service.ts
index 50078f74998..c7ab2cec99d 100644
--- a/frontend/src/app/features/work-packages/routing/wp-view-base/view-services/wp-view-filters.service.ts
+++ b/frontend/src/app/features/work-packages/routing/wp-view-base/view-services/wp-view-filters.service.ts
@@ -93,7 +93,7 @@ export class WorkPackageViewFiltersService extends WorkPackageQueryStateService<
}
public get availableState():InputState<QueryFilterInstanceSchemaResource[]> {
- return this.states.queries.filters;
+ return this.querySpace.available.filters;
}
/** Return whether the filters the user is working on are incomplete */
diff --git a/frontend/src/app/features/work-packages/routing/wp-view-base/view-services/wp-view-group-by.service.ts b/frontend/src/app/features/work-packages/routing/wp-view-base/view-services/wp-view-group-by.service.ts
index 73243550efc..9d49608cedc 100644
--- a/frontend/src/app/features/work-packages/routing/wp-view-base/view-services/wp-view-group-by.service.ts
+++ b/frontend/src/app/features/work-packages/routing/wp-view-base/view-services/wp-view-group-by.service.ts
@@ -82,7 +82,7 @@ export class WorkPackageViewGroupByService extends WorkPackageQueryStateService<
}
protected get availableState() {
- return this.states.queries.groupBy;
+ return this.querySpace.available.groupBy;
}
public get isEnabled():boolean {
diff --git a/frontend/src/app/features/work-packages/routing/wp-view-base/view-services/wp-view-sort-by.service.ts b/frontend/src/app/features/work-packages/routing/wp-view-base/view-services/wp-view-sort-by.service.ts
index 20d16e390c1..e98ae54c943 100644
--- a/frontend/src/app/features/work-packages/routing/wp-view-base/view-services/wp-view-sort-by.service.ts
+++ b/frontend/src/app/features/work-packages/routing/wp-view-base/view-services/wp-view-sort-by.service.ts
@@ -52,7 +52,7 @@ export class WorkPackageViewSortByService extends WorkPackageQueryStateService<Q
}
public onReadyWithAvailable():Observable<null> {
- return combine(this.pristineState, this.states.queries.sortBy)
+ return combine(this.pristineState, this.querySpace.available.sortBy)
.values$()
.pipe(
mapTo(null),
@@ -140,7 +140,7 @@ export class WorkPackageViewSortByService extends WorkPackageQueryStateService<Q
}
private get availableState() {
- return this.states.queries.sortBy;
+ return this.querySpace.available.sortBy;
}
public get available():QuerySortByResource[] {
diff --git a/spec/features/work_packages/details/relations/hierarchy_spec.rb b/spec/features/work_packages/details/relations/hierarchy_spec.rb
index e7e0f3b5505..e2684f57e31 100644
--- a/spec/features/work_packages/details/relations/hierarchy_spec.rb
+++ b/spec/features/work_packages/details/relations/hierarchy_spec.rb
@@ -85,6 +85,56 @@ shared_examples 'work package relations tab', js: true, selenium: true do
tabs.expect_counter(relations_tab, 2)
end
+ context 'when switching to custom field with required CF' do
+ let(:custom_field) do
+ FactoryBot.create(
+ :work_package_custom_field,
+ field_format: 'string',
+ default_value: nil,
+ is_required: true,
+ is_for_all: true
+ )
+ end
+ let(:type2) { FactoryBot.create(:type, custom_fields: [custom_field]) }
+ let(:relations) { ::Components::WorkPackages::Relations.new(parent) }
+ let!(:status) { FactoryBot.create(:status, is_default: true) }
+ let!(:priority) { FactoryBot.create(:priority, is_default: true) }
+
+ before do
+ project.types << type2
+ project.save!
+ custom_field
+ end
+
+ it 'shows the required field when switching' do
+ relations.inline_create_child 'my new child'
+ table = relations.children_table
+
+ table.expect_work_package_subject 'my new child'
+ wp = WorkPackage.find_by!(subject: 'my new child')
+ type_field = table.edit_field(wp, :type)
+
+ type_field.activate!
+ type_field.set_value type2.name
+
+ wp_page.expect_notification message: "#{custom_field.name} can't be blank.",
+ type: 'error'
+
+ cf_field = wp_page.edit_field("customField#{custom_field.id}")
+ cf_field.expect_active!
+ cf_field.expect_value('')
+
+ cf_field.set_value 'my value'
+ cf_field.save!
+
+ wp_page.expect_notification message: "Successful update.",
+ type: 'success'
+
+ wp.reload
+ expect(wp.custom_value_for(custom_field).value).to eq 'my value'
+ end
+ end
+
describe 'inline create' do
let!(:status) { FactoryBot.create(:status, is_default: true) }
let!(:priority) { FactoryBot.create(:priority, is_default: true) }