Skip to content
Snippets Groups Projects
Commit 96ec0025 authored by Tom Käsler's avatar Tom Käsler
Browse files

Merge branch 'deleteComments3088' into 'master'

Delete comments

See merge request swtp-2019/arsnova-lite!41
parents 0d434c36 e2742bc8
No related merge requests found
......@@ -49,6 +49,9 @@
<button mat-icon-button (focus)="hideCommentsList=false" (click)="sortTimeStamp()">
<mat-icon color="primary">remove</mat-icon>
</button>
<button mat-icon-button *ngIf="userRole === 1" (focus)="hideCommentsList=false" (click)="deleteComments()">
<mat-icon color="primary">delete</mat-icon>
</button>
</div>
</mat-menu>
</div>
......
......@@ -140,6 +140,13 @@ export class CommentListComponent implements OnInit {
}
}
break;
case 'CommentDeleted':
for (let i = 0; i < this.comments.length; i++) {
this.comments = this.comments.filter(function (el) {
return el.id !== payload.id;
});
}
break;
}
}
......@@ -200,4 +207,8 @@ export class CommentListComponent implements OnInit {
return +dateB - +dateA;
});
}
deleteComments(): void {
this.commentService.deleteCommentsByRoomId(this.roomId).subscribe();
}
}
......@@ -66,4 +66,12 @@ export class CommentService extends BaseHttpService {
catchError(this.handleError<any>('updateComment'))
);
}
deleteCommentsByRoomId(roomId: string): Observable<Comment> {
const connectionUrl = `${this.apiUrl.base + this.apiUrl.comment}/byRoom?roomId=${roomId}`;
return this.http.delete<Comment>(connectionUrl, httpOptions).pipe(
tap(_ => ''),
catchError(this.handleError<Comment>('deleteComment'))
);
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment