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

Allow loading multiple resources

Oliver Güntherc54f1a53a829
diff --git a/frontend/src/app/shared/components/autocompleter/op-autocompleter/services/op-autocompleter.service.ts b/frontend/src/app/shared/components/autocompleter/op-autocompleter/services/op-autocompleter.service.ts
index d41fc08d81b..84687ea90da 100644
--- a/frontend/src/app/shared/components/autocompleter/op-autocompleter/services/op-autocompleter.service.ts
+++ b/frontend/src/app/shared/components/autocompleter/op-autocompleter/services/op-autocompleter.service.ts
@@ -8,7 +8,7 @@ import { ApiV3WorkPackagePaths } from 'core-app/core/apiv3/endpoints/work_packag
import { WorkPackageResource } from 'core-app/features/hal/resources/work-package-resource';
import { HalResource } from 'core-app/features/hal/resources/hal-resource';
import { ApiV3Service } from 'core-app/core/apiv3/api-v3.service';
-import { Observable } from 'rxjs';
+import { forkJoin, Observable } from 'rxjs';
import { UntilDestroyedMixin } from 'core-app/shared/helpers/angular/until-destroyed.mixin';
@Injectable()
@@ -32,7 +32,17 @@ export class OpAutocompleterService extends UntilDestroyedMixin {
}
// A method for fetching the object for a provided value using the API
- public loadValue(id:string, resource:TOpAutocompleterResource):Observable<HalResource> {
+ public loadValue(id:string|string[], resource:TOpAutocompleterResource, multiple:boolean):Observable<HalResource|HalResource[]> {
+ if (multiple) {
+ const calls = (id as string[])
+ .map((singleId) => this.loadSingleValue(singleId, resource));
+ return forkJoin(calls);
+ }
+
+ return this.loadSingleValue(id as string, resource);
+ }
+
+ protected loadSingleValue(id:string, resource:TOpAutocompleterResource) {
return (this.apiV3Service[resource] as
ApiV3ResourceCollection<UserResource|WorkPackageResource, ApiV3UserPaths|ApiV3WorkPackagePaths>)
.id(id)