Store board collapsed mode user preference in the database
This commit is contained in:
@@ -7,6 +7,7 @@ New features:
|
|||||||
|
|
||||||
Improvements:
|
Improvements:
|
||||||
|
|
||||||
|
* Store board collapsed mode user preference in the database
|
||||||
* Store comment sorting direction in the database
|
* Store comment sorting direction in the database
|
||||||
* Avoid tags overlapping on the board
|
* Avoid tags overlapping on the board
|
||||||
* Show project name in notifications
|
* Show project name in notifications
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ namespace Kanboard\Controller;
|
|||||||
|
|
||||||
use Kanboard\Core\Controller\AccessForbiddenException;
|
use Kanboard\Core\Controller\AccessForbiddenException;
|
||||||
use Kanboard\Formatter\BoardFormatter;
|
use Kanboard\Formatter\BoardFormatter;
|
||||||
|
use Kanboard\Model\UserMetadataModel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class BoardAjaxController
|
* Class BoardAjaxController
|
||||||
@@ -88,7 +89,7 @@ class BoardAjaxController extends BaseController
|
|||||||
*/
|
*/
|
||||||
public function collapse()
|
public function collapse()
|
||||||
{
|
{
|
||||||
$this->changeDisplayMode(true);
|
$this->changeDisplayMode(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -98,19 +99,19 @@ class BoardAjaxController extends BaseController
|
|||||||
*/
|
*/
|
||||||
public function expand()
|
public function expand()
|
||||||
{
|
{
|
||||||
$this->changeDisplayMode(false);
|
$this->changeDisplayMode(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Change display mode
|
* Change display mode
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @param boolean $mode
|
* @param int $mode
|
||||||
*/
|
*/
|
||||||
private function changeDisplayMode($mode)
|
private function changeDisplayMode($mode)
|
||||||
{
|
{
|
||||||
$project_id = $this->request->getIntegerParam('project_id');
|
$project_id = $this->request->getIntegerParam('project_id');
|
||||||
$this->userSession->setBoardDisplayMode($project_id, $mode);
|
$this->userMetadataCacheDecorator->set(UserMetadataModel::KEY_BOARD_COLLAPSED.$project_id, $mode);
|
||||||
|
|
||||||
if ($this->request->isAjax()) {
|
if ($this->request->isAjax()) {
|
||||||
$this->response->html($this->renderBoard($project_id));
|
$this->response->html($this->renderBoard($project_id));
|
||||||
|
|||||||
@@ -179,28 +179,4 @@ class UserSession extends Base
|
|||||||
{
|
{
|
||||||
$this->sessionStorage->filters[$project_id] = $filters;
|
$this->sessionStorage->filters[$project_id] = $filters;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Is board collapsed or expanded
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @param integer $project_id
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
public function isBoardCollapsed($project_id)
|
|
||||||
{
|
|
||||||
return ! empty($this->sessionStorage->boardCollapsed[$project_id]) ? $this->sessionStorage->boardCollapsed[$project_id] : false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set board display mode
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @param integer $project_id
|
|
||||||
* @param boolean $is_collapsed
|
|
||||||
*/
|
|
||||||
public function setBoardDisplayMode($project_id, $is_collapsed)
|
|
||||||
{
|
|
||||||
$this->sessionStorage->boardCollapsed[$project_id] = $is_collapsed;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace Kanboard\Helper;
|
namespace Kanboard\Helper;
|
||||||
|
|
||||||
use Kanboard\Core\Base;
|
use Kanboard\Core\Base;
|
||||||
|
use Kanboard\Model\UserMetadataModel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Board Helper
|
* Board Helper
|
||||||
@@ -21,6 +22,6 @@ class BoardHelper extends Base
|
|||||||
*/
|
*/
|
||||||
public function isCollapsed($project_id)
|
public function isCollapsed($project_id)
|
||||||
{
|
{
|
||||||
return $this->userSession->isBoardCollapsed($project_id);
|
return $this->userMetadataCacheDecorator->get(UserMetadataModel::KEY_BOARD_COLLAPSED.$project_id, 0) == 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ namespace Kanboard\Model;
|
|||||||
class UserMetadataModel extends MetadataModel
|
class UserMetadataModel extends MetadataModel
|
||||||
{
|
{
|
||||||
const KEY_COMMENT_SORTING_DIRECTION = 'comment.sorting.direction';
|
const KEY_COMMENT_SORTING_DIRECTION = 'comment.sorting.direction';
|
||||||
|
const KEY_BOARD_COLLAPSED = 'board.collapsed.';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the table
|
* Get the table
|
||||||
|
|||||||
@@ -83,18 +83,6 @@ class UserSessionTest extends Base
|
|||||||
$this->assertFalse($us->isAdmin());
|
$this->assertFalse($us->isAdmin());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testBoardCollapseMode()
|
|
||||||
{
|
|
||||||
$us = new UserSession($this->container);
|
|
||||||
$this->assertFalse($us->isBoardCollapsed(2));
|
|
||||||
|
|
||||||
$us->setBoardDisplayMode(3, false);
|
|
||||||
$this->assertFalse($us->isBoardCollapsed(3));
|
|
||||||
|
|
||||||
$us->setBoardDisplayMode(3, true);
|
|
||||||
$this->assertTrue($us->isBoardCollapsed(3));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testFilters()
|
public function testFilters()
|
||||||
{
|
{
|
||||||
$us = new UserSession($this->container);
|
$us = new UserSession($this->container);
|
||||||
|
|||||||
Reference in New Issue
Block a user