mirror of
https://github.com/freescout-helpdesk/freescout.git
synced 2024-11-24 11:22:42 +01:00
Pagination in customers search
This commit is contained in:
parent
4cc750ec0f
commit
f904057944
@ -363,6 +363,18 @@ class CustomersController extends Controller
|
||||
}
|
||||
break;
|
||||
|
||||
// Conversations navigation
|
||||
case 'customers_pagination':
|
||||
|
||||
$customers = app('App\Http\Controllers\ConversationsController')->searchCustomers($request, $user);
|
||||
|
||||
$response['status'] = 'success';
|
||||
|
||||
$response['html'] = view('customers/partials/customers_table', [
|
||||
'customers' => $customers,
|
||||
])->render();
|
||||
break;
|
||||
|
||||
default:
|
||||
$response['msg'] = 'Unknown action';
|
||||
break;
|
||||
|
53
public/js/main.js
vendored
53
public/js/main.js
vendored
@ -2189,6 +2189,8 @@ function searchInit()
|
||||
conversationPagination();
|
||||
starConversationInit();
|
||||
|
||||
customersPagination();
|
||||
|
||||
$(".sidebar-menu .menu-link a").filter('[data-filter]').click(function(e){
|
||||
var trigger = $(this);
|
||||
var filter = trigger.attr('data-filter');
|
||||
@ -2293,6 +2295,49 @@ function loadConversations(page, table, no_loader)
|
||||
);
|
||||
}
|
||||
|
||||
function loadCustomers(page, table)
|
||||
{
|
||||
var filter = null;
|
||||
//var params = {};
|
||||
|
||||
if ($('body:first').hasClass('body-search')) {
|
||||
filter = {
|
||||
q: getQueryParam('q'), // For search
|
||||
f: getQueryParam('f') // For search
|
||||
};
|
||||
}
|
||||
if (typeof(page) == "undefined" || page === '') {
|
||||
page = table.attr('data-page');
|
||||
}
|
||||
/*var datas = table.data();
|
||||
for (data_name in datas) {
|
||||
if (/^filter_/.test(data_name)) {
|
||||
filter[data_name.replace(/^filter_/, '')] = datas[data_name];
|
||||
}
|
||||
}*/
|
||||
|
||||
fsAjax(
|
||||
{
|
||||
action: 'customers_pagination',
|
||||
filter: filter,
|
||||
//params: params,
|
||||
page: page
|
||||
},
|
||||
laroute.route('customers.ajax'),
|
||||
function(response) {
|
||||
if (isAjaxSuccess(response)) {
|
||||
if (typeof(response.html) != "undefined") {
|
||||
table.replaceWith(response.html);
|
||||
customersPagination();
|
||||
}
|
||||
} else {
|
||||
showAjaxError(response);
|
||||
}
|
||||
loaderHide();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function conversationPagination()
|
||||
{
|
||||
$(".table-conversations .pager-nav").click(function(e){
|
||||
@ -2301,6 +2346,14 @@ function conversationPagination()
|
||||
});
|
||||
}
|
||||
|
||||
function customersPagination()
|
||||
{
|
||||
$(".table-customers .pager-nav").click(function(e){
|
||||
loadCustomers($(this).attr('data-page'), $(this).parents('.table-customers:first'));
|
||||
e.preventDefault();
|
||||
});
|
||||
}
|
||||
|
||||
// Change customer modal
|
||||
function changeCustomerInit()
|
||||
{
|
||||
|
@ -145,7 +145,7 @@
|
||||
@if ($mode == App\Conversation::SEARCH_MODE_CONV)
|
||||
@include('conversations/conversations_table', ['params' => ['show_mailbox' => (count(Auth::user()->mailboxesCanView(true)) > 1)]])
|
||||
@else
|
||||
@include('customers/partials/list')
|
||||
@include('customers/partials/customers_table')
|
||||
@endif
|
||||
</div>
|
||||
@endsection
|
||||
|
23
resources/views/customers/partials/customers_table.blade.php
Normal file
23
resources/views/customers/partials/customers_table.blade.php
Normal file
@ -0,0 +1,23 @@
|
||||
@if (count($customers))
|
||||
<div class="table-customers">
|
||||
<div class="container">
|
||||
<div class="card-list margin-top">
|
||||
@foreach ($customers as $customer)
|
||||
<a href="{{ Eventy::filter('customer.card.url', route('customers.update', ['id' => $customer->id]), $customer) }}" class="card hover-shade" @action('customer.card.link', $customer) >
|
||||
<img src="{{ $customer->getPhotoUrl() }}" />
|
||||
<h4>{{ $customer->first_name }} {{ $customer->last_name }}</h4>
|
||||
<p class="text-truncate"><small>{{ $customer->getEmailOrPhone() }}</small></p>
|
||||
</a>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if ($customers)
|
||||
<div class="customers-pager">
|
||||
{{ $customers->links('conversations/conversations_pagination') }}
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
@else
|
||||
@include('partials/empty', ['empty_text' => __('No customers found')])
|
||||
@endif
|
@ -1,15 +0,0 @@
|
||||
@if (count($customers))
|
||||
<div class="container">
|
||||
<div class="card-list margin-top">
|
||||
@foreach ($customers as $customer)
|
||||
<a href="{{ Eventy::filter('customer.card.url', route('customers.update', ['id' => $customer->id]), $customer) }}" class="card hover-shade" @action('customer.card.link', $customer) >
|
||||
<img src="{{ $customer->getPhotoUrl() }}" />
|
||||
<h4>{{ $customer->first_name }} {{ $customer->last_name }}</h4>
|
||||
<p class="text-truncate"><small>{{ $customer->getEmailOrPhone() }}</small></p>
|
||||
</a>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
@else
|
||||
@include('partials/empty', ['empty_text' => __('No customers found')])
|
||||
@endif
|
Loading…
Reference in New Issue
Block a user