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

[34884] Ensure schemas are cached in the work package collection request

Oliver Günther6a2ab0b20043
diff --git a/frontend/src/app/modules/apiv3/endpoints/work_packages/api-v3-work-package-cached-subresource.ts b/frontend/src/app/modules/apiv3/endpoints/work_packages/api-v3-work-package-cached-subresource.ts
index 7befb610f44..fbc5d08bf0c 100644
--- a/frontend/src/app/modules/apiv3/endpoints/work_packages/api-v3-work-package-cached-subresource.ts
+++ b/frontend/src/app/modules/apiv3/endpoints/work_packages/api-v3-work-package-cached-subresource.ts
@@ -32,14 +32,20 @@ import { Observable } from "rxjs";
import { APIV3WorkPackagesPaths } from "core-app/modules/apiv3/endpoints/work_packages/api-v3-work-packages-paths";
import { take, tap } from "rxjs/operators";
import { WorkPackageCache } from "core-app/modules/apiv3/endpoints/work_packages/work-package.cache";
+import { InjectField } from "core-app/helpers/angular/inject-field.decorator";
+import { States } from "core-components/states.service";
+import { CollectionResource } from "core-app/modules/hal/resources/collection-resource";
+import { SchemaResource } from "core-app/modules/hal/resources/schema-resource";
export class ApiV3WorkPackageCachedSubresource extends APIv3GettableResource<WorkPackageCollectionResource> {
+ @InjectField() private states:States;
public get():Observable<WorkPackageCollectionResource> {
return this
.halResourceService
.get<WorkPackageCollectionResource>(this.path)
.pipe(
+ tap(collection => collection.schemas && this.updateSchemas(collection.schemas)),
tap(collection => this.cache.updateWorkPackageList(collection.elements)),
take(1)
);
@@ -48,4 +54,10 @@ export class ApiV3WorkPackageCachedSubresource extends APIv3GettableResource<Wor
protected get cache():WorkPackageCache {
return (this.parent as APIV3WorkPackagesPaths).cache;
}
+
+ private updateSchemas(schemas:CollectionResource<SchemaResource>) {
+ schemas.elements.forEach(schema => {
+ this.states.schemas.get(schema.href as string).putValue(schema);
+ });
+ }
}