diff --git a/app/Http/Controllers/TaskKanbanController.php b/app/Http/Controllers/TaskKanbanController.php index d4a6c20a6e06..130a0c04fdf4 100644 --- a/app/Http/Controllers/TaskKanbanController.php +++ b/app/Http/Controllers/TaskKanbanController.php @@ -100,6 +100,20 @@ class TaskKanbanController extends BaseController ->where('sort_order', '>', $status->sort_order) ->decrement('sort_order'); + $firstStatus = TaskStatus::scope() + ->orderBy('sort_order') + ->first(); + + // Move linked tasks to the end of the first status + if ($firstStatus) { + $firstCount = $firstStatus->tasks->count(); + Task::scope() + ->where('task_status_id', '=', $status->id) + ->increment('task_status_sort_order', $firstCount, [ + 'task_status_id' => $firstStatus->id + ]); + } + return response()->json(['message' => RESULT_SUCCESS]); } diff --git a/app/Models/TaskStatus.php b/app/Models/TaskStatus.php index fa3d77329a3e..d0eb278dbad8 100644 --- a/app/Models/TaskStatus.php +++ b/app/Models/TaskStatus.php @@ -37,4 +37,13 @@ class TaskStatus extends EntityModel { return ENTITY_TASK_STATUS; } + + /** + * @return mixed + */ + public function tasks() + { + return $this->hasMany('App\Models\Task')->orderBy('task_status_sort_order'); + } + } diff --git a/resources/views/tasks/kanban.blade.php b/resources/views/tasks/kanban.blade.php index 566c015e0ebf..f2d0144036ea 100644 --- a/resources/views/tasks/kanban.blade.php +++ b/resources/views/tasks/kanban.blade.php @@ -299,7 +299,8 @@ sweetConfirm(function() { var url = '{{ url('/task_statuses') }}/' + self.public_id(); model.ajax('delete', url, null, function(response) { - model.statuses.remove(self); + //model.statuses.remove(self); + location.reload(); }) }, "{{ trans('texts.archive_status')}}"); }