Add cancel option when editing comments
This commit is contained in:
parent
7531d645b4
commit
6987bb9338
@ -169,7 +169,7 @@
|
||||
*ngIf="!comment.isEdit"></div>
|
||||
|
||||
<textarea *ngIf="comment.isEdit"
|
||||
[(ngModel)]="comment.text"
|
||||
[(ngModel)]="commentEdit.text"
|
||||
(keyup.enter)="$event.stopPropagation()"></textarea>
|
||||
|
||||
<div class="byline">
|
||||
@ -180,14 +180,19 @@
|
||||
</div>
|
||||
|
||||
<div class="actions" *ngIf="canAdminComment(comment)">
|
||||
<i class="icon icon-cancel"
|
||||
[title]="strings['cancel']"
|
||||
*ngIf="comment.isEdit"
|
||||
(click)="comment.isEdit = false"></i>
|
||||
<i class="icon icon-floppy color-primary"
|
||||
[title]="strings['save']"
|
||||
*ngIf="comment.isEdit"
|
||||
(click)="comment.isEdit = false;editComment(comment)"></i>
|
||||
(click)="comment.isEdit = false;editComment()"></i>
|
||||
|
||||
<i class="icon icon-edit color-primary"
|
||||
[title]="strings['boards_taskEditComment']"
|
||||
*ngIf="!comment.isEdit"
|
||||
(click)="comment.isEdit = true"></i>
|
||||
(click)="comment.isEdit = true;beginEditComment(comment)"></i>
|
||||
<i class="icon icon-trash-empty color-secondary"
|
||||
[title]="strings['boards_taskRemoveComment']"
|
||||
(click)="commentToRemove=comment;
|
||||
|
@ -62,6 +62,7 @@ export class ColumnDisplay implements OnInit {
|
||||
private viewModalProps: Task;
|
||||
private taskToRemove: number;
|
||||
private taskLimit: number;
|
||||
private commentEdit: Comment;
|
||||
private commentToRemove: Comment;
|
||||
|
||||
private newComment: string;
|
||||
@ -274,11 +275,15 @@ export class ColumnDisplay implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
editComment(comment: Comment) {
|
||||
comment.is_edited = true;
|
||||
comment.user_id = this.activeUser.id;
|
||||
beginEditComment(comment: Comment) {
|
||||
this.commentEdit = { ...comment };
|
||||
}
|
||||
|
||||
this.boardService.updateComment(comment)
|
||||
editComment() {
|
||||
this.commentEdit.is_edited = true;
|
||||
this.commentEdit.user_id = this.activeUser.id;
|
||||
|
||||
this.boardService.updateComment(this.commentEdit)
|
||||
.subscribe((response: ApiResponse) => {
|
||||
response.alerts.forEach(note => this.notes.add(note));
|
||||
|
||||
@ -288,6 +293,8 @@ export class ColumnDisplay implements OnInit {
|
||||
|
||||
let updatedTask = response.data[1][0];
|
||||
this.replaceUpdatedTask(updatedTask);
|
||||
|
||||
this.viewModalProps = this.convertToTask(updatedTask);
|
||||
});
|
||||
}
|
||||
|
||||
@ -364,6 +371,22 @@ export class ColumnDisplay implements OnInit {
|
||||
return yiq >= 140 ? '#333333' : '#efefef';
|
||||
}
|
||||
|
||||
private convertToTask(updatedTask: any) {
|
||||
let task = new Task(updatedTask.id,
|
||||
updatedTask.title,
|
||||
updatedTask.description,
|
||||
updatedTask.color,
|
||||
updatedTask.due,
|
||||
updatedTask.points,
|
||||
updatedTask.position,
|
||||
updatedTask.column_id,
|
||||
updatedTask.ownComment,
|
||||
updatedTask.ownAttachment,
|
||||
updatedTask.sharedUser,
|
||||
updatedTask.sharedCategory);
|
||||
return task;
|
||||
}
|
||||
|
||||
private replaceUpdatedTask(updatedTask: any) {
|
||||
this.activeBoard.columns.forEach(column => {
|
||||
if (+column.id !== +updatedTask.column_id) {
|
||||
|
Reference in New Issue
Block a user