From 912cf378d730b3df8d285ba765711d9c456bdea0 Mon Sep 17 00:00:00 2001 From: Frédéric Guillot Date: Fri, 1 Jun 2018 15:58:17 -0700 Subject: Add checkboxes in list view to move tasks to another column at once --- app/Model/TaskPositionModel.php | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'app/Model/TaskPositionModel.php') diff --git a/app/Model/TaskPositionModel.php b/app/Model/TaskPositionModel.php index 9f7eb983..6c109f3d 100644 --- a/app/Model/TaskPositionModel.php +++ b/app/Model/TaskPositionModel.php @@ -12,6 +12,42 @@ use Kanboard\Core\Base; */ class TaskPositionModel extends Base { + public function moveBottom($project_id, $task_id, $swimlane_id, $column_id) + { + $this->db->startTransaction(); + + $task = $this->taskFinderModel->getById($task_id); + + $result = $this->db->table(TaskModel::TABLE) + ->eq('project_id', $project_id) + ->eq('swimlane_id', $swimlane_id) + ->eq('column_id', $column_id) + ->columns('MAX(position) AS pos') + ->findOne(); + + $position = 1; + if (! empty($result)) { + $position = $result['pos'] + 1; + } + + $result = $this->db->table(TaskModel::TABLE) + ->eq('id', $task_id) + ->eq('project_id', $project_id) + ->update([ + 'swimlane_id' => $swimlane_id, + 'column_id' => $column_id, + 'position' => $position + ]); + + $this->db->closeTransaction(); + + if ($result) { + $this->fireEvents($task, $column_id, $position, $swimlane_id); + } + + return $result; + } + /** * Move a task to another column or to another position * -- cgit v1.2.3