summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog1
-rw-r--r--app/Controller/BoardAjaxController.php9
-rw-r--r--app/Core/User/UserSession.php24
-rw-r--r--app/Helper/BoardHelper.php3
-rw-r--r--app/Model/UserMetadataModel.php1
-rw-r--r--tests/units/Core/User/UserSessionTest.php12
6 files changed, 9 insertions, 41 deletions
diff --git a/ChangeLog b/ChangeLog
index 4462c05a..1f7cedd5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,7 @@ New features:
Improvements:
+* Store board collapsed mode user preference in the database
* Store comment sorting direction in the database
* Avoid tags overlapping on the board
* Show project name in notifications
diff --git a/app/Controller/BoardAjaxController.php b/app/Controller/BoardAjaxController.php
index 9b721f06..ccd47667 100644
--- a/app/Controller/BoardAjaxController.php
+++ b/app/Controller/BoardAjaxController.php
@@ -4,6 +4,7 @@ namespace Kanboard\Controller;
use Kanboard\Core\Controller\AccessForbiddenException;
use Kanboard\Formatter\BoardFormatter;
+use Kanboard\Model\UserMetadataModel;
/**
* Class BoardAjaxController
@@ -88,7 +89,7 @@ class BoardAjaxController extends BaseController
*/
public function collapse()
{
- $this->changeDisplayMode(true);
+ $this->changeDisplayMode(1);
}
/**
@@ -98,19 +99,19 @@ class BoardAjaxController extends BaseController
*/
public function expand()
{
- $this->changeDisplayMode(false);
+ $this->changeDisplayMode(0);
}
/**
* Change display mode
*
* @access private
- * @param boolean $mode
+ * @param int $mode
*/
private function changeDisplayMode($mode)
{
$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()) {
$this->response->html($this->renderBoard($project_id));
diff --git a/app/Core/User/UserSession.php b/app/Core/User/UserSession.php
index 4397876c..7917b223 100644
--- a/app/Core/User/UserSession.php
+++ b/app/Core/User/UserSession.php
@@ -179,28 +179,4 @@ class UserSession extends Base
{
$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;
- }
}
diff --git a/app/Helper/BoardHelper.php b/app/Helper/BoardHelper.php
index a86a6c18..f5df3db2 100644
--- a/app/Helper/BoardHelper.php
+++ b/app/Helper/BoardHelper.php
@@ -3,6 +3,7 @@
namespace Kanboard\Helper;
use Kanboard\Core\Base;
+use Kanboard\Model\UserMetadataModel;
/**
* Board Helper
@@ -21,6 +22,6 @@ class BoardHelper extends Base
*/
public function isCollapsed($project_id)
{
- return $this->userSession->isBoardCollapsed($project_id);
+ return $this->userMetadataCacheDecorator->get(UserMetadataModel::KEY_BOARD_COLLAPSED.$project_id, 0) == 1;
}
}
diff --git a/app/Model/UserMetadataModel.php b/app/Model/UserMetadataModel.php
index e285b98e..42fe4c6d 100644
--- a/app/Model/UserMetadataModel.php
+++ b/app/Model/UserMetadataModel.php
@@ -11,6 +11,7 @@ namespace Kanboard\Model;
class UserMetadataModel extends MetadataModel
{
const KEY_COMMENT_SORTING_DIRECTION = 'comment.sorting.direction';
+ const KEY_BOARD_COLLAPSED = 'board.collapsed.';
/**
* Get the table
diff --git a/tests/units/Core/User/UserSessionTest.php b/tests/units/Core/User/UserSessionTest.php
index 7e9674c0..2a118079 100644
--- a/tests/units/Core/User/UserSessionTest.php
+++ b/tests/units/Core/User/UserSessionTest.php
@@ -83,18 +83,6 @@ class UserSessionTest extends Base
$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()
{
$us = new UserSession($this->container);