Add mandatory argument "project_id" to API method "updateSwimlane()"
This commit is contained in:
parent
de128dbad8
commit
948b7fbaaa
|
|
@ -15,6 +15,7 @@ Breaking changes:
|
|||
* Previous default swimlanes are migrated to an independent swimlane
|
||||
* 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()"
|
||||
|
||||
Bug fixes:
|
||||
|
||||
|
|
|
|||
|
|
@ -49,15 +49,28 @@ class SwimlaneProcedure extends BaseProcedure
|
|||
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;
|
||||
}
|
||||
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ class SwimlaneController extends BaseController
|
|||
list($valid, $errors) = $this->swimlaneValidator->validateModification($values);
|
||||
|
||||
if ($valid) {
|
||||
if ($this->swimlaneModel->update($values)) {
|
||||
if ($this->swimlaneModel->update($values['id'], $values)) {
|
||||
$this->flash->success(t('Swimlane updated successfully.'));
|
||||
return $this->response->redirect($this->helper->url->to('SwimlaneController', 'index', array('project_id' => $project['id'])));
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -216,14 +216,18 @@ class SwimlaneModel extends Base
|
|||
* Update a swimlane
|
||||
*
|
||||
* @access public
|
||||
* @param array $values Form values
|
||||
* @param integer $swimlaneId
|
||||
* @param array $values
|
||||
* @return bool
|
||||
*/
|
||||
public function update(array $values)
|
||||
public function update($swimlaneId, array $values)
|
||||
{
|
||||
unset($values['id']);
|
||||
unset($values['project_id']);
|
||||
|
||||
return $this->db
|
||||
->table(self::TABLE)
|
||||
->eq('id', $values['id'])
|
||||
->eq('id', $swimlaneId)
|
||||
->update($values);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -239,6 +239,7 @@ Response example:
|
|||
|
||||
- Purpose: **Update swimlane properties**
|
||||
- Parameters:
|
||||
- **project_id** (integer, required)
|
||||
- **swimlane_id** (integer, required)
|
||||
- **name** (string, required)
|
||||
- **description** (string, optional)
|
||||
|
|
@ -253,6 +254,7 @@ Request example:
|
|||
"method": "updateSwimlane",
|
||||
"id": 87102426,
|
||||
"params": [
|
||||
"1",
|
||||
"1",
|
||||
"Another swimlane"
|
||||
]
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ class SwimlaneProcedureTest extends BaseProcedureTest
|
|||
|
||||
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);
|
||||
$this->assertEquals('Another swimlane', $swimlane['name']);
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ require_once __DIR__.'/../Base.php';
|
|||
|
||||
use Kanboard\Model\ProjectModel;
|
||||
use Kanboard\Model\TaskCreationModel;
|
||||
use Kanboard\Model\TaskFinderModel;
|
||||
use Kanboard\Model\SwimlaneModel;
|
||||
|
||||
class SwimlaneModelTest extends Base
|
||||
|
|
@ -86,7 +85,7 @@ class SwimlaneModelTest extends Base
|
|||
$this->assertEquals(1, $projectModel->create(array('name' => 'UnitTest')));
|
||||
$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);
|
||||
$this->assertEquals('foobar', $swimlane['name']);
|
||||
|
|
|
|||
Loading…
Reference in New Issue