Add table field sorting for user and groups
Change-Id: If413a861559e7baad0ba5b511beb587ae03fa828 Signed-off-by: smarcet <smarcet@gmail.com>
This commit is contained in:
parent
0705f655eb
commit
26ba433bd5
@ -69,6 +69,7 @@ final class GroupApiController extends APICRUDController
|
||||
*/
|
||||
protected function getOrderRules():array{
|
||||
return [
|
||||
'id',
|
||||
'name',
|
||||
'slug'
|
||||
];
|
||||
|
@ -85,6 +85,20 @@ final class UserApiController extends APICRUDController
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function getOrderRules():array{
|
||||
return [
|
||||
'first_name',
|
||||
'last_name',
|
||||
'email',
|
||||
'identifier',
|
||||
'last_login_date',
|
||||
'spam_type'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
* @return mixed
|
||||
|
@ -13,10 +13,6 @@
|
||||
**/
|
||||
use App\libs\Auth\Repositories\IGroupRepository;
|
||||
use Auth\Group;
|
||||
use utils\Filter;
|
||||
use utils\Order;
|
||||
use utils\PagingInfo;
|
||||
use utils\PagingResponse;
|
||||
/**
|
||||
* Class DoctrineGroupRepository
|
||||
* @package App\Repositories
|
||||
@ -30,6 +26,7 @@ final class DoctrineGroupRepository extends ModelDoctrineRepository implements I
|
||||
protected function getOrderMappings()
|
||||
{
|
||||
return [
|
||||
'id' => 'e.id',
|
||||
'name' => 'e.name',
|
||||
'slug' => 'e.slug',
|
||||
];
|
||||
|
@ -15,15 +15,30 @@ use Auth\Repositories\IUserRepository;
|
||||
use Auth\User;
|
||||
use utils\DoctrineFilterMapping;
|
||||
use utils\DoctrineJoinFilterMapping;
|
||||
use utils\DoctrineLeftJoinFilterMapping;
|
||||
|
||||
/**
|
||||
* Class DoctrineUserRepository
|
||||
* @package App\Repositories
|
||||
*/
|
||||
final class DoctrineUserRepository extends ModelDoctrineRepository implements IUserRepository
|
||||
final class DoctrineUserRepository
|
||||
extends ModelDoctrineRepository implements IUserRepository
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function getOrderMappings()
|
||||
{
|
||||
return [
|
||||
'first_name' => 'e.first_name',
|
||||
'last_name' => 'e.last_name',
|
||||
'email' => 'e.email',
|
||||
'active' => 'e.active',
|
||||
'identifier' => 'e.identifier',
|
||||
'last_login_date' => 'e.last_login_date',
|
||||
'spam_type' => 'e.spam_type',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
|
22
public/assets/css/main.css
vendored
22
public/assets/css/main.css
vendored
@ -348,3 +348,25 @@ span.help-block::before {
|
||||
vertical-align: middle;
|
||||
display:table-cell;
|
||||
}
|
||||
|
||||
.sort-header{
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.sort-header.current.desc:after{
|
||||
content: '\f0dd';
|
||||
font-family: FontAwesome;
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
margin:0px 0px 0px 10px;
|
||||
text-decoration:none;
|
||||
}
|
||||
|
||||
.sort-header.current.asc:after{
|
||||
content: '\f0de';
|
||||
font-family: FontAwesome;
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
margin:0px 0px 0px 10px;
|
||||
text-decoration:none;
|
||||
}
|
@ -57,6 +57,8 @@ GroupsCrud.prototype._buildFilters = function () {
|
||||
GroupsCrud.prototype.init = function () {
|
||||
BasicCrud.prototype.init.call(this);
|
||||
var _this = this;
|
||||
// default sort
|
||||
this.orderBy= encodeURI('+name');
|
||||
|
||||
var add_item_form = $('#form-add-item');
|
||||
var add_item_dialog = $("#dialog-form-add-item");
|
||||
|
@ -68,6 +68,8 @@ UsersCrud.prototype.init = function () {
|
||||
// Chain parent method
|
||||
BasicCrud.prototype.init.call(this);
|
||||
var _this = this;
|
||||
// default sort
|
||||
this.orderBy= encodeURI('+email');
|
||||
|
||||
$("body").on('click', ".user-active-checkbox", function (event) {
|
||||
var active = $(this).is(':checked');
|
||||
|
@ -28,6 +28,26 @@ BasicCrud.prototype = {
|
||||
|
||||
$('#btn-do-search-clear').hide();
|
||||
|
||||
$("body").on('click',".sort-header",function (event) {
|
||||
$(".sort-header").removeClass("current");
|
||||
$(this).addClass('current');
|
||||
var dir = '+';
|
||||
if($(this).hasClass('asc')){
|
||||
$(this).removeClass('asc');
|
||||
$(this).addClass('desc');
|
||||
dir = '-';
|
||||
}
|
||||
else {
|
||||
dir = '+';
|
||||
$(this).removeClass('desc');
|
||||
$(this).addClass('asc');
|
||||
}
|
||||
|
||||
var field = $(this).data('field');
|
||||
_this.orderBy = encodeURI(dir+field);
|
||||
_this.loadPage();
|
||||
});
|
||||
|
||||
var currentTermFromDeepLink = $(window).url_fragment('getParam', 'term');
|
||||
if (currentTermFromDeepLink != null) {
|
||||
$('#search-term').val(currentTermFromDeepLink);
|
||||
@ -136,7 +156,6 @@ BasicCrud.prototype = {
|
||||
var url = this.urls.load + '?page=' + parseInt(this.currentPage) + '&per_page=' + this.perPage;
|
||||
|
||||
if (this.searchTerm != null && this.searchTerm != '') {
|
||||
|
||||
url += '&' + this._buildFilters();
|
||||
}
|
||||
|
||||
|
@ -24,9 +24,9 @@
|
||||
<table id="table" class="table table-hover table-condensed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Id</th>
|
||||
<th>Name</th>
|
||||
<th>Slug</th>
|
||||
<th data-field="id" class="sort-header">Id</th>
|
||||
<th data-field="name" class="sort-header current asc">Name</th>
|
||||
<th data-field="slug" class="sort-header">Slug</th>
|
||||
<th>Active</th>
|
||||
<th> </th>
|
||||
</tr>
|
||||
|
@ -24,13 +24,13 @@
|
||||
<table id="table" class="table table-hover table-condensed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Identifier</th>
|
||||
<th>First Name</th>
|
||||
<th>Surname</th>
|
||||
<th>Email</th>
|
||||
<th data-field="identifier" class="sort-header">Identifier</th>
|
||||
<th data-field="first_name" class="sort-header">First Name</th>
|
||||
<th data-field="last_name" class="sort-header">Surname</th>
|
||||
<th data-field="email" class="sort-header current asc">Email</th>
|
||||
<th>Active</th>
|
||||
<th>Last Login Date</th>
|
||||
<th>Spam Type</th>
|
||||
<th data-field="last_login_date" class="sort-header">Last Login Date</th>
|
||||
<th data-field="spam_type" class="sort-header">Spam Type</th>
|
||||
<th> </th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
Loading…
Reference in New Issue
Block a user