diff --git a/ChangeLog b/ChangeLog
index 7ab888c90..3524e419c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,12 +7,14 @@ New features:
Improvements:
+* Prevent people to remove swimlanes that contains tasks
+* Show task count in swimlane table
* Use contextual menu instead of action column in users management
Breaking changes:
-* The concept of "default swimlane" is removed
-* Previous default swimlanes are migrated to an independent swimlane
+* The concept of "default swimlane" has been removed
+* Previous default swimlanes are migrated to an independent swimlanes
* Columns "default_swimlane" and "show_default_swimlane" from "projects" table are not used anymore
* Remove API method "getDefaultSwimlane()"
* Add mandatory argument "project_id" to API method "updateSwimlane()"
diff --git a/app/Controller/ColumnController.php b/app/Controller/ColumnController.php
index 3facbebce..7047d30e1 100644
--- a/app/Controller/ColumnController.php
+++ b/app/Controller/ColumnController.php
@@ -20,7 +20,7 @@ class ColumnController extends BaseController
public function index()
{
$project = $this->getProject();
- $columns = $this->columnModel->getAllWithTasksCount($project['id']);
+ $columns = $this->columnModel->getAllWithTaskCount($project['id']);
$this->response->html($this->helper->layout->project('column/index', array(
'columns' => $columns,
diff --git a/app/Controller/ProjectOverviewController.php b/app/Controller/ProjectOverviewController.php
index 33bec0786..477c1dd50 100644
--- a/app/Controller/ProjectOverviewController.php
+++ b/app/Controller/ProjectOverviewController.php
@@ -16,7 +16,7 @@ class ProjectOverviewController extends BaseController
public function show()
{
$project = $this->getProject();
- $columns = $this->columnModel->getAllWithTasksCount($project['id']);
+ $columns = $this->columnModel->getAllWithTaskCount($project['id']);
$this->response->html($this->helper->layout->app('project_overview/show', array(
'project' => $project,
diff --git a/app/Controller/ProjectViewController.php b/app/Controller/ProjectViewController.php
index 8ccf36abb..8ff793435 100644
--- a/app/Controller/ProjectViewController.php
+++ b/app/Controller/ProjectViewController.php
@@ -18,7 +18,7 @@ class ProjectViewController extends BaseController
public function show()
{
$project = $this->getProject();
- $columns = $this->columnModel->getAllWithTasksCount($project['id']);
+ $columns = $this->columnModel->getAllWithTaskCount($project['id']);
$this->response->html($this->helper->layout->project('project_view/show', array(
'project' => $project,
diff --git a/app/Controller/SwimlaneController.php b/app/Controller/SwimlaneController.php
index d99cfa7a5..0d81d83cc 100644
--- a/app/Controller/SwimlaneController.php
+++ b/app/Controller/SwimlaneController.php
@@ -40,10 +40,11 @@ class SwimlaneController extends BaseController
public function index()
{
$project = $this->getProject();
+ $swimlanes = $this->swimlaneModel->getAllWithTaskCount($project['id']);
$this->response->html($this->helper->layout->project('swimlane/index', array(
- 'active_swimlanes' => $this->swimlaneModel->getAllByStatus($project['id'], SwimlaneModel::ACTIVE),
- 'inactive_swimlanes' => $this->swimlaneModel->getAllByStatus($project['id'], SwimlaneModel::INACTIVE),
+ 'active_swimlanes' => $swimlanes['active'],
+ 'inactive_swimlanes' => $swimlanes['inactive'],
'project' => $project,
'title' => t('Swimlanes')
)));
diff --git a/app/Model/ColumnModel.php b/app/Model/ColumnModel.php
index da5ea856f..05f76fb9d 100644
--- a/app/Model/ColumnModel.php
+++ b/app/Model/ColumnModel.php
@@ -121,13 +121,13 @@ class ColumnModel extends Base
}
/**
- * Get all columns with tasks count
+ * Get all columns with task count
*
* @access public
* @param integer $project_id Project id
* @return array
*/
- public function getAllWithTasksCount($project_id)
+ public function getAllWithTaskCount($project_id)
{
return $this->db->table(self::TABLE)
->columns('id', 'title', 'position', 'task_limit', 'description', 'hide_in_dashboard', 'project_id')
diff --git a/app/Model/ProjectModel.php b/app/Model/ProjectModel.php
index a4d75a0bd..b88a8c8bd 100644
--- a/app/Model/ProjectModel.php
+++ b/app/Model/ProjectModel.php
@@ -270,7 +270,7 @@ class ProjectModel extends Base
*/
public function getColumnStats(array &$project)
{
- $project['columns'] = $this->columnModel->getAllWithTasksCount($project['id']);
+ $project['columns'] = $this->columnModel->getAllWithTaskCount($project['id']);
$project['nb_active_tasks'] = 0;
foreach ($project['columns'] as $column) {
diff --git a/app/Model/SwimlaneModel.php b/app/Model/SwimlaneModel.php
index 300120963..2b3be912e 100644
--- a/app/Model/SwimlaneModel.php
+++ b/app/Model/SwimlaneModel.php
@@ -163,6 +163,40 @@ class SwimlaneModel extends Base
return $query->findAll();
}
+ /**
+ * Get all swimlanes with task count
+ *
+ * @access public
+ * @param integer $project_id Project id
+ * @return array
+ */
+ public function getAllWithTaskCount($project_id)
+ {
+ $result = array(
+ 'active' => array(),
+ 'inactive' => array(),
+ );
+
+ $swimlanes = $this->db->table(self::TABLE)
+ ->columns('id', 'name', 'description', 'project_id', 'position', 'is_active')
+ ->subquery("SELECT COUNT(*) FROM ".TaskModel::TABLE." WHERE swimlane_id=".self::TABLE.".id AND is_active='1'", 'nb_open_tasks')
+ ->subquery("SELECT COUNT(*) FROM ".TaskModel::TABLE." WHERE swimlane_id=".self::TABLE.".id AND is_active='0'", 'nb_closed_tasks')
+ ->eq('project_id', $project_id)
+ ->asc('position')
+ ->asc('name')
+ ->findAll();
+
+ foreach ($swimlanes as $swimlane) {
+ if ($swimlane['is_active']) {
+ $result['active'][] = $swimlane;
+ } else {
+ $result['inactive'][] = $swimlane;
+ }
+ }
+
+ return $result;
+ }
+
/**
* Get list of all swimlanes
*
diff --git a/app/Template/column/index.php b/app/Template/column/index.php
index 6108661b0..3c60d021c 100644
--- a/app/Template/column/index.php
+++ b/app/Template/column/index.php
@@ -15,19 +15,31 @@
data-save-position-url="= $this->url->href('ColumnController', 'move', array('project_id' => $project['id'])) ?>">
-
= t('Column') ?>
+ = t('Column') ?>
= t('Task limit') ?>
- = t('Visible on dashboard') ?>
- = t('Open tasks') ?>
- = t('Closed tasks') ?>
- = t('Actions') ?>
+ = t('Visible on dashboard') ?>
+ = t('Open tasks') ?>
+ = t('Closed tasks') ?>