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

[59556] Filter out root item of hierarchy filter

Andreas Pfohl650c67833f6f
diff --git a/frontend/src/app/features/work-packages/components/filters/filter-searchable-multiselect-value/filter-searchable-multiselect-value.component.ts b/frontend/src/app/features/work-packages/components/filters/filter-searchable-multiselect-value/filter-searchable-multiselect-value.component.ts
index bf5db2d53ee..dd259d3ed05 100644
--- a/frontend/src/app/features/work-packages/components/filters/filter-searchable-multiselect-value/filter-searchable-multiselect-value.component.ts
+++ b/frontend/src/app/features/work-packages/components/filters/filter-searchable-multiselect-value/filter-searchable-multiselect-value.component.ts
@@ -109,19 +109,29 @@ export class FilterSearchableMultiselectValueComponent extends UntilDestroyedMix
switchMap((initialLoad) => {
// If we already loaded all values, just compare in the frontend
if (initialLoad.count === initialLoad.total) {
- return this.matchingItems(initialLoad.elements, matching);
+ return this.matchingItems(this.filterEmptyElements(initialLoad.elements), matching);
}
// Otherwise, request the matching API call
return this
.loadCollection(matching)
.pipe(
- switchMap((collection) => this.withMeValue(matching, collection.elements)),
+ switchMap(
+ (collection) =>
+ this.withMeValue(
+ matching,
+ this.filterEmptyElements(collection.elements),
+ ),
+ ),
);
}),
);
}
+ private filterEmptyElements(elements:HalResource[]):HalResource[] {
+ return elements.filter((element) => element.name.trim().length !== 0);
+ }
+
matchingItems(elements:HalResource[], matching:string):Observable<HalResource[]> {
let filtered:HalResource[];
diff --git a/frontend/src/app/shared/components/autocompleter/op-autocompleter/op-autocompleter.component.html b/frontend/src/app/shared/components/autocompleter/op-autocompleter/op-autocompleter.component.html
index 69fd0b2cb05..26deec10a6e 100644
--- a/frontend/src/app/shared/components/autocompleter/op-autocompleter/op-autocompleter.component.html
+++ b/frontend/src/app/shared/components/autocompleter/op-autocompleter/op-autocompleter.component.html
@@ -134,6 +134,14 @@
</div>
<ng-template let-item let-search="search" #defaultOption [ngSwitch]="true">
+ <ng-container *ngSwitchCase="!resource && item.depth !== null">
+ <span [ngOptionHighlight]="search"
+ [textContent]="item.name"
+ [ngStyle]="{'padding-left.px': item.depth * 16}"
+ class="ng-option-label ellipsis">
+ </span>
+ </ng-container>
+
<ng-container *ngSwitchCase="resource === 'work_packages' || resource === 'parent-child'">
<div class="op-autocompleter--option-wrapper">
<op-principal
@@ -167,7 +175,7 @@
<span
class="op-autocompleter--wp-id"
[ngOptionHighlight]="search"
- >#{{item.id}}</span>
+ >#{{ item.id }}</span>
<span
[textContent]="item.status?.name"
@@ -195,7 +203,7 @@
</ng-container>
<ng-container
- *ngSwitchCase="resource ==='subproject' || resource ==='version' || resource ==='status' || resource ==='default' || !resource">
+ *ngSwitchCase="resource ==='subproject' || resource ==='version' || resource ==='status' || resource ==='default' || (!resource && item.depth === null)">
<span [ngOptionHighlight]="search">{{ item.name }}</span>
<span
class="op-autocompleter__option-principal-email"
@@ -212,7 +220,7 @@
class="ng-value-label"
[ngOptionHighlight]="search"
>
- {{item.type?.name }} #{{ item.id }} {{ item.subject || item.name }}
+ {{ item.type?.name }} #{{ item.id }} {{ item.subject || item.name }}
</span>
</ng-container>
@@ -220,6 +228,6 @@
<span class="ng-value-icon left" (click)="clear(item)">×</span>
<span
[ngOptionHighlight]="search"
- class="ng-value-label">{{item.name}}</span>
+ class="ng-value-label">{{ item.name }}</span>
</ng-container>
</ng-template>