select user own first
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2022 Yurii Kuznietsov, Taras Machyshyn, Oleksii Avramenko
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Classes\Select\User\OrderItemConverters;
|
||||
|
||||
use Espo\Core\Select\Order\ItemConverter;
|
||||
use Espo\Core\Select\Order\Item;
|
||||
|
||||
use Espo\ORM\Query\Part\OrderList;
|
||||
use Espo\ORM\Query\Part\Order;
|
||||
use Espo\ORM\Query\Part\Expression as Expr;
|
||||
|
||||
use Espo\Entities\User;
|
||||
|
||||
class UserNameOwnFirst implements ItemConverter
|
||||
{
|
||||
private User $user;
|
||||
|
||||
public function __construct(User $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
}
|
||||
|
||||
public function convert(Item $item): OrderList
|
||||
{
|
||||
return OrderList::create([
|
||||
Order
|
||||
::create(
|
||||
Expr::notEqual(
|
||||
Expr::column('id'),
|
||||
$this->user->getId()
|
||||
)
|
||||
)
|
||||
->withDirection($item->getOrder()),
|
||||
Order
|
||||
::create(Expr::column('userName'))
|
||||
->withDirection($item->getOrder()),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -80,12 +80,18 @@ class Item
|
||||
return $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an order-by field.
|
||||
*/
|
||||
public function getOrderBy(): ?string
|
||||
{
|
||||
/** @var ?string */
|
||||
return $this->orderBy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a direction of order.
|
||||
*/
|
||||
public function getOrder(): ?string
|
||||
{
|
||||
/** @var ?string */
|
||||
|
||||
@@ -120,5 +120,8 @@
|
||||
"selectDefaultFilters": {
|
||||
"filter": "active"
|
||||
},
|
||||
"selectRecords": {
|
||||
"orderBy": "userNameOwnFirst"
|
||||
},
|
||||
"iconClass": "fas fa-user-circle"
|
||||
}
|
||||
|
||||
@@ -18,5 +18,8 @@
|
||||
},
|
||||
"boolFilterClassNameMap": {
|
||||
"onlyMyTeam": "Espo\\Classes\\Select\\User\\BoolFilters\\OnlyMyTeam"
|
||||
},
|
||||
"orderItemConverterClassNameMap": {
|
||||
"userNameOwnFirst": "Espo\\Classes\\Select\\User\\OrderItemConverters\\UserNameOwnFirst"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,6 +118,14 @@ define('views/modals/select-records', ['views/modal', 'search-manager'], functio
|
||||
|
||||
this.scope = this.entityType = this.options.scope || this.scope;
|
||||
|
||||
let customDefaultOrderBy = this.getMetadata().get(['clientDefs', this.scope, 'selectRecords', 'orderBy']);
|
||||
let customDefaultOrder = this.getMetadata().get(['clientDefs', this.scope, 'selectRecords', 'order']);
|
||||
|
||||
if (customDefaultOrderBy) {
|
||||
this.defaultOrderBy = customDefaultOrderBy;
|
||||
this.defaultOrder = customDefaultOrder || false;
|
||||
}
|
||||
|
||||
if (this.noCreateScopeList.indexOf(this.scope) !== -1) {
|
||||
this.createButton = false;
|
||||
}
|
||||
@@ -151,7 +159,7 @@ define('views/modals/select-records', ['views/modal', 'search-manager'], functio
|
||||
this.collection = collection;
|
||||
|
||||
if (this.defaultOrderBy) {
|
||||
this.collection.setOrder(this.defaultOrderBy, this.defaultOrder || false, true);
|
||||
this.collection.setOrder(this.defaultOrderBy, this.defaultOrder || 'asc', true);
|
||||
}
|
||||
|
||||
this.loadSearch();
|
||||
|
||||
Reference in New Issue
Block a user