Store comment sorting direction in user metadata
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace Kanboard\Controller;
|
||||
|
||||
use Kanboard\Model\UserMetadataModel;
|
||||
|
||||
/**
|
||||
* Board Tooltip
|
||||
*
|
||||
@@ -75,10 +77,11 @@ class BoardTooltipController extends BaseController
|
||||
public function comments()
|
||||
{
|
||||
$task = $this->getTask();
|
||||
$commentSortingDirection = $this->userMetadataCacheDecorator->get(UserMetadataModel::KEY_COMMENT_SORTING_DIRECTION, 'ASC');
|
||||
|
||||
$this->response->html($this->template->render('board/tooltip_comments', array(
|
||||
'task' => $task,
|
||||
'comments' => $this->commentModel->getAll($task['id'], $this->userSession->getCommentSorting())
|
||||
'comments' => $this->commentModel->getAll($task['id'], $commentSortingDirection)
|
||||
)));
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace Kanboard\Controller;
|
||||
|
||||
use Kanboard\Core\Controller\AccessForbiddenException;
|
||||
use Kanboard\Core\Controller\PageNotFoundException;
|
||||
use Kanboard\Model\UserMetadataModel;
|
||||
|
||||
/**
|
||||
* Comment Controller
|
||||
@@ -82,10 +83,10 @@ class CommentController extends BaseController
|
||||
$this->flash->failure(t('Unable to create your comment.'));
|
||||
}
|
||||
|
||||
return $this->response->redirect($this->helper->url->to('TaskViewController', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), 'comments'), true);
|
||||
$this->response->redirect($this->helper->url->to('TaskViewController', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), 'comments'), true);
|
||||
} else {
|
||||
$this->create($values, $errors);
|
||||
}
|
||||
|
||||
return $this->create($values, $errors);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -183,9 +184,16 @@ class CommentController extends BaseController
|
||||
{
|
||||
$task = $this->getTask();
|
||||
|
||||
$order = $this->userSession->getCommentSorting() === 'ASC' ? 'DESC' : 'ASC';
|
||||
$this->userSession->setCommentSorting($order);
|
||||
$oldDirection = $this->userMetadataCacheDecorator->get(UserMetadataModel::KEY_COMMENT_SORTING_DIRECTION, 'ASC');
|
||||
$newDirection = $oldDirection === 'ASC' ? 'DESC' : 'ASC';
|
||||
|
||||
$this->response->redirect($this->helper->url->to('TaskViewController', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), 'comments'));
|
||||
$this->userMetadataCacheDecorator->set(UserMetadataModel::KEY_COMMENT_SORTING_DIRECTION, $newDirection);
|
||||
|
||||
$this->response->redirect($this->helper->url->to(
|
||||
'TaskViewController',
|
||||
'show',
|
||||
array('task_id' => $task['id'], 'project_id' => $task['project_id']),
|
||||
'comments'
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace Kanboard\Controller;
|
||||
|
||||
use Kanboard\Core\Controller\AccessForbiddenException;
|
||||
use Kanboard\Core\Controller\PageNotFoundException;
|
||||
use Kanboard\Model\UserMetadataModel;
|
||||
|
||||
/**
|
||||
* Task Controller
|
||||
@@ -61,13 +62,14 @@ class TaskViewController extends BaseController
|
||||
{
|
||||
$task = $this->getTask();
|
||||
$subtasks = $this->subtaskModel->getAll($task['id']);
|
||||
$commentSortingDirection = $this->userMetadataCacheDecorator->get(UserMetadataModel::KEY_COMMENT_SORTING_DIRECTION, 'ASC');
|
||||
|
||||
$this->response->html($this->helper->layout->task('task/show', array(
|
||||
'task' => $task,
|
||||
'project' => $this->projectModel->getById($task['project_id']),
|
||||
'files' => $this->taskFileModel->getAllDocuments($task['id']),
|
||||
'images' => $this->taskFileModel->getAllImages($task['id']),
|
||||
'comments' => $this->commentModel->getAll($task['id'], $this->userSession->getCommentSorting()),
|
||||
'comments' => $this->commentModel->getAll($task['id'], $commentSortingDirection),
|
||||
'subtasks' => $subtasks,
|
||||
'internal_links' => $this->taskLinkModel->getAllGroupedByLabel($task['id']),
|
||||
'external_links' => $this->taskExternalLinkModel->getAll($task['id']),
|
||||
|
||||
Reference in New Issue
Block a user