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 project grouping to work package version multiselect editing field

Dombi Attila7d2c0de0cc76
diff --git a/frontend/src/app/shared/components/fields/edit/field-types/multi-select-edit-field.component.html b/frontend/src/app/shared/components/fields/edit/field-types/multi-select-edit-field.component.html
index fb876a5777b..f2b57acbac9 100644
--- a/frontend/src/app/shared/components/fields/edit/field-types/multi-select-edit-field.component.html
+++ b/frontend/src/app/shared/components/fields/edit/field-types/multi-select-edit-field.component.html
@@ -16,6 +16,7 @@
[multiple]="true"
[closeOnSelect]="false"
[appendTo]="appendTo"
+ [groupBy]="groupByFn"
[dropdownPosition]="'top'"
[hideSelected]="true">
<ng-template ng-option-tmp let-item="item">
diff --git a/frontend/src/app/shared/components/fields/edit/field-types/multi-select-edit-field.component.ts b/frontend/src/app/shared/components/fields/edit/field-types/multi-select-edit-field.component.ts
index 1a199bed51c..cd4b3f3169d 100644
--- a/frontend/src/app/shared/components/fields/edit/field-types/multi-select-edit-field.component.ts
+++ b/frontend/src/app/shared/components/fields/edit/field-types/multi-select-edit-field.component.ts
@@ -29,7 +29,7 @@
import { CollectionResource } from 'core-app/features/hal/resources/collection-resource';
import { HalResource } from 'core-app/features/hal/resources/hal-resource';
import { I18nService } from 'core-app/core/i18n/i18n.service';
-import { Component, OnInit, ViewChild } from '@angular/core';
+import { Component, ChangeDetectionStrategy, OnInit, ViewChild } from '@angular/core';
import { EditFieldComponent } from 'core-app/shared/components/fields/edit/edit-field.component';
import { ValueOption } from 'core-app/shared/components/fields/edit/field-types/select-edit-field/select-edit-field.component';
import { NgSelectComponent } from '@ng-select/ng-select';
@@ -38,6 +38,7 @@ import { PathHelperService } from 'core-app/core/path-helper/path-helper.service
@Component({
templateUrl: './multi-select-edit-field.component.html',
+ changeDetection: ChangeDetectionStrategy.OnPush,
})
export class MultiSelectEditFieldComponent extends EditFieldComponent implements OnInit {
@ViewChild(NgSelectComponent, { static: true }) public ngSelectComponent:NgSelectComponent;
@@ -46,6 +47,12 @@ export class MultiSelectEditFieldComponent extends EditFieldComponent implements
@InjectField() pathHelperService:PathHelperService;
+ groupByFn = (item:HalResource):string|null => {
+ if (!this.isVersionResource) return null;
+ const project = item.definingProject as HalResource | undefined;
+ return project?.name ?? null;
+ };
+
public availableOptions:any[] = [];
public text = {
@@ -151,9 +158,8 @@ export class MultiSelectEditFieldComponent extends EditFieldComponent implements
private openAutocompleteSelectField() {
// The timeout takes care that the opening is added to the end of the current call stack.
// Thus we can be sure that the autocompleter is rendered and ready to be opened.
- const that = this;
window.setTimeout(() => {
- that.ngSelectComponent.open();
+ this.ngSelectComponent.open();
}, 0);
}
@@ -232,7 +238,7 @@ export class MultiSelectEditFieldComponent extends EditFieldComponent implements
* dropdown. For this to happen we must register a trigger target.
*/
protected getHoverCardTriggerTarget() {
- if (this.schema?.type === '[]User') {
+ if (this.isUserResource) {
return 'trigger';
}
@@ -252,4 +258,14 @@ export class MultiSelectEditFieldComponent extends EditFieldComponent implements
}
protected readonly getComputedStyle = getComputedStyle;
+
+ private get isUserResource() {
+ const type = this.schema?.type;
+ return type && type.indexOf('User') > 0;
+ }
+
+ private get isVersionResource() {
+ const type = this.schema?.type;
+ return type && type.indexOf('Version') > 0;
+ }
}