From 8fd52e7beda5a271e6593ebb5e58c9b0ec55a488 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Wed, 20 Dec 2017 00:26:56 +0200 Subject: [PATCH] Working on task kanban --- app/Http/Controllers/TaskKanbanController.php | 31 +++++++++++++++++++ resources/views/tasks/kanban.blade.php | 1 + 2 files changed, 32 insertions(+) diff --git a/app/Http/Controllers/TaskKanbanController.php b/app/Http/Controllers/TaskKanbanController.php index bafbe63229..cf6886e7df 100644 --- a/app/Http/Controllers/TaskKanbanController.php +++ b/app/Http/Controllers/TaskKanbanController.php @@ -32,6 +32,7 @@ class TaskKanbanController extends BaseController // check initial statuses exist if (! $statuses->count()) { $statuses = collect([]); + $firstStatus = false; $defaults = [ 'backlog', 'ready_to_do', @@ -44,6 +45,36 @@ class TaskKanbanController extends BaseController $status->sort_order = $i; $status->save(); $statuses[] = $status; + if (! $firstStatus) { + $firstStatus = $status; + } + } + $i = 0; + foreach ($tasks as $task) { + $task->task_status_id = $firstStatus->id; + $task->task_status_sort_order = $i++; + $task->save(); + } + // otherwise, check that the tasks orders are correct + } else { + $firstStatus = $statuses[0]; + $adjustment = 0; + $counts = []; + foreach ($tasks as $task) { + if (! $task->task_status_id) { + $task->task_status_id = $firstStatus->id; + $task->setRelation('task_status', $firstStatus); + } + if (! isset($counts[$task->task_status_id])) { + $counts[$task->task_status_id] = 0; + } + if ($task->task_status_sort_order != $counts[$task->task_status_id]) { + $task->task_status_sort_order = $counts[$task->task_status_id]; + } + $counts[$task->task_status_id]++; + if ($task->isDirty()) { + $task->save(); + } } } diff --git a/resources/views/tasks/kanban.blade.php b/resources/views/tasks/kanban.blade.php index 44be22bce2..a83d3e36ae 100644 --- a/resources/views/tasks/kanban.blade.php +++ b/resources/views/tasks/kanban.blade.php @@ -8,6 +8,7 @@ .kanban { overflow-x: auto; white-space: nowrap; + min-height: 400px; } .kanban input {