From 5493ce5d6e2fb5667548b5e2cac7d88adb76fc18 Mon Sep 17 00:00:00 2001 From: Matthew Ross Date: Sun, 28 Jun 2020 10:24:26 -0400 Subject: [PATCH] Update task visually when changed by drag and drop. Fixes #507. --- README.md | 10 ++++----- src/app/board/column/column.component.ts | 27 +++++++++++++++++++++++- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 113ddaf..b64f540 100644 --- a/README.md +++ b/README.md @@ -195,11 +195,11 @@ Because I like seeing the numbers. Language | Files | Blank | Comment | Code -----------|--------:|---------:|---------:|---------: -TypeScript | 67 | 978 | 129 | 4107 -PHP | 20 | 752 | 40 | 2265 -HTML | 21 | 268 | 2 | 1573 -SASS | 14 | 299 | 10 | 1347 -**SUM:** | **122** | **2297** | **181** | **9292** +TypeScript | 69 | 1032 | 122 | 4307 +PHP | 21 | 790 | 40 | 2396 +HTML | 22 | 287 | 2 | 1604 +SASS | 14 | 302 | 10 | 1365 +**SUM:** | **126** | **2411** | **174** | **9672** Command: `cloc --exclude-dir=vendor,favicons --exclude-ext=json,svg,ini src/` diff --git a/src/app/board/column/column.component.ts b/src/app/board/column/column.component.ts index 273b9c0..7c5f4d0 100644 --- a/src/app/board/column/column.component.ts +++ b/src/app/board/column/column.component.ts @@ -244,6 +244,11 @@ export class ColumnDisplayComponent implements OnInit, OnDestroy { updateTaskColorByCategory(event: Category[]) { this.modalProps.categories = event; + + if (!event.length) { + return; + } + this.modalProps.color = event[event.length - 1].default_task_color; } @@ -299,7 +304,27 @@ export class ColumnDisplayComponent implements OnInit, OnDestroy { }); const task = this.activeBoard.columns[colIndex].tasks[event.currentIndex]; - this.boardService.updateTask(task).subscribe(() => {}); + this.boardService.updateTask(task).subscribe((response: ApiResponse) => { + response.alerts.forEach(alert => { + if (alert.type === 'success') { + return; // No need to show "task updated" for drag and drop + } + + this.notes.add(alert); + }); + + if (response.status !== 'success') { + return; + } + + const newTask = response.data[1][0]; + const updatedTask = new Task(newTask.id, newTask.title, newTask.description, + newTask.color, newTask.due_date, newTask.points, + newTask.position, newTask.column_id, newTask.ownComment, + newTask.ownAttachment, newTask.sharedUser, newTask.sharedCategory); + + this.activeBoard.columns[colIndex].tasks[event.currentIndex] = updatedTask; + }); } updateTask() {