mirror of
https://github.com/freescout-helpdesk/freescout.git
synced 2024-11-24 19:33:07 +01:00
Update search
This commit is contained in:
parent
4e555f3198
commit
826e42085c
@ -173,6 +173,13 @@ class Customer extends Model
|
||||
self::SOCIAL_TYPE_OTHER => 'Other',
|
||||
];
|
||||
|
||||
/**
|
||||
* Search filters.
|
||||
*/
|
||||
public static $search_filters = [
|
||||
'mailbox',
|
||||
];
|
||||
|
||||
/**
|
||||
* Countries list.
|
||||
*/
|
||||
|
@ -2237,15 +2237,21 @@ class ConversationsController extends Controller
|
||||
session()->put('recent_search_queries', $recent_search_queries);
|
||||
}
|
||||
|
||||
$conversations = $this->searchQuery($request, $user, $q, $filters);
|
||||
$conversations = [];
|
||||
if (\Eventy::filter('search.is_needed', true, 'conversations')) {
|
||||
$conversations = $this->searchQuery($request, $user, $q, $filters);
|
||||
}
|
||||
$customers = $this->searchCustomers($request, $user);
|
||||
|
||||
// Dummy folder
|
||||
$folder = $this->getSearchFolder($conversations);
|
||||
|
||||
// List of available filters.
|
||||
$filters_list = \Eventy::filter('search.filters_list', Conversation::$search_filters, $mode, $filters, $q);
|
||||
//$filters_list_all = \Eventy::filter('search.filters_list_all', array_merge(Conversation::$search_filters, Customer::$search_filters), $filters, $q);
|
||||
if ($mode == Conversation::SEARCH_MODE_CONV) {
|
||||
$filters_list = \Eventy::filter('search.filters_list', Conversation::$search_filters, $mode, $filters, $q);
|
||||
} else {
|
||||
$filters_list = \Eventy::filter('search.filters_list_customers', Customer::$search_filters, $mode, $filters, $q);
|
||||
}
|
||||
|
||||
$mailboxes = \Cache::remember('search_filter_mailboxes_'.$user->id, 5, function () use ($user) {
|
||||
return $user->mailboxesCanView();
|
||||
@ -2466,6 +2472,14 @@ class ConversationsController extends Controller
|
||||
->orWhere('emails.email', 'like', $like);
|
||||
});
|
||||
|
||||
if (!empty($filters['mailbox'])) {
|
||||
$query_customers->join('conversations', function ($join) use ($filters) {
|
||||
$join->on('conversations.customer_id', '=', 'customers.id');
|
||||
//$join->on('conversations.mailbox_id', '=', $filters['mailbox']);
|
||||
});
|
||||
$query_customers->where('conversations.mailbox_id', '=', $filters['mailbox']);
|
||||
}
|
||||
|
||||
$query_customers = \Eventy::filter('search.customers.apply_filters', $query_customers, $filters, $q);
|
||||
|
||||
return $query_customers->paginate(50);
|
||||
|
@ -38,7 +38,7 @@ class Helper
|
||||
'conversations.view',
|
||||
'conversations.create',
|
||||
'conversations.draft',
|
||||
'conversations.search',
|
||||
//'conversations.search',
|
||||
],
|
||||
'manage' => [
|
||||
'settings' => 'settings',
|
||||
|
2
public/js/main.js
vendored
2
public/js/main.js
vendored
@ -2189,7 +2189,7 @@ function searchInit()
|
||||
conversationPagination();
|
||||
starConversationInit();
|
||||
|
||||
$(".sidebar-menu .menu-link a").click(function(e){
|
||||
$(".sidebar-menu .menu-link a").filter('[data-filter]').click(function(e){
|
||||
var trigger = $(this);
|
||||
var filter = trigger.attr('data-filter');
|
||||
if (!trigger.parent().hasClass('active')) {
|
||||
|
Loading…
Reference in New Issue
Block a user