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

Merge branch 'chore/add-spot-hover-menu' into implementation/42158-add-direct-action-hover-menu

Eric Schubertf2a25268d569
diff --cc frontend/src/app/core/state/file-links/file-links.service.ts
index b3e242a414b,6c4474414eb..595983d05ae
--- a/frontend/src/app/core/state/file-links/file-links.service.ts
+++ b/frontend/src/app/core/state/file-links/file-links.service.ts
@@@ -27,11 -27,15 +27,16 @@@
//++
import { Injectable } from '@angular/core';
-import { HttpClient } from '@angular/common/http';
+import { HttpClient, HttpHeaders } from '@angular/common/http';
- import { applyTransaction, QueryEntity } from '@datorama/akita';
- import { from, Observable } from 'rxjs';
++import { applyTransaction } from '@datorama/akita';
+ import { from } from 'rxjs';
import {
- catchError, groupBy, map, mergeMap, reduce, switchMap, tap,
+ catchError,
+ groupBy,
+ mergeMap,
+ reduce,
+ switchMap,
+ tap,
} from 'rxjs/operators';
import { IFileLink } from 'core-app/core/state/file-links/file-link.model';
import { IHALCollection } from 'core-app/core/apiv3/types/hal-collection.type';
@@@ -79,45 -87,7 +88,39 @@@ export class FileLinksResourceService e
});
}
- collection(key:string):Observable<IFileLink[]> {
- const query = new QueryEntity(this.store);
- return query
- .select()
- .pipe(
- map((state) => state.collections[key]?.ids),
- switchMap((fileLinkIds) => query.selectMany(fileLinkIds)),
- );
+ protected createStore():CollectionStore<IFileLink> {
+ return new FileLinksStore();
}
+
+ remove(collectionKey:string, fileLink:IFileLink):void {
+ if (!fileLink._links.delete) {
+ return;
+ }
+
+ const headers = new HttpHeaders({ 'Content-Type': 'application/json' });
+ this.http
+ .delete<void>(fileLink._links.delete.href, { withCredentials: true, headers })
+ .pipe(
+ catchError((error) => {
+ this.toastService.addError(error);
+ throw error;
+ }),
+ )
+ .subscribe(() => {
+ applyTransaction(() => {
+ this.store.remove(fileLink.id);
+ this.store.update(({ collections }) => (
+ {
+ collections: {
+ ...collections,
+ [collectionKey]: {
+ ...collections[collectionKey],
+ ids: (collections[collectionKey]?.ids || []).filter((id) => id !== fileLink.id),
+ },
+ },
+ }
+ ));
+ });
+ });
+ }
}