Add mandatory argument "project_id" to API method "updateSwimlane()"
This commit is contained in:
@@ -15,6 +15,7 @@ Breaking changes:
|
|||||||
* Previous default swimlanes are migrated to an independent swimlane
|
* Previous default swimlanes are migrated to an independent swimlane
|
||||||
* Columns "default_swimlane" and "show_default_swimlane" from "projects" table are not used anymore
|
* Columns "default_swimlane" and "show_default_swimlane" from "projects" table are not used anymore
|
||||||
* Remove API method "getDefaultSwimlane()"
|
* Remove API method "getDefaultSwimlane()"
|
||||||
|
* Add mandatory argument "project_id" to API method "updateSwimlane()"
|
||||||
|
|
||||||
Bug fixes:
|
Bug fixes:
|
||||||
|
|
||||||
|
|||||||
@@ -49,15 +49,28 @@ class SwimlaneProcedure extends BaseProcedure
|
|||||||
return $this->swimlaneModel->create($project_id, $name, $description);
|
return $this->swimlaneModel->create($project_id, $name, $description);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateSwimlane($swimlane_id, $name, $description = null)
|
public function updateSwimlane($project_id, $swimlane_id, $name, $description = null)
|
||||||
{
|
{
|
||||||
$values = array('id' => $swimlane_id, 'name' => $name);
|
ProjectAuthorization::getInstance($this->container)->check($this->getClassName(), 'updateSwimlane', $project_id);
|
||||||
|
|
||||||
if (!is_null($description)) {
|
$values = array(
|
||||||
|
'project_id' => $project_id,
|
||||||
|
'id' => $swimlane_id,
|
||||||
|
'name' => $name,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (! is_null($description)) {
|
||||||
$values['description'] = $description;
|
$values['description'] = $description;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->swimlaneModel->update($values);
|
list($valid, $errors) = $this->swimlaneValidator->validateModification($values);
|
||||||
|
|
||||||
|
if (! $valid) {
|
||||||
|
$this->logger->debug(__METHOD__.': Validation error: '.var_export($errors, true));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->swimlaneModel->update($swimlane_id, $values);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function removeSwimlane($project_id, $swimlane_id)
|
public function removeSwimlane($project_id, $swimlane_id)
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ class SwimlaneController extends BaseController
|
|||||||
list($valid, $errors) = $this->swimlaneValidator->validateModification($values);
|
list($valid, $errors) = $this->swimlaneValidator->validateModification($values);
|
||||||
|
|
||||||
if ($valid) {
|
if ($valid) {
|
||||||
if ($this->swimlaneModel->update($values)) {
|
if ($this->swimlaneModel->update($values['id'], $values)) {
|
||||||
$this->flash->success(t('Swimlane updated successfully.'));
|
$this->flash->success(t('Swimlane updated successfully.'));
|
||||||
return $this->response->redirect($this->helper->url->to('SwimlaneController', 'index', array('project_id' => $project['id'])));
|
return $this->response->redirect($this->helper->url->to('SwimlaneController', 'index', array('project_id' => $project['id'])));
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -216,14 +216,18 @@ class SwimlaneModel extends Base
|
|||||||
* Update a swimlane
|
* Update a swimlane
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @param array $values Form values
|
* @param integer $swimlaneId
|
||||||
|
* @param array $values
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function update(array $values)
|
public function update($swimlaneId, array $values)
|
||||||
{
|
{
|
||||||
|
unset($values['id']);
|
||||||
|
unset($values['project_id']);
|
||||||
|
|
||||||
return $this->db
|
return $this->db
|
||||||
->table(self::TABLE)
|
->table(self::TABLE)
|
||||||
->eq('id', $values['id'])
|
->eq('id', $swimlaneId)
|
||||||
->update($values);
|
->update($values);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -239,6 +239,7 @@ Response example:
|
|||||||
|
|
||||||
- Purpose: **Update swimlane properties**
|
- Purpose: **Update swimlane properties**
|
||||||
- Parameters:
|
- Parameters:
|
||||||
|
- **project_id** (integer, required)
|
||||||
- **swimlane_id** (integer, required)
|
- **swimlane_id** (integer, required)
|
||||||
- **name** (string, required)
|
- **name** (string, required)
|
||||||
- **description** (string, optional)
|
- **description** (string, optional)
|
||||||
@@ -253,6 +254,7 @@ Request example:
|
|||||||
"method": "updateSwimlane",
|
"method": "updateSwimlane",
|
||||||
"id": 87102426,
|
"id": 87102426,
|
||||||
"params": [
|
"params": [
|
||||||
|
"1",
|
||||||
"1",
|
"1",
|
||||||
"Another swimlane"
|
"Another swimlane"
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ class SwimlaneProcedureTest extends BaseProcedureTest
|
|||||||
|
|
||||||
public function assertUpdateSwimlane()
|
public function assertUpdateSwimlane()
|
||||||
{
|
{
|
||||||
$this->assertTrue($this->app->updateSwimlane($this->swimlaneId, 'Another swimlane'));
|
$this->assertTrue($this->app->updateSwimlane($this->projectId, $this->swimlaneId, 'Another swimlane'));
|
||||||
|
|
||||||
$swimlane = $this->app->getSwimlaneById($this->swimlaneId);
|
$swimlane = $this->app->getSwimlaneById($this->swimlaneId);
|
||||||
$this->assertEquals('Another swimlane', $swimlane['name']);
|
$this->assertEquals('Another swimlane', $swimlane['name']);
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ require_once __DIR__.'/../Base.php';
|
|||||||
|
|
||||||
use Kanboard\Model\ProjectModel;
|
use Kanboard\Model\ProjectModel;
|
||||||
use Kanboard\Model\TaskCreationModel;
|
use Kanboard\Model\TaskCreationModel;
|
||||||
use Kanboard\Model\TaskFinderModel;
|
|
||||||
use Kanboard\Model\SwimlaneModel;
|
use Kanboard\Model\SwimlaneModel;
|
||||||
|
|
||||||
class SwimlaneModelTest extends Base
|
class SwimlaneModelTest extends Base
|
||||||
@@ -86,7 +85,7 @@ class SwimlaneModelTest extends Base
|
|||||||
$this->assertEquals(1, $projectModel->create(array('name' => 'UnitTest')));
|
$this->assertEquals(1, $projectModel->create(array('name' => 'UnitTest')));
|
||||||
$this->assertEquals(2, $swimlaneModel->create(1, 'Swimlane #1'));
|
$this->assertEquals(2, $swimlaneModel->create(1, 'Swimlane #1'));
|
||||||
|
|
||||||
$this->assertTrue($swimlaneModel->update(array('id' => 2, 'name' => 'foobar')));
|
$this->assertTrue($swimlaneModel->update(2, array('name' => 'foobar')));
|
||||||
|
|
||||||
$swimlane = $swimlaneModel->getById(2);
|
$swimlane = $swimlaneModel->getById(2);
|
||||||
$this->assertEquals('foobar', $swimlane['name']);
|
$this->assertEquals('foobar', $swimlane['name']);
|
||||||
|
|||||||
Reference in New Issue
Block a user