From cff9be19876adf8705168acfe4814a5d4c295385 Mon Sep 17 00:00:00 2001 From: Matthew Ross Date: Thu, 2 Apr 2020 12:23:15 -0400 Subject: [PATCH] Allow Ctrl+Enter to submit comments (and comment edits). Fixes #302 --- src/app/board/column/column.component.html | 6 ++-- src/app/board/column/column.component.ts | 38 +++++++++++++++------- 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/src/app/board/column/column.component.html b/src/app/board/column/column.component.html index ea16e32..8cee99e 100644 --- a/src/app/board/column/column.component.html +++ b/src/app/board/column/column.component.html @@ -173,7 +173,8 @@ + (keyup.control.enter)="comment.isEdit = false;editComment()" + (keyup.enter)="preventEnter($event)">
{{ comment.is_edited ? strings['boards_editedBy'] @@ -208,8 +209,9 @@

{{ strings['boards_taskAddComment'] }}

- diff --git a/src/app/board/column/column.component.ts b/src/app/board/column/column.component.ts index d5daa72..28b17b8 100644 --- a/src/app/board/column/column.component.ts +++ b/src/app/board/column/column.component.ts @@ -304,8 +304,10 @@ export class ColumnDisplayComponent implements OnInit, OnDestroy { attachment.task_id = this.viewModalProps.id; this.boardService.uploadAttachment(attachment, formData) - .subscribe(res => { - console.log(res); + .subscribe(response => { + response.alerts.forEach(note => this.notes.add(note)); + + console.log(response); }); } @@ -330,6 +332,7 @@ export class ColumnDisplayComponent implements OnInit, OnDestroy { this.replaceUpdatedTask(updatedTask); this.viewModalProps = this.convertToTask(updatedTask); + this.updateTaskActivity(this.viewModalProps.id); }); } @@ -353,6 +356,7 @@ export class ColumnDisplayComponent implements OnInit, OnDestroy { this.replaceUpdatedTask(updatedTask); this.viewModalProps = this.convertToTask(updatedTask); + this.updateTaskActivity(this.viewModalProps.id); }); } @@ -369,6 +373,7 @@ export class ColumnDisplayComponent implements OnInit, OnDestroy { const updatedTask = response.data[1][0]; this.replaceUpdatedTask(updatedTask); + this.updateTaskActivity(this.viewModalProps.id); }); } @@ -523,7 +528,7 @@ export class ColumnDisplayComponent implements OnInit, OnDestroy { } getUserName(userId: number) { - const user = this.activeBoard.users.find((test: User) => test.id === userId); + const user = this.activeBoard.users.find((test: User) => test.id === +userId); return user.username; } @@ -535,17 +540,10 @@ export class ColumnDisplayComponent implements OnInit, OnDestroy { showViewModal(taskId: number) { const viewTask = this.columnData.tasks.find(task => task.id === taskId); - this.viewTaskActivities = []; - this.boardService.getTaskActivity(viewTask.id) - .subscribe(response => { - response.data[1].forEach((item: any) => { - this.viewTaskActivities.push( - new ActivitySimple(item.text, item.timestamp)); - }); - }); + this.updateTaskActivity(taskId); this.newComment = ''; - this.viewModalProps = this.convertToTask(viewTask); + this.viewModalProps = Object.assign({}, viewTask); this.checkDueDate(); if (this.showActivity) { @@ -562,6 +560,18 @@ export class ColumnDisplayComponent implements OnInit, OnDestroy { } } + private updateTaskActivity(id: number) { + this.viewTaskActivities = []; + + this.boardService.getTaskActivity(id) + .subscribe(response => { + response.data[1].forEach((item: any) => { + this.viewTaskActivities.push( + new ActivitySimple(item.text, item.timestamp)); + }); + }); + } + private convertToTask(updatedTask: any) { const task = new Task(updatedTask.id, updatedTask.title, @@ -602,6 +612,10 @@ export class ColumnDisplayComponent implements OnInit, OnDestroy { private updateTaskComments(task: Task, newComments: Array) { task.comments = []; + if (!newComments) { + return; + } + newComments.forEach(comment => { task.comments.push( new Comment(comment.id, comment.text, comment.user_id,