feature : persistent sort
This commit is contained in:
61
Controller/OrganonSortController.php
Normal file
61
Controller/OrganonSortController.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace Kanboard\Plugin\OrganonTweaks\Controller;
|
||||
|
||||
use Kanboard\Controller\BaseController;
|
||||
use Kanboard\Core\Controller\AccessForbiddenException;
|
||||
use Kanboard\Plugin\OrganonTweaks\Helper\OrganonSortHelper;
|
||||
|
||||
/**
|
||||
* Per-column persistent sort, driven from the column's sort control on the board. Project-member
|
||||
* (task-update) gated + CSRF, mirroring core TaskReorderController; returns to the board.
|
||||
*/
|
||||
class OrganonSortController extends BaseController
|
||||
{
|
||||
private function authorize()
|
||||
{
|
||||
$project = $this->getProject();
|
||||
|
||||
if (! $this->helper->user->hasProjectAccess('TaskModificationController', 'update', $project['id'])) {
|
||||
throw new AccessForbiddenException();
|
||||
}
|
||||
|
||||
return $project;
|
||||
}
|
||||
|
||||
private function sorter()
|
||||
{
|
||||
return new OrganonSortHelper($this->container);
|
||||
}
|
||||
|
||||
private function backToBoard(array $project)
|
||||
{
|
||||
$this->response->redirect($this->helper->url->to('BoardViewController', 'show', array('project_id' => $project['id'])));
|
||||
}
|
||||
|
||||
public function sort()
|
||||
{
|
||||
$this->checkCSRFParam();
|
||||
$project = $this->authorize();
|
||||
|
||||
$this->sorter()->applySort(
|
||||
$project['id'],
|
||||
$this->request->getIntegerParam('swimlane_id'),
|
||||
$this->request->getIntegerParam('column_id'),
|
||||
$this->request->getStringParam('sort'),
|
||||
$this->request->getStringParam('direction')
|
||||
);
|
||||
|
||||
$this->backToBoard($project);
|
||||
}
|
||||
|
||||
public function toggle()
|
||||
{
|
||||
$this->checkCSRFParam();
|
||||
$project = $this->authorize();
|
||||
|
||||
$this->sorter()->toggle($project['id'], $this->request->getIntegerParam('column_id'));
|
||||
|
||||
$this->backToBoard($project);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user