diff options
-rw-r--r-- | app/Helper/ProjectRoleHelper.php | 11 | ||||
-rw-r--r-- | app/Template/board/table_tasks.php | 2 | ||||
-rw-r--r-- | tests/units/Helper/ProjectRoleHelperTest.php | 14 |
3 files changed, 19 insertions, 8 deletions
diff --git a/app/Helper/ProjectRoleHelper.php b/app/Helper/ProjectRoleHelper.php index e1808be5..87f7fed2 100644 --- a/app/Helper/ProjectRoleHelper.php +++ b/app/Helper/ProjectRoleHelper.php @@ -36,7 +36,7 @@ class ProjectRoleHelper extends Base public function isDraggable(array &$task) { if ($task['is_active'] == 1 && $this->helper->user->hasProjectAccess('BoardViewController', 'save', $task['project_id'])) { - return $this->isSortableColumn($task['project_id'], $task['column_id'], 'src_column_id'); + return $this->isSortableColumn($task['project_id'], $task['column_id']); } return false; @@ -47,10 +47,9 @@ class ProjectRoleHelper extends Base * * @param int $project_id * @param int $column_id - * @param string $field * @return bool */ - public function isSortableColumn($project_id, $column_id, $field) + public function isSortableColumn($project_id, $column_id) { $role = $this->getProjectUserRole($project_id); @@ -58,7 +57,7 @@ class ProjectRoleHelper extends Base $sortableColumns = $this->columnMoveRestrictionCacheDecorator->getSortableColumns($project_id, $role); foreach ($sortableColumns as $column) { - if ($column[$field] == $column_id) { + if ($column['src_column_id'] == $column_id || $column['dst_column_id'] == $column_id) { return true; } } @@ -92,6 +91,10 @@ class ProjectRoleHelper extends Base if ($column['src_column_id'] == $src_column_id && $column['dst_column_id'] == $dst_column_id) { return true; } + + if ($column['dst_column_id'] == $src_column_id && $column['src_column_id'] == $dst_column_id) { + return true; + } } return empty($sortableColumns); diff --git a/app/Template/board/table_tasks.php b/app/Template/board/table_tasks.php index a22f581b..e03ca90c 100644 --- a/app/Template/board/table_tasks.php +++ b/app/Template/board/table_tasks.php @@ -9,7 +9,7 @@ <!-- tasks list --> <div - class="board-task-list board-column-expanded <?= $this->projectRole->isSortableColumn($column['project_id'], $column['id'], 'dst_column_id') ? 'sortable-column' : '' ?>" + class="board-task-list board-column-expanded <?= $this->projectRole->isSortableColumn($column['project_id'], $column['id']) ? 'sortable-column' : '' ?>" data-column-id="<?= $column['id'] ?>" data-swimlane-id="<?= $swimlane['id'] ?>" data-task-limit="<?= $column['task_limit'] ?>"> diff --git a/tests/units/Helper/ProjectRoleHelperTest.php b/tests/units/Helper/ProjectRoleHelperTest.php index 4583d58e..eb9b320c 100644 --- a/tests/units/Helper/ProjectRoleHelperTest.php +++ b/tests/units/Helper/ProjectRoleHelperTest.php @@ -265,13 +265,21 @@ class ProjectRoleHelperTest extends Base $this->assertEquals(1, $columnMoveRestrictionModel->create(1, 1, 2, 3)); $this->assertTrue($projectUserRole->addUser(1, 2, 'Custom Role')); - $this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test', 'column_id' => 2))); - $this->assertEquals(2, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test', 'column_id' => 3))); + $this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test', 'column_id' => 1))); + $this->assertEquals(2, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test', 'column_id' => 2))); + $this->assertEquals(3, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test', 'column_id' => 3))); + $this->assertEquals(4, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test', 'column_id' => 4))); $task = $taskFinderModel->getById(1); - $this->assertTrue($projectRoleHelper->isDraggable($task)); + $this->assertFalse($projectRoleHelper->isDraggable($task)); $task = $taskFinderModel->getById(2); + $this->assertTrue($projectRoleHelper->isDraggable($task)); + + $task = $taskFinderModel->getById(3); + $this->assertTrue($projectRoleHelper->isDraggable($task)); + + $task = $taskFinderModel->getById(4); $this->assertFalse($projectRoleHelper->isDraggable($task)); } |