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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Restructure the frontend code to be more readable.
Pavel Balashovccd597ab9f2d
diff --git a/frontend/src/app/core/state/file-links/file-links.service.ts b/frontend/src/app/core/state/file-links/file-links.service.tsindex 0bf6115d044..ffb9345287f 100644--- a/frontend/src/app/core/state/file-links/file-links.service.ts+++ b/frontend/src/app/core/state/file-links/file-links.service.ts@@ -31,12 +31,10 @@ import { Injectable } from '@angular/core';import { HttpHeaders } from '@angular/common/http';import { from, Observable } from 'rxjs';import {- catchError,groupBy,mergeMap,reduce,switchMap,- map,tap,} from 'rxjs/operators';@@ -55,7 +53,7 @@ import idFromLink from 'core-app/features/hal/helpers/id-from-link';export class FileLinksResourceService extends ResourceCollectionService<IFileLink> {@InjectField() toastService:ToastService;- updateCollectionsForWorkPackage(fileLinksSelfLink:string):Observable<void> {+ updateCollectionsForWorkPackage(fileLinksSelfLink:string):Observable<IFileLink[]> {return this.http.get<IHALCollection<IFileLink>>(fileLinksSelfLink).pipe(@@ -72,14 +70,14 @@ export class FileLinksResourceService extends ResourceCollectionService<IFileLinreturn acc;}, seed));}),- map((fileLinkCollections) => {+ tap((fileLinkCollections) => {const storageId = idFromLink(fileLinkCollections.storage);const collectionKey = `${fileLinksSelfLink}?filters=[{"storage":{"operator":"=","values":["${storageId}"]}}]`;const collection = { _embedded: { elements: fileLinkCollections.fileLinks } } as IHALCollection<IFileLink>;insertCollectionIntoState(this.store, collection, collectionKey);}),- catchError(this.toastAndThrow.bind(this)),- ) as Observable<void>;+ reduce((acc, group) => acc.concat(group.fileLinks), [] as IFileLink[]),+ );}protected createStore():CollectionStore<IFileLink> {diff --git a/frontend/src/app/features/work-packages/routing/wp-view-base/work-package-single-view.base.ts b/frontend/src/app/features/work-packages/routing/wp-view-base/work-package-single-view.base.tsindex 9d571d144d6..74d1504f28e 100644--- a/frontend/src/app/features/work-packages/routing/wp-view-base/work-package-single-view.base.ts+++ b/frontend/src/app/features/work-packages/routing/wp-view-base/work-package-single-view.base.ts@@ -45,6 +45,9 @@ import {import {WorkPackageNotificationService,} from 'core-app/features/work-packages/services/notifications/work-package-notification.service';+import {+ switchMap,+} from 'rxjs/operators';import { InjectField } from 'core-app/shared/helpers/angular/inject-field.decorator';import { UntilDestroyedMixin } from 'core-app/shared/helpers/angular/until-destroyed.mixin';import { ApiV3Service } from 'core-app/core/apiv3/api-v3.service';@@ -194,16 +197,19 @@ export class WorkPackageSingleViewBase extends UntilDestroyedMixin {if (this.workPackage.$links.fileLinks) {this.fileLinkResourceService.updateCollectionsForWorkPackage(this.workPackage.$links.fileLinks.href as string)+ .pipe(+ this.untilDestroyed(),+ switchMap(() => this.projectsResourceService.lookup((this.workPackage.project as unknown&{ id:string }).id)),+ ).subscribe(- () => {- this.projectsResourceService- .lookup((this.workPackage.project as unknown&{ id:string }).id)- .pipe(this.untilDestroyed())- .subscribe((project) => {- if (project._links.storages) {- this.storages.updateCollection(project._links.self.href, project._links.storages);- }- });+ (project) => {+ if (project._links.storages) {+ this.storages.updateCollection(project._links.self.href, project._links.storages);+ }+ },+ (error) => {+ this.toastService.addError(error);+ throw error;},);}