Take default swimlane into consideration for SwimlaneModel::getFirstActiveSwimlane()
This commit is contained in:
parent
d975a3ac45
commit
f87d3334e5
|
|
@ -29,6 +29,7 @@ Bug fixes:
|
||||||
* Fixed lexer issue with non word characters
|
* Fixed lexer issue with non word characters
|
||||||
* Flush memory cache in worker to get latest config values
|
* Flush memory cache in worker to get latest config values
|
||||||
* Fixed empty title for web notification with only one overdue task
|
* Fixed empty title for web notification with only one overdue task
|
||||||
|
* Take default swimlane into consideration for SwimlaneModel::getFirstActiveSwimlane()
|
||||||
|
|
||||||
Version 1.0.30
|
Version 1.0.30
|
||||||
--------------
|
--------------
|
||||||
|
|
|
||||||
|
|
@ -94,15 +94,17 @@ class SwimlaneModel extends Base
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @param integer $project_id
|
* @param integer $project_id
|
||||||
* @return array
|
* @return array|null
|
||||||
*/
|
*/
|
||||||
public function getFirstActiveSwimlane($project_id)
|
public function getFirstActiveSwimlane($project_id)
|
||||||
{
|
{
|
||||||
return $this->db->table(self::TABLE)
|
$swimlanes = $this->getSwimlanes($project_id);
|
||||||
->eq('is_active', self::ACTIVE)
|
|
||||||
->eq('project_id', $project_id)
|
if (empty($swimlanes)) {
|
||||||
->orderBy('position', 'asc')
|
return null;
|
||||||
->findOne();
|
}
|
||||||
|
|
||||||
|
return $swimlanes[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -184,18 +186,18 @@ class SwimlaneModel extends Base
|
||||||
->orderBy('position', 'asc')
|
->orderBy('position', 'asc')
|
||||||
->findAll();
|
->findAll();
|
||||||
|
|
||||||
$default_swimlane = $this->db
|
$defaultSwimlane = $this->db
|
||||||
->table(ProjectModel::TABLE)
|
->table(ProjectModel::TABLE)
|
||||||
->eq('id', $project_id)
|
->eq('id', $project_id)
|
||||||
->eq('show_default_swimlane', 1)
|
->eq('show_default_swimlane', 1)
|
||||||
->findOneColumn('default_swimlane');
|
->findOneColumn('default_swimlane');
|
||||||
|
|
||||||
if ($default_swimlane) {
|
if ($defaultSwimlane) {
|
||||||
if ($default_swimlane === 'Default swimlane') {
|
if ($defaultSwimlane === 'Default swimlane') {
|
||||||
$default_swimlane = t($default_swimlane);
|
$defaultSwimlane = t($defaultSwimlane);
|
||||||
}
|
}
|
||||||
|
|
||||||
array_unshift($swimlanes, array('id' => 0, 'name' => $default_swimlane));
|
array_unshift($swimlanes, array('id' => 0, 'name' => $defaultSwimlane));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $swimlanes;
|
return $swimlanes;
|
||||||
|
|
|
||||||
|
|
@ -39,8 +39,18 @@ class SwimlaneTest extends Base
|
||||||
$this->assertEquals(1, $swimlaneModel->create(array('project_id' => 1, 'name' => 'Swimlane #1', 'is_active' => 0)));
|
$this->assertEquals(1, $swimlaneModel->create(array('project_id' => 1, 'name' => 'Swimlane #1', 'is_active' => 0)));
|
||||||
$this->assertEquals(2, $swimlaneModel->create(array('project_id' => 1, 'name' => 'Swimlane #2')));
|
$this->assertEquals(2, $swimlaneModel->create(array('project_id' => 1, 'name' => 'Swimlane #2')));
|
||||||
|
|
||||||
|
$swimlane = $swimlaneModel->getFirstActiveSwimlane(1);
|
||||||
|
$this->assertEquals(0, $swimlane['id']);
|
||||||
|
$this->assertEquals('Default swimlane', $swimlane['name']);
|
||||||
|
|
||||||
|
$this->assertTrue($swimlaneModel->disableDefault(1));
|
||||||
|
|
||||||
$swimlane = $swimlaneModel->getFirstActiveSwimlane(1);
|
$swimlane = $swimlaneModel->getFirstActiveSwimlane(1);
|
||||||
$this->assertEquals(2, $swimlane['id']);
|
$this->assertEquals(2, $swimlane['id']);
|
||||||
|
$this->assertEquals('Swimlane #2', $swimlane['name']);
|
||||||
|
|
||||||
|
$this->assertTrue($swimlaneModel->disable(1, 2));
|
||||||
|
$this->assertNull($swimlaneModel->getFirstActiveSwimlane(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetList()
|
public function testGetList()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue