Display user initials when tasks are in collapsed mode
This commit is contained in:
parent
0a9ad08e9e
commit
c231b65cfc
|
|
@ -10,6 +10,24 @@ namespace Helper;
|
|||
*/
|
||||
class User extends \Core\Base
|
||||
{
|
||||
/**
|
||||
* Get initials from a user
|
||||
*
|
||||
* @access public
|
||||
* @param string $name
|
||||
* @return string
|
||||
*/
|
||||
public function getInitials($name)
|
||||
{
|
||||
$initials = '';
|
||||
|
||||
foreach (explode(' ', $name) as $string) {
|
||||
$initials .= mb_substr($string, 0, 1);
|
||||
}
|
||||
|
||||
return mb_strtoupper($initials);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user id
|
||||
*
|
||||
|
|
|
|||
|
|
@ -11,6 +11,11 @@
|
|||
<?= $this->render('board/task_menu', array('task' => $task)) ?>
|
||||
|
||||
<div class="task-board-collapsed" style="display: none">
|
||||
<?php if (! empty($task['assignee_username'])): ?>
|
||||
<span title="<?= $this->e($task['assignee_name'] ?: $task['assignee_username']) ?>">
|
||||
<?= $this->e($this->user->getInitials($task['assignee_name'] ?: $task['assignee_username'])) ?>
|
||||
</span> -
|
||||
<?php endif ?>
|
||||
<?= $this->url->link($this->e($task['title']), 'task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'task-board-collapsed-title') ?>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
require_once __DIR__.'/Base.php';
|
||||
|
||||
use Helper\User;
|
||||
|
||||
class UserHelperTest extends Base
|
||||
{
|
||||
public function testInitials()
|
||||
{
|
||||
$h = new User($this->container);
|
||||
|
||||
$this->assertEquals('CN', $h->getInitials('chuck norris'));
|
||||
$this->assertEquals('A', $h->getInitials('admin'));
|
||||
$this->assertEquals('漢', $h->getInitials('漢字'));
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue