From 889672f035397a7a51e053248244d5cacc4ba37f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20Mau=C3=9F?= <lukas.mauss@mni.thm.de> Date: Sun, 8 Apr 2018 19:37:16 +0200 Subject: [PATCH] Adjust delete-functions in room-, content- and comment-service so that they only need the id --- .../fragments/comment-list/comment-list.component.ts | 2 +- src/app/components/pages/room-page/room-page.component.ts | 2 +- src/app/services/http/comment.service.ts | 8 ++++---- src/app/services/http/content.service.ts | 4 ++-- src/app/services/http/room.service.ts | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/app/components/fragments/comment-list/comment-list.component.ts b/src/app/components/fragments/comment-list/comment-list.component.ts index 0884f0307..dee58c5af 100644 --- a/src/app/components/fragments/comment-list/comment-list.component.ts +++ b/src/app/components/fragments/comment-list/comment-list.component.ts @@ -52,7 +52,7 @@ export class CommentListComponent implements OnInit { delete(comment: Comment): void { this.comments = this.comments.filter(c => c !== comment); - this.commentService.deleteComment(comment).subscribe(room => { + this.commentService.deleteComment(comment.id).subscribe(room => { this.notification.show(`Comment '${comment.subject}' successfully deleted.`); }); } diff --git a/src/app/components/pages/room-page/room-page.component.ts b/src/app/components/pages/room-page/room-page.component.ts index 74b9e8a8f..7a79ee8e6 100644 --- a/src/app/components/pages/room-page/room-page.component.ts +++ b/src/app/components/pages/room-page/room-page.component.ts @@ -32,7 +32,7 @@ export class RoomPageComponent implements OnInit { } delete(room: Room): void { - this.roomService.deleteRoom(room).subscribe(); + this.roomService.deleteRoom(room.id).subscribe(); this.location.back(); } } diff --git a/src/app/services/http/comment.service.ts b/src/app/services/http/comment.service.ts index 2d6e2f1c8..ee399e111 100644 --- a/src/app/services/http/comment.service.ts +++ b/src/app/services/http/comment.service.ts @@ -21,8 +21,8 @@ export class CommentService extends BaseHttpService { super(); } - getComment(comment: Comment): Observable<Comment> { - const connectionUrl = `${ this.apiUrl.base }${ this.apiUrl.comment }/~${comment.id}`; + getComment(commentId: string): Observable<Comment> { + const connectionUrl = `${ this.apiUrl.base }${ this.apiUrl.comment }/~${ commentId }`; return this.http.get<Comment>(connectionUrl, httpOptions).pipe( tap (_ => ''), catchError(this.handleError<Comment>('addComment')) @@ -40,8 +40,8 @@ export class CommentService extends BaseHttpService { ); } - deleteComment(comment: Comment): Observable<Comment> { - const connectionUrl = `${this.apiUrl.base + this.apiUrl.comment }/${comment.id}`; + deleteComment(commentId: string): Observable<Comment> { + const connectionUrl = `${ this.apiUrl.base + this.apiUrl.comment }/${ commentId }`; return this.http.delete<Comment>(connectionUrl, httpOptions).pipe( tap (_ => ''), catchError(this.handleError<Comment>('deleteComment')) diff --git a/src/app/services/http/content.service.ts b/src/app/services/http/content.service.ts index 90a81a621..3717799a3 100644 --- a/src/app/services/http/content.service.ts +++ b/src/app/services/http/content.service.ts @@ -60,8 +60,8 @@ export class ContentService extends BaseHttpService { ); } - deleteContent(content: Content): Observable<Content> { - const connectionUrl = this.apiUrl.base + this.apiUrl.content + '/' + content.contentId; + deleteContent(contentId: string): Observable<Content> { + const connectionUrl = this.apiUrl.base + this.apiUrl.content + '/' + contentId; return this.http.delete<Content>(connectionUrl, httpOptions).pipe( tap (_ => ''), catchError(this.handleError<Content>('deleteContent')) diff --git a/src/app/services/http/room.service.ts b/src/app/services/http/room.service.ts index 6c2eab3f5..810bdb6b1 100644 --- a/src/app/services/http/room.service.ts +++ b/src/app/services/http/room.service.ts @@ -75,8 +75,8 @@ export class RoomService extends BaseHttpService { ); } - deleteRoom(room: Room): Observable<Room> { - const connectionUrl = `${ this.apiUrl.base + this.apiUrl.rooms }/${ room.id }`; + deleteRoom(roomId: string): Observable<Room> { + const connectionUrl = `${ this.apiUrl.base + this.apiUrl.rooms }/${ roomId }`; return this.http.delete<Room>(connectionUrl, httpOptions).pipe( tap(() => ''), catchError(this.handleError<Room>('deleteRoom')) -- GitLab