diff options
author | Frédéric Guillot <fred@kanboard.net> | 2018-06-01 15:58:17 -0700 |
---|---|---|
committer | Frédéric Guillot <fred@kanboard.net> | 2018-06-01 15:58:17 -0700 |
commit | 912cf378d730b3df8d285ba765711d9c456bdea0 (patch) | |
tree | cc26710f2e1e4e9eb958b873a2fb537cf3a389cb /app/Model/TaskPositionModel.php | |
parent | cd6da138973f6bfe7c71846ff6cc1d6fb97c4813 (diff) |
Add checkboxes in list view to move tasks to another column at once
Diffstat (limited to 'app/Model/TaskPositionModel.php')
-rw-r--r-- | app/Model/TaskPositionModel.php | 36 |
1 files changed, 36 insertions, 0 deletions
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 * |