Add comments sorting
This commit is contained in:
@@ -1,3 +1,10 @@
|
|||||||
|
Version 1.0.20 (unreleased)
|
||||||
|
---------------------------
|
||||||
|
|
||||||
|
Improvements:
|
||||||
|
|
||||||
|
* Allow to change comments sorting
|
||||||
|
|
||||||
Version 1.0.19
|
Version 1.0.19
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
|
|||||||
@@ -195,7 +195,7 @@ class Board extends Base
|
|||||||
$task = $this->getTask();
|
$task = $this->getTask();
|
||||||
|
|
||||||
$this->response->html($this->template->render('board/tooltip_comments', array(
|
$this->response->html($this->template->render('board/tooltip_comments', array(
|
||||||
'comments' => $this->comment->getAll($task['id'])
|
'comments' => $this->comment->getAll($task['id'], $this->userSession->getCommentSorting())
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -183,4 +183,19 @@ class Comment extends Base
|
|||||||
|
|
||||||
$this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), 'comments'));
|
$this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), 'comments'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Toggle comment sorting
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
public function toggleSorting()
|
||||||
|
{
|
||||||
|
$task = $this->getTask();
|
||||||
|
|
||||||
|
$order = $this->userSession->getCommentSorting() === 'ASC' ? 'DESC' : 'ASC';
|
||||||
|
$this->userSession->setCommentSorting($order);
|
||||||
|
|
||||||
|
$this->response->redirect($this->helper->url->href('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'comments'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ class Task extends Base
|
|||||||
'project' => $this->project->getById($task['project_id']),
|
'project' => $this->project->getById($task['project_id']),
|
||||||
'files' => $this->file->getAllDocuments($task['id']),
|
'files' => $this->file->getAllDocuments($task['id']),
|
||||||
'images' => $this->file->getAllImages($task['id']),
|
'images' => $this->file->getAllImages($task['id']),
|
||||||
'comments' => $this->comment->getAll($task['id']),
|
'comments' => $this->comment->getAll($task['id'], $this->userSession->getCommentSorting()),
|
||||||
'subtasks' => $subtasks,
|
'subtasks' => $subtasks,
|
||||||
'links' => $this->taskLink->getAllGroupedByLabel($task['id']),
|
'links' => $this->taskLink->getAllGroupedByLabel($task['id']),
|
||||||
'task' => $task,
|
'task' => $task,
|
||||||
|
|||||||
@@ -34,9 +34,10 @@ class Comment extends Base
|
|||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @param integer $task_id Task id
|
* @param integer $task_id Task id
|
||||||
|
* @param string $sorting ASC/DESC
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getAll($task_id)
|
public function getAll($task_id, $sorting = 'ASC')
|
||||||
{
|
{
|
||||||
return $this->db
|
return $this->db
|
||||||
->table(self::TABLE)
|
->table(self::TABLE)
|
||||||
@@ -51,7 +52,7 @@ class Comment extends Base
|
|||||||
User::TABLE.'.email'
|
User::TABLE.'.email'
|
||||||
)
|
)
|
||||||
->join(User::TABLE, 'id', 'user_id')
|
->join(User::TABLE, 'id', 'user_id')
|
||||||
->orderBy(self::TABLE.'.date_creation', 'ASC')
|
->orderBy(self::TABLE.'.date_creation', $sorting)
|
||||||
->eq(self::TABLE.'.task_id', $task_id)
|
->eq(self::TABLE.'.task_id', $task_id)
|
||||||
->findAll();
|
->findAll();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -154,4 +154,26 @@ class UserSession extends Base
|
|||||||
{
|
{
|
||||||
$_SESSION['board_collapsed'][$project_id] = $collapsed;
|
$_SESSION['board_collapsed'][$project_id] = $collapsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set comments sorting
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param string $order
|
||||||
|
*/
|
||||||
|
public function setCommentSorting($order)
|
||||||
|
{
|
||||||
|
$this->session['comment_sorting'] = $order;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get comments sorting direction
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getCommentSorting()
|
||||||
|
{
|
||||||
|
return $this->session['comment_sorting'] ?: 'ASC';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,13 @@
|
|||||||
<?php if (! empty($comments)): ?>
|
<?php if (! empty($comments)): ?>
|
||||||
<div id="comments" class="task-show-section">
|
<div id="comments" class="task-show-section">
|
||||||
<div class="page-header">
|
<div class="page-header">
|
||||||
<h2><?= t('Comments') ?></h2>
|
<h2>
|
||||||
|
<?= t('Comments') ?>
|
||||||
|
<span class="comment-sorting">
|
||||||
|
<i class="fa fa-sort"></i>
|
||||||
|
<?= $this->url->link(t('change sorting'), 'comment', 'toggleSorting', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>
|
||||||
|
</span>
|
||||||
|
</h2>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php foreach ($comments as $comment): ?>
|
<?php foreach ($comments as $comment): ?>
|
||||||
@@ -16,13 +22,13 @@
|
|||||||
|
|
||||||
<?php if (! isset($not_editable)): ?>
|
<?php if (! isset($not_editable)): ?>
|
||||||
<?= $this->render('comment/create', array(
|
<?= $this->render('comment/create', array(
|
||||||
'skip_cancel' => true,
|
'skip_cancel' => true,
|
||||||
'values' => array(
|
'values' => array(
|
||||||
'user_id' => $this->user->getId(),
|
'user_id' => $this->user->getId(),
|
||||||
'task_id' => $task['id'],
|
'task_id' => $task['id'],
|
||||||
),
|
),
|
||||||
'errors' => array(),
|
'errors' => array(),
|
||||||
'task' => $task
|
'task' => $task
|
||||||
)) ?>
|
)) ?>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -69,6 +69,20 @@
|
|||||||
max-width: 800px;
|
max-width: 800px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.comment-sorting {
|
||||||
|
font-size: 0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
span.comment-sorting a {
|
||||||
|
color: #555;
|
||||||
|
font-weight: normal;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
span.comment-sorting a:hover {
|
||||||
|
color: #aaa;
|
||||||
|
}
|
||||||
|
|
||||||
#comments .comment-textarea {
|
#comments .comment-textarea {
|
||||||
height: 80px;
|
height: 80px;
|
||||||
width: 500px;
|
width: 500px;
|
||||||
|
|||||||
Reference in New Issue
Block a user