summaryrefslogtreecommitdiff
path: root/app/Model
diff options
context:
space:
mode:
authorFrédéric Guillot <fred@kanboard.net>2014-12-31 13:47:47 -0500
committerFrédéric Guillot <fred@kanboard.net>2014-12-31 13:47:47 -0500
commit27f453707948daf08e4a38c4c22e637a7ad0c57d (patch)
treeec0d2509b007f4f438a79c8af6e1c6519875d6e9 /app/Model
parent198f8d6a8e39fe7bb21faafe53b12e351feca8b7 (diff)
Fix bug tasks don't show up on board/swimlanes
Diffstat (limited to 'app/Model')
-rw-r--r--app/Model/Board.php14
-rw-r--r--app/Model/TaskCreation.php3
-rw-r--r--app/Model/TaskFinder.php20
3 files changed, 29 insertions, 8 deletions
diff --git a/app/Model/Board.php b/app/Model/Board.php
index 41e9b441..5ebec279 100644
--- a/app/Model/Board.php
+++ b/app/Model/Board.php
@@ -239,15 +239,15 @@ class Board extends Base
$columns = $this->getColumns($project_id);
$nb_columns = count($columns);
- foreach ($swimlanes as &$swimlane) {
+ for ($i = 0, $ilen = count($swimlanes); $i < $ilen; $i++) {
- foreach ($columns as &$column) {
- $column['tasks'] = $this->taskFinder->getTasksByColumnAndSwimlane($project_id, $column['id'], $swimlane['id']);
- $column['nb_tasks'] = count($column['tasks']);
- }
+ $swimlanes[$i]['columns'] = $columns;
+ $swimlanes[$i]['nb_columns'] = $nb_columns;
- $swimlane['columns'] = $columns;
- $swimlane['nb_columns'] = $nb_columns;
+ for ($j = 0; $j < $nb_columns; $j++) {
+ $swimlanes[$i]['columns'][$j]['tasks'] = $this->taskFinder->getTasksByColumnAndSwimlane($project_id, $columns[$j]['id'], $swimlanes[$i]['id']);
+ $swimlanes[$i]['columns'][$j]['nb_tasks'] = count($swimlanes[$i]['columns'][$j]['tasks']);
+ }
}
return $swimlanes;
diff --git a/app/Model/TaskCreation.php b/app/Model/TaskCreation.php
index 7d523214..e99bf6d2 100644
--- a/app/Model/TaskCreation.php
+++ b/app/Model/TaskCreation.php
@@ -51,9 +51,10 @@ class TaskCreation extends Base
$values['color_id'] = $this->color->getDefaultColor();
}
+ $values['swimlane_id'] = empty($values['swimlane_id']) ? 0 : $values['swimlane_id'];
$values['date_creation'] = time();
$values['date_modification'] = $values['date_creation'];
- $values['position'] = $this->taskFinder->countByColumnId($values['project_id'], $values['column_id']) + 1;
+ $values['position'] = $this->taskFinder->countByColumnAndSwimlaneId($values['project_id'], $values['column_id'], $values['swimlane_id']) + 1;
}
/**
diff --git a/app/Model/TaskFinder.php b/app/Model/TaskFinder.php
index 117edae8..7f66fa4d 100644
--- a/app/Model/TaskFinder.php
+++ b/app/Model/TaskFinder.php
@@ -230,6 +230,26 @@ class TaskFinder extends Base
}
/**
+ * Count the number of tasks for a given column and swimlane
+ *
+ * @access public
+ * @param integer $project_id Project id
+ * @param integer $column_id Column id
+ * @param integer $swimlane_id Swimlane id
+ * @return integer
+ */
+ public function countByColumnAndSwimlaneId($project_id, $column_id, $swimlane_id)
+ {
+ return $this->db
+ ->table(Task::TABLE)
+ ->eq('project_id', $project_id)
+ ->eq('column_id', $column_id)
+ ->eq('swimlane_id', $swimlane_id)
+ ->in('is_active', 1)
+ ->count();
+ }
+
+ /**
* Return true if the task exists
*
* @access public