diff options
author | Frederic Guillot <fred@kanboard.net> | 2015-04-07 21:06:15 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2015-04-07 21:06:15 -0400 |
commit | 4460851615d16b1ad0047b3d21389396d8ce5234 (patch) | |
tree | bca11098edcb20f1df379767a236e442932ab391 /app | |
parent | 7d1c84699ac12f91bf711ded5c93b57a644fabbf (diff) |
Display the sum of task complexity in the column
Diffstat (limited to 'app')
-rw-r--r-- | app/Model/Board.php | 20 | ||||
-rw-r--r-- | app/Template/board/swimlane.php | 6 |
2 files changed, 26 insertions, 0 deletions
diff --git a/app/Model/Board.php b/app/Model/Board.php index 8a344f7f..711f3dd9 100644 --- a/app/Model/Board.php +++ b/app/Model/Board.php @@ -225,6 +225,7 @@ class Board extends Base 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']); + $swimlanes[$i]['columns'][$j]['score'] = $this->getColumnSum($swimlanes[$i]['columns'][$j]['tasks'], 'score'); $swimlanes[$i]['nb_tasks'] += $swimlanes[$i]['columns'][$j]['nb_tasks']; } } @@ -233,6 +234,25 @@ class Board extends Base } /** + * Calculate the sum of the defined field for a list of tasks + * + * @access public + * @param array $tasks + * @param string $field + * @return integer + */ + public function getColumnSum(array &$tasks, $field) + { + $sum = 0; + + foreach ($tasks as $task) { + $sum += $task['score']; + } + + return $sum; + } + + /** * Get the total of tasks per column * * @access public diff --git a/app/Template/board/swimlane.php b/app/Template/board/swimlane.php index 744610ab..b73febb6 100644 --- a/app/Template/board/swimlane.php +++ b/app/Template/board/swimlane.php @@ -33,6 +33,12 @@ </span> <?php endif ?> + <?php if (! empty($column['score'])): ?> + <span class="column-score pull-right" title="<?= t('Score') ?>"> + <?= $column['score'] ?> + </span> + <?php endif ?> + <?php if ($column['task_limit']): ?> <span title="<?= t('Task limit') ?>" class="task-limit"> (<span id="task-number-column-<?= $column['id'] ?>"><?= $column['nb_tasks'] ?></span>/<?= $this->e($column['task_limit']) ?>) |