#2408 Added the feature to delete comments on issues

pull/2452/head
Jamie 6 years ago
parent eecf1de303
commit d98dafb8d2

@ -46,6 +46,7 @@ export interface IIssueComments {
}
export interface IIssuesChat {
id: number;
comment: string;
date: Date;
username: string;

@ -51,15 +51,17 @@
<div *ngIf="comments" class="panel-body msg_container_base">
<div *ngIf="comments.length <= 0" class="row msg_container base_receive">
<div class="col-md-10 col-xs-10">
<div class="messages msg_sent">
<p [translate]="'Issues.NoComments'"></p>
<div class="messages msg_sent">
<p [translate]="'Issues.NoComments'"></p>
</div>
</div>
</div>
<div *ngFor="let comment of comments" class="row msg_container" [ngClass]="{'base_sent': comment.adminComment, 'base_receive': !comment.adminComment}">
<div class="col-md-10 col-xs-10">
<div class="messages msg_sent">
<div class="messages msg_sent"> <i *ngIf="isAdmin" style="float:right;" class="fa fa-times" aria-hidden="true" (click)="deleteComment(comment.id)"></i>
<p>{{comment.comment}}</p>
<time>{{comment.username}} • {{comment.date | date:'short'}}</time>
</div>

@ -97,6 +97,13 @@ export class IssueDetailsComponent implements OnInit {
});
}
public deleteComment(id: number) {
this.issueService.deleteComment(id).subscribe(x => {
this.loadComments();
this.notificationService.success("Comment Deleted");
});
}
private loadComments() {
this.issueService.getComments(this.issueId).subscribe(x => this.comments = x);
}

@ -56,4 +56,8 @@ export class IssuesService extends ServiceHelpers {
public updateStatus(model: IUpdateStatus): Observable<boolean> {
return this.http.post<boolean>(`${this.url}status`, JSON.stringify(model), { headers: this.headers });
}
public deleteComment(id: number): Observable<boolean> {
return this.http.delete<boolean>(`${this.url}comments/${id}`, { headers: this.headers });
}
}

@ -182,6 +182,7 @@ namespace Ombi.Controllers
var roles = await _userManager.GetRolesAsync(c.User);
vm.Add(new IssueCommentChatViewModel
{
Id = c.Id,
Comment = c.Comment,
Date = c.Date,
Username = c.User.UserAlias,
@ -245,9 +246,9 @@ namespace Ombi.Controllers
/// </summary>
[HttpDelete("comments/{id:int}")]
[PowerUser]
public async Task<bool> DeleteComment(int commentId)
public async Task<bool> DeleteComment(int id)
{
var comment = await _issueComments.GetAll().FirstOrDefaultAsync(x => x.Id == commentId);
var comment = await _issueComments.GetAll().FirstOrDefaultAsync(x => x.Id == id);
await _issueComments.Delete(comment);
return true;

@ -4,6 +4,7 @@ namespace Ombi.Models
{
public class IssueCommentChatViewModel
{
public int Id { get; set; }
public string Comment { get; set; }
public DateTime Date { get; set; }
public string Username { get; set; }

Loading…
Cancel
Save