1
0
mirror of https://github.com/freescout-helpdesk/freescout.git synced 2024-11-24 11:22:42 +01:00

Show waiting since time in dashboard

This commit is contained in:
FreeScout 2018-12-05 04:33:05 -08:00
parent 4d753b60d3
commit 2373771be8
5 changed files with 90 additions and 16 deletions

View File

@ -1047,4 +1047,19 @@ class Conversation extends Model
$thread->deleteThread();
});
}
/**
* Get waiting since time for the conversation.
* @param [type] $folder [description]
* @return [type] [description]
*/
public function getWaitingSince($folder)
{
$waiting_since_field = $folder->getWaitingSinceField();
if ($waiting_since_field) {
return \App\User::dateDiffForHumans($this->$waiting_since_field);
} else {
return '';
}
}
}

View File

@ -96,7 +96,15 @@ class Folder extends Model
public function getTypeName()
{
return __(self::$types[$this->type]);
// To make name translatable.
switch ($this->type) {
case self::TYPE_UNASSIGNED:
return __('Unassigned');
case self::TYPE_MINE:
return __('Mine');
default:
return __(self::$types[$this->type]);
}
}
public function getTypeIcon()
@ -230,4 +238,57 @@ class Folder extends Model
return $active_count;
}
public function getConversationsQuery()
{
if ($this->type == self::TYPE_MINE) {
// Assigned to user.
return Conversation::where('user_id', $this->user_id)
->where('mailbox_id', $this->mailbox_id);
} elseif ($this->isIndirect()) {
// Via intermediate table.
return Conversation::join('conversation_folder', 'conversations.id', '=', 'conversation_folder.conversation_id')
->where('conversation_folder.folder_id', $this->id);
} else {
// All other conversations.
return $this->conversations();
}
}
/**
* Works for main folder only for now.
*
* @return [type] [description]
*/
public function getWaitingSince()
{
// Get oldest active conversation.
$conversation = $this->getConversationsQuery()
->where('state', Conversation::STATE_PUBLISHED)
->where('status', Conversation::STATUS_ACTIVE)
->orderBy($this->getWaitingSinceField(), 'asc')
->first();
if ($conversation) {
return $conversation->getWaitingSince($this);
} else {
return '';
}
}
/**
* Get conversation field used to detect waiting since time.
* @return [type] [description]
*/
public function getWaitingSinceField()
{
if ($this->type == \App\Folder::TYPE_CLOSED) {
return 'closed_at';
} elseif ($this->type == \App\Folder::TYPE_DRAFTS) {
return 'updated_at';
} elseif ($this->type == \App\Folder::TYPE_DELETED) {
return 'user_updated_at';
} else {
return'last_reply_at';
}
}
}

11
public/css/style.css vendored
View File

@ -721,7 +721,7 @@ a h4 {
box-sizing: border-box;
min-height: 295px;
margin: 0 20px 20px 0;
width: 235px;
width: 257px;
}
.dash-card-content {
padding-bottom: 60px;
@ -769,10 +769,15 @@ a h4 {
margin: 0;
display: block;
}
.dash-card .waiting-since {
color: #93a1af;
font-size: 13.4px;
margin-left: 4px;
}
.dash-card-list-item:hover {
background-color: #f4f5f5;
}
.dash-card-list-item span {
.dash-card-list-item strong {
display: block;
float: right;
}
@ -796,7 +801,7 @@ a h4 {
/*border-left-color: #93a1af;*/
background: #f4f5f5;
}
.dash-card-item-empty span {
.dash-card-item-empty strong {
display: none;
}
.dash-card a.dash-card-item-empty,

View File

@ -136,17 +136,7 @@
<a href="{{ $conversation->url() }}" title="{{ __('View conversation') }}">{{ $conversation->number }}</a>
</td>
<td class="conv-date">
<a href="{{ $conversation->url() }}" @if (!in_array($folder->type, [App\Folder::TYPE_CLOSED, App\Folder::TYPE_DRAFTS, App\Folder::TYPE_DELETED])) data-toggle="tooltip" data-html="true" data-placement="left" title="{{ $conversation->getDateTitle() }}"@else title="{{ __('View conversation') }}" @endif >
@if ($folder->type == App\Folder::TYPE_CLOSED)
{{ App\User::dateDiffForHumans($conversation->closed_at) }}
@elseif ($folder->type == App\Folder::TYPE_DRAFTS)
{{ App\User::dateDiffForHumans($conversation->updated_at) }}
@elseif ($folder->type == App\Folder::TYPE_DELETED)
{{ App\User::dateDiffForHumans($conversation->user_updated_at) }}
@else
{{ App\User::dateDiffForHumans($conversation->last_reply_at) }}
@endif
</a>
<a href="{{ $conversation->url() }}" @if (!in_array($folder->type, [App\Folder::TYPE_CLOSED, App\Folder::TYPE_DRAFTS, App\Folder::TYPE_DELETED])) data-toggle="tooltip" data-html="true" data-placement="left" title="{{ $conversation->getDateTitle() }}"@else title="{{ __('View conversation') }}" @endif >{{ $conversation->getWaitingSince($folder) }}</a>
</td>
</tr>
@endforeach

View File

@ -20,7 +20,10 @@
$main_folders = $mailbox->getMainFolders();
@endphp
@foreach ($main_folders as $folder)
<a href="{{ route('mailboxes.view.folder', ['id' => $mailbox->id, 'folder_id' => $folder->id]) }}" class="dash-card-list-item @if (!$folder->active_count) dash-card-item-empty @endif" title="{{ __('View conversations') }}">{{ $folder->getTypeName() }}<span>{{ $folder->getActiveCount($main_folders) }}</span></a>
@php
$active_count = $folder->getActiveCount($main_folders);
@endphp
<a href="{{ route('mailboxes.view.folder', ['id' => $mailbox->id, 'folder_id' => $folder->id]) }}" class="dash-card-list-item @if (!$active_count) dash-card-item-empty @endif" title="@if ($active_count){{ __('Waiting Since') }}@else{{ __('View conversations') }}@endif">{{ $folder->getTypeName() }}@if ($active_count)<span class="waiting-since">/ {{ $folder->getWaitingSince() }}</span>@endif<strong>{{ $active_count }}</strong></a>
@endforeach
</div>
<div class="dash-card-inactive-content">