orderBy param
This commit is contained in:
@@ -130,10 +130,6 @@ class EntityManager extends \Espo\Core\Controllers\Base
|
||||
$name = $data['name'];
|
||||
$name = filter_var($name, \FILTER_SANITIZE_STRING);
|
||||
|
||||
if (!empty($data['sortDirection'])) {
|
||||
$data['asc'] = $data['sortDirection'] === 'asc';
|
||||
}
|
||||
|
||||
$result = $this->getContainer()->get('entityManagerUtil')->update($name, $data);
|
||||
|
||||
if ($result) {
|
||||
|
||||
@@ -125,34 +125,17 @@ class Record extends Base
|
||||
throw new Forbidden();
|
||||
}
|
||||
|
||||
$where = $request->get('where');
|
||||
$offset = $request->get('offset');
|
||||
$maxSize = $request->get('maxSize');
|
||||
$asc = $request->get('asc', 'true') === 'true';
|
||||
$sortBy = $request->get('sortBy');
|
||||
$q = $request->get('q');
|
||||
$textFilter = $request->get('textFilter');
|
||||
$params = [];
|
||||
$this->fetchListParamsFromRequest($params, $request, $data);
|
||||
|
||||
$maxSizeLimit = $this->getConfig()->get('recordListMaxSizeLimit', self::MAX_SIZE_LIMIT);
|
||||
if (empty($maxSize)) {
|
||||
$maxSize = $maxSizeLimit;
|
||||
if (empty($params['maxSize'])) {
|
||||
$params['maxSize'] = $maxSizeLimit;
|
||||
}
|
||||
if (!empty($maxSize) && $maxSize > $maxSizeLimit) {
|
||||
if (!empty($params['maxSize']) && $params['maxSize'] > $maxSizeLimit) {
|
||||
throw new Forbidden("Max size should should not exceed " . $maxSizeLimit . ". Use offset and limit.");
|
||||
}
|
||||
|
||||
$params = array(
|
||||
'where' => $where,
|
||||
'offset' => $offset,
|
||||
'maxSize' => $maxSize,
|
||||
'asc' => $asc,
|
||||
'sortBy' => $sortBy,
|
||||
'q' => $q,
|
||||
'textFilter' => $textFilter
|
||||
);
|
||||
|
||||
$this->fetchListParamsFromRequest($params, $request, $data);
|
||||
|
||||
$result = $this->getRecordService()->findEntities($params);
|
||||
|
||||
return array(
|
||||
@@ -167,34 +150,17 @@ class Record extends Base
|
||||
throw new Forbidden();
|
||||
}
|
||||
|
||||
$where = $request->get('where');
|
||||
$offset = $request->get('offset');
|
||||
$maxSize = $request->get('maxSize');
|
||||
$asc = $request->get('asc', 'true') === 'true';
|
||||
$sortBy = $request->get('sortBy');
|
||||
$q = $request->get('q');
|
||||
$textFilter = $request->get('textFilter');
|
||||
$params = [];
|
||||
$this->fetchListParamsFromRequest($params, $request, $data);
|
||||
|
||||
$maxSizeLimit = $this->getConfig()->get('recordListMaxSizeLimit', self::MAX_SIZE_LIMIT);
|
||||
if (empty($maxSize)) {
|
||||
$maxSize = $maxSizeLimit;
|
||||
if (empty($params['maxSize'])) {
|
||||
$params['maxSize'] = $maxSizeLimit;
|
||||
}
|
||||
if (!empty($maxSize) && $maxSize > $maxSizeLimit) {
|
||||
if (!empty($params['maxSize']) && $params['maxSize'] > $maxSizeLimit) {
|
||||
throw new Forbidden("Max size should should not exceed " . $maxSizeLimit . ". Use offset and limit.");
|
||||
}
|
||||
|
||||
$params = array(
|
||||
'where' => $where,
|
||||
'offset' => $offset,
|
||||
'maxSize' => $maxSize,
|
||||
'asc' => $asc,
|
||||
'sortBy' => $sortBy,
|
||||
'q' => $q,
|
||||
'textFilter' => $textFilter
|
||||
);
|
||||
|
||||
$this->fetchListParamsFromRequest($params, $request, $data);
|
||||
|
||||
$result = $this->getRecordService()->getListKanban($params);
|
||||
|
||||
return (object) [
|
||||
@@ -214,34 +180,17 @@ class Record extends Base
|
||||
$id = $params['id'];
|
||||
$link = $params['link'];
|
||||
|
||||
$where = $request->get('where');
|
||||
$offset = $request->get('offset');
|
||||
$maxSize = $request->get('maxSize');
|
||||
$asc = $request->get('asc', 'true') === 'true';
|
||||
$sortBy = $request->get('sortBy');
|
||||
$q = $request->get('q');
|
||||
$textFilter = $request->get('textFilter');
|
||||
$params = [];
|
||||
$this->fetchListParamsFromRequest($params, $request, $data);
|
||||
|
||||
$maxSizeLimit = $this->getConfig()->get('recordListMaxSizeLimit', self::MAX_SIZE_LIMIT);
|
||||
if (empty($maxSize)) {
|
||||
$maxSize = $maxSizeLimit;
|
||||
if (empty($params['maxSize'])) {
|
||||
$params['maxSize'] = $maxSizeLimit;
|
||||
}
|
||||
if (!empty($maxSize) && $maxSize > $maxSizeLimit) {
|
||||
if (!empty($params['maxSize']) && $params['maxSize'] > $maxSizeLimit) {
|
||||
throw new Forbidden("Max size should should not exceed " . $maxSizeLimit . ". Use offset and limit.");
|
||||
}
|
||||
|
||||
$params = array(
|
||||
'where' => $where,
|
||||
'offset' => $offset,
|
||||
'maxSize' => $maxSize,
|
||||
'asc' => $asc,
|
||||
'sortBy' => $sortBy,
|
||||
'q' => $q,
|
||||
'textFilter' => $textFilter
|
||||
);
|
||||
|
||||
$this->fetchListParamsFromRequest($params, $request, $data);
|
||||
|
||||
$result = $this->getRecordService()->findLinkedEntities($id, $link, $params);
|
||||
|
||||
return array(
|
||||
|
||||
@@ -136,8 +136,11 @@ class Base
|
||||
|
||||
protected function order($sortBy, $desc = false, &$result)
|
||||
{
|
||||
if (!empty($sortBy)) {
|
||||
if (is_string($desc)) {
|
||||
$desc = $desc === strtolower('desc');
|
||||
}
|
||||
|
||||
if (!empty($sortBy)) {
|
||||
$result['orderBy'] = $sortBy;
|
||||
$type = $this->getMetadata()->get(['entityDefs', $this->getEntityType(), 'fields', $sortBy, 'type']);
|
||||
if (in_array($type, ['link', 'file', 'image'])) {
|
||||
@@ -423,7 +426,7 @@ class Base
|
||||
protected function prepareResult(&$result)
|
||||
{
|
||||
if (empty($result)) {
|
||||
$result = array();
|
||||
$result = [];
|
||||
}
|
||||
if (empty($result['joins'])) {
|
||||
$result['joins'] = [];
|
||||
@@ -699,14 +702,26 @@ class Base
|
||||
|
||||
public function getSelectParams(array $params, $withAcl = false, $checkWherePermission = false)
|
||||
{
|
||||
$result = array();
|
||||
$result = [];
|
||||
$this->prepareResult($result);
|
||||
|
||||
if (!empty($params['sortBy'])) {
|
||||
if (!array_key_exists('asc', $params)) {
|
||||
$params['asc'] = true;
|
||||
if (!empty($params['orderBy'])) {
|
||||
$isDesc = false;
|
||||
if (isset($params['order'])) {
|
||||
$isDesc = $params['order'] === 'desc';
|
||||
}
|
||||
$this->order($params['sortBy'], !$params['asc'], $result);
|
||||
$this->order($params['orderBy'], $isDesc, $result);
|
||||
} else if (!empty($params['sortBy'])) {
|
||||
if (isset($params['order'])) {
|
||||
$isDesc = $params['order'] === 'desc';
|
||||
} else if (isset($params['asc'])) {
|
||||
$isDesc = $params['asc'] !== true;
|
||||
}
|
||||
$this->order($params['sortBy'], $isDesc, $result);
|
||||
} else if (!empty($params['order'])) {
|
||||
$orderBy = $this->getMetadata()->get(['entityDefs', $this->getEntityType(), 'collection', 'orderBy']);
|
||||
$isDesc = $params['order'] === 'desc';
|
||||
$this->order($orderBy, $isDesc, $result);
|
||||
}
|
||||
|
||||
if (!isset($params['offset'])) {
|
||||
|
||||
@@ -57,8 +57,8 @@
|
||||
}
|
||||
},
|
||||
"collection": {
|
||||
"sortBy": "createdAt",
|
||||
"asc": false
|
||||
"orderBy": "createdAt",
|
||||
"order": "desc"
|
||||
},
|
||||
"indexes": {
|
||||
"name": {
|
||||
|
||||
@@ -75,8 +75,8 @@
|
||||
}
|
||||
},
|
||||
"collection": {
|
||||
"sortBy": "createdAt",
|
||||
"asc": false
|
||||
"orderBy": "createdAt",
|
||||
"order": "desc"
|
||||
},
|
||||
"indexes": {
|
||||
"name": {
|
||||
|
||||
@@ -72,8 +72,8 @@
|
||||
}
|
||||
},
|
||||
"collection": {
|
||||
"sortBy": "parent",
|
||||
"asc": true
|
||||
"orderBy": "parent",
|
||||
"order": "asc"
|
||||
},
|
||||
"indexes": {
|
||||
"name": {
|
||||
|
||||
@@ -136,8 +136,8 @@
|
||||
}
|
||||
},
|
||||
"collection": {
|
||||
"sortBy": "createdAt",
|
||||
"asc": false
|
||||
"orderBy": "createdAt",
|
||||
"order": "desc"
|
||||
},
|
||||
"indexes": {
|
||||
"name": {
|
||||
|
||||
@@ -101,8 +101,8 @@
|
||||
}
|
||||
},
|
||||
"collection": {
|
||||
"sortBy": "dateStart",
|
||||
"asc": false
|
||||
"orderBy": "dateStart",
|
||||
"order": "desc"
|
||||
},
|
||||
"indexes": {
|
||||
"dateStartStatus": {
|
||||
|
||||
@@ -126,8 +126,8 @@
|
||||
}
|
||||
},
|
||||
"collection": {
|
||||
"sortBy": "createdAt",
|
||||
"asc": false
|
||||
"orderBy": "createdAt",
|
||||
"order": "desc"
|
||||
},
|
||||
"indexes": {
|
||||
"firstName": {
|
||||
|
||||
@@ -33,6 +33,28 @@ class ControllerUtil
|
||||
{
|
||||
public static function fetchListParamsFromRequest(&$params, $request, $data)
|
||||
{
|
||||
$params['where'] = $request->get('where');
|
||||
$params['maxSize'] = $request->get('maxSize');
|
||||
$params['offset'] = $request->get('offset');
|
||||
|
||||
if ($request->get('orderBy')) {
|
||||
$params['orderBy'] = $request->get('orderBy');
|
||||
} else if ($request->get('sortBy')) {
|
||||
$params['orderBy'] = $request->get('sortBy');
|
||||
}
|
||||
|
||||
if ($request->get('order')) {
|
||||
$params['order'] = $request->get('order');
|
||||
} else if ($request->get('asc')) {
|
||||
$params['order'] = $request->get('asc') === 'true' ? 'asc' : 'desc';
|
||||
}
|
||||
|
||||
if ($request->get('q')) {
|
||||
$params['q'] = $request->get('q');
|
||||
}
|
||||
if ($request->get('textFilter')) {
|
||||
$params['textFilter'] = $request->get('textFilter');
|
||||
}
|
||||
if ($request->get('primaryFilter')) {
|
||||
$params['primaryFilter'] = $request->get('primaryFilter');
|
||||
}
|
||||
|
||||
@@ -213,16 +213,16 @@ class Converter
|
||||
$collectionDefs = $entityMetadata['collection'];
|
||||
$ormMetadata[$entityName]['collection'] = array();
|
||||
|
||||
if (array_key_exists('sortByByColumn', $collectionDefs)) {
|
||||
$ormMetadata[$entityName]['collection']['orderBy'] = $collectionDefs['sortByByColumn'];
|
||||
} else if (array_key_exists('sortBy', $collectionDefs)) {
|
||||
if (array_key_exists($collectionDefs['sortBy'], $ormMetadata[$entityName]['fields'])) {
|
||||
$ormMetadata[$entityName]['collection']['orderBy'] = $collectionDefs['sortBy'];
|
||||
if (array_key_exists('orderByColumn', $collectionDefs)) {
|
||||
$ormMetadata[$entityName]['collection']['orderBy'] = $collectionDefs['orderByColumn'];
|
||||
} else if (array_key_exists('orderBy', $collectionDefs)) {
|
||||
if (array_key_exists($collectionDefs['orderBy'], $ormMetadata[$entityName]['fields'])) {
|
||||
$ormMetadata[$entityName]['collection']['orderBy'] = $collectionDefs['orderBy'];
|
||||
}
|
||||
}
|
||||
$ormMetadata[$entityName]['collection']['order'] = 'ASC';
|
||||
if (array_key_exists('asc', $collectionDefs)) {
|
||||
$ormMetadata[$entityName]['collection']['order'] = $collectionDefs['asc'] ? 'ASC' : 'DESC';
|
||||
if (array_key_exists('order', $collectionDefs)) {
|
||||
$ormMetadata[$entityName]['collection']['order'] = strtoupper($collectionDefs['order']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -413,12 +413,15 @@ class EntityManager
|
||||
}
|
||||
|
||||
if (isset($data['sortBy'])) {
|
||||
$entityDefsData = array(
|
||||
'collection' => array(
|
||||
'sortBy' => $data['sortBy'],
|
||||
'asc' => !empty($data['asc'])
|
||||
)
|
||||
);
|
||||
$entityDefsData = [
|
||||
'collection' => [
|
||||
'orderBy' => $data['sortBy']
|
||||
]
|
||||
];
|
||||
if (isset($data['sortDirection'])) {
|
||||
$entityDefsData['collection']['order'] = $data['sortDirection'];
|
||||
}
|
||||
|
||||
$this->getMetadata()->set('entityDefs', $name, $entityDefsData);
|
||||
}
|
||||
|
||||
@@ -1060,6 +1063,8 @@ class EntityManager
|
||||
$this->getMetadata()->delete('entityDefs', $scope, [
|
||||
'collection.sortBy',
|
||||
'collection.asc',
|
||||
'collection.orderBy',
|
||||
'collection.order',
|
||||
'collection.textFilterFields'
|
||||
]);
|
||||
$this->getMetadata()->save();
|
||||
|
||||
@@ -309,6 +309,24 @@ class Metadata
|
||||
$fieldDefinitionList = Util::objectToArray($data->fields);
|
||||
|
||||
foreach (get_object_vars($data->entityDefs) as $entityType => $entityDefsItem) {
|
||||
|
||||
if (isset($data->entityDefs->$entityType->collection)) {
|
||||
|
||||
$collectionItem = $data->entityDefs->$entityType->collection;
|
||||
|
||||
if (isset($collectionItem->orderBy)) {
|
||||
$collectionItem->sortBy = $collectionItem->orderBy;
|
||||
} else if (isset($collectionItem->sortBy)) {
|
||||
$collectionItem->orderBy = $collectionItem->sortBy;
|
||||
}
|
||||
|
||||
if (isset($collectionItem->order)) {
|
||||
$collectionItem->asc = $collectionItem->order === 'asc' ? true : false;
|
||||
} else if (isset($collectionItem->asc)) {
|
||||
$collectionItem->order = $collectionItem->asc === true ? 'asc' : 'desc';
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($entityDefsItem->fields)) continue;
|
||||
foreach (get_object_vars($entityDefsItem->fields) as $field => $fieldDefsItem) {
|
||||
$additionalFields = $this->getMetadataHelper()->getAdditionalFieldList($field, Util::objectToArray($fieldDefsItem), $fieldDefinitionList);
|
||||
|
||||
@@ -172,8 +172,8 @@ class Activities extends \Espo\Core\Controllers\Base
|
||||
|
||||
$offset = intval($request->get('offset'));
|
||||
$maxSize = intval($request->get('maxSize'));
|
||||
$asc = $request->get('asc') === 'true';
|
||||
$sortBy = $request->get('sortBy');
|
||||
$order = $request->get('order');
|
||||
$orderBy = $request->get('orderBy');
|
||||
$where = $request->get('where');
|
||||
|
||||
$maxSizeLimit = $this->getConfig()->get('recordListMaxSizeLimit', self::MAX_SIZE_LIMIT);
|
||||
@@ -193,13 +193,13 @@ class Activities extends \Espo\Core\Controllers\Base
|
||||
|
||||
$methodName = 'get' . ucfirst($name);
|
||||
|
||||
return $service->$methodName($entityType, $id, array(
|
||||
return $service->$methodName($entityType, $id, [
|
||||
'scope' => $scope,
|
||||
'offset' => $offset,
|
||||
'maxSize' => $maxSize,
|
||||
'asc' => $asc,
|
||||
'sortBy' => $sortBy,
|
||||
));
|
||||
'order' => $order,
|
||||
'orderBy' => $orderBy,
|
||||
]);
|
||||
}
|
||||
|
||||
public function getActionEntityTypeList($params, $data, $request)
|
||||
@@ -222,33 +222,18 @@ class Activities extends \Espo\Core\Controllers\Base
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
$where = $request->get('where');
|
||||
$offset = $request->get('offset');
|
||||
$maxSize = $request->get('maxSize');
|
||||
$asc = $request->get('asc', 'true') === 'true';
|
||||
$sortBy = $request->get('sortBy');
|
||||
$q = $request->get('q');
|
||||
$textFilter = $request->get('textFilter');
|
||||
|
||||
$maxSizeLimit = $this->getConfig()->get('recordListMaxSizeLimit', 200);
|
||||
if (empty($maxSize)) {
|
||||
$maxSize = $maxSizeLimit;
|
||||
}
|
||||
if (!empty($maxSize) && $maxSize > $maxSizeLimit) {
|
||||
throw new Forbidden("Max size should should not exceed " . $maxSizeLimit . ". Use offset and limit.");
|
||||
}
|
||||
|
||||
$params = [
|
||||
'where' => $where,
|
||||
'offset' => $offset,
|
||||
'maxSize' => $maxSize,
|
||||
'asc' => $asc,
|
||||
'sortBy' => $sortBy,
|
||||
'textFilter' => $textFilter
|
||||
];
|
||||
$params = [];
|
||||
|
||||
\Espo\Core\Utils\ControllerUtil::fetchListParamsFromRequest($params, $request, $data);
|
||||
|
||||
$maxSizeLimit = $this->getConfig()->get('recordListMaxSizeLimit', 200);
|
||||
if (empty($params['maxSize'])) {
|
||||
$params['maxSize'] = $maxSizeLimit;
|
||||
}
|
||||
if (!empty($params['maxSize']) && $params['maxSize'] > $maxSizeLimit) {
|
||||
throw new Forbidden("Max size should should not exceed " . $maxSizeLimit . ". Use offset and limit.");
|
||||
}
|
||||
|
||||
$service = $this->getService('Activities');
|
||||
|
||||
$result = $service->findActivitiyEntityType($scope, $id, $entityType, $isHistory, $params);
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
}
|
||||
},
|
||||
"defaults": {
|
||||
"sortBy": "dateStart",
|
||||
"asc": true,
|
||||
"orderBy": "dateStart",
|
||||
"order": "desc",
|
||||
"displayRecords": 5,
|
||||
"populateAssignedUser": true,
|
||||
"expandedLayout": {
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
}
|
||||
},
|
||||
"defaults": {
|
||||
"sortBy": "createdAt",
|
||||
"asc": false,
|
||||
"orderBy": "number",
|
||||
"order": "desc",
|
||||
"displayRecords": 5,
|
||||
"populateAssignedUser": true,
|
||||
"expandedLayout": {
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
}
|
||||
},
|
||||
"defaults": {
|
||||
"sortBy": "createdAt",
|
||||
"asc": false,
|
||||
"orderBy": "createdAt",
|
||||
"order": "desc",
|
||||
"displayRecords": 5,
|
||||
"populateAssignedUser": true,
|
||||
"expandedLayout": {
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
}
|
||||
},
|
||||
"defaults": {
|
||||
"sortBy": "dateStart",
|
||||
"asc": true,
|
||||
"orderBy": "dateStart",
|
||||
"order": "desc",
|
||||
"displayRecords": 5,
|
||||
"populateAssignedUser": true,
|
||||
"expandedLayout": {
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
}
|
||||
},
|
||||
"defaults": {
|
||||
"sortBy": "closeDate",
|
||||
"asc": true,
|
||||
"orderBy": "closeDate",
|
||||
"order": "asc",
|
||||
"displayRecords": 5,
|
||||
"populateAssignedUser": true,
|
||||
"expandedLayout": {
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
}
|
||||
},
|
||||
"defaults": {
|
||||
"sortBy": "dateEnd",
|
||||
"asc": true,
|
||||
"orderBy": "dateEnd",
|
||||
"order": "asc",
|
||||
"displayRecords": 5,
|
||||
"expandedLayout": {
|
||||
"rows": [
|
||||
|
||||
@@ -334,8 +334,8 @@
|
||||
}
|
||||
},
|
||||
"collection": {
|
||||
"sortBy": "createdAt",
|
||||
"asc": false,
|
||||
"orderBy": "createdAt",
|
||||
"order": "desc",
|
||||
"textFilterFields": ["name", "emailAddress"]
|
||||
},
|
||||
"indexes": {
|
||||
|
||||
@@ -214,8 +214,8 @@
|
||||
}
|
||||
},
|
||||
"collection": {
|
||||
"sortBy": "dateStart",
|
||||
"asc": false
|
||||
"orderBy": "dateStart",
|
||||
"order": "desc"
|
||||
},
|
||||
"indexes": {
|
||||
"dateStartStatus": {
|
||||
|
||||
@@ -262,8 +262,8 @@
|
||||
}
|
||||
},
|
||||
"collection": {
|
||||
"sortBy": "createdAt",
|
||||
"asc": false
|
||||
"orderBy": "createdAt",
|
||||
"order": "desc"
|
||||
},
|
||||
"indexes": {
|
||||
"createdAt": {
|
||||
|
||||
@@ -78,8 +78,8 @@
|
||||
}
|
||||
},
|
||||
"collection": {
|
||||
"sortBy": "actionDate",
|
||||
"asc": false
|
||||
"orderBy": "createdAt",
|
||||
"order": "desc"
|
||||
},
|
||||
"indexes": {
|
||||
"actionDate": {
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
}
|
||||
},
|
||||
"collection": {
|
||||
"sortBy": "name",
|
||||
"asc": true
|
||||
"orderBy": "name",
|
||||
"order": "asc"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,8 +164,8 @@
|
||||
}
|
||||
},
|
||||
"collection": {
|
||||
"sortBy": "number",
|
||||
"asc": false,
|
||||
"orderBy": "number",
|
||||
"order": "desc",
|
||||
"textFilterFields": ["name", "number"]
|
||||
},
|
||||
"indexes": {
|
||||
|
||||
@@ -421,8 +421,8 @@
|
||||
}
|
||||
},
|
||||
"collection": {
|
||||
"sortBy": "createdAt",
|
||||
"asc": false,
|
||||
"orderBy": "createdAt",
|
||||
"order": "desc",
|
||||
"textFilterFields": ["name", "emailAddress"]
|
||||
},
|
||||
"indexes": {
|
||||
|
||||
@@ -121,7 +121,7 @@
|
||||
}
|
||||
},
|
||||
"collection": {
|
||||
"sortBy": "createdAt",
|
||||
"asc": false
|
||||
"orderBy": "createdAt",
|
||||
"order": "desc"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,8 +68,8 @@
|
||||
}
|
||||
},
|
||||
"collection": {
|
||||
"sortBy": "parent",
|
||||
"asc": true
|
||||
"orderBy": "parent",
|
||||
"order": "asc"
|
||||
},
|
||||
"additionalTables": {
|
||||
"DocumentFolderPath": {
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
}
|
||||
},
|
||||
"collection": {
|
||||
"sortBy": "createdAt",
|
||||
"asc": false
|
||||
"orderBy": "createdAt",
|
||||
"order": "desc"
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -111,7 +111,7 @@
|
||||
}
|
||||
},
|
||||
"collection": {
|
||||
"sortBy": "order",
|
||||
"asc": true
|
||||
"orderBy": "order",
|
||||
"order": "asc"
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -74,9 +74,9 @@
|
||||
}
|
||||
},
|
||||
"collection": {
|
||||
"sortBy": "parent",
|
||||
"sortByByColumn": "parentId",
|
||||
"asc": true
|
||||
"orderBy": "parent",
|
||||
"orderByColumn": "parentId",
|
||||
"order": "asc"
|
||||
},
|
||||
"additionalTables": {
|
||||
"KnowledgeBaseCategoryPath": {
|
||||
|
||||
@@ -318,8 +318,8 @@
|
||||
}
|
||||
},
|
||||
"collection": {
|
||||
"sortBy": "createdAt",
|
||||
"asc": false,
|
||||
"orderBy": "createdAt",
|
||||
"order": "desc",
|
||||
"textFilterFields": ["name", "accountName", "emailAddress"]
|
||||
},
|
||||
"indexes": {
|
||||
|
||||
@@ -121,7 +121,7 @@
|
||||
}
|
||||
},
|
||||
"collection": {
|
||||
"sortBy": "createdAt",
|
||||
"asc": false
|
||||
"orderBy": "createdAt",
|
||||
"order": "desc"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,8 +204,8 @@
|
||||
}
|
||||
},
|
||||
"collection": {
|
||||
"sortBy": "dateStart",
|
||||
"asc": false
|
||||
"orderBy": "dateStart",
|
||||
"order": "desc"
|
||||
},
|
||||
"indexes": {
|
||||
"dateStartStatus": {
|
||||
|
||||
@@ -248,8 +248,8 @@
|
||||
}
|
||||
},
|
||||
"collection": {
|
||||
"sortBy": "createdAt",
|
||||
"asc": false
|
||||
"orderBy": "createdAt",
|
||||
"order": "desc"
|
||||
},
|
||||
"indexes": {
|
||||
"stage": {
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
}
|
||||
},
|
||||
"collection": {
|
||||
"sortBy": "remindAt",
|
||||
"asc": false
|
||||
"orderBy": "remindAt",
|
||||
"order": "desc"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,8 +111,8 @@
|
||||
}
|
||||
},
|
||||
"collection": {
|
||||
"sortBy": "createdAt",
|
||||
"asc": false
|
||||
"orderBy": "createdAt",
|
||||
"order": "desc"
|
||||
},
|
||||
"indexes": {
|
||||
"firstName": {
|
||||
|
||||
@@ -175,8 +175,8 @@
|
||||
}
|
||||
},
|
||||
"collection": {
|
||||
"sortBy": "createdAt",
|
||||
"asc": false
|
||||
"orderBy": "createdAt",
|
||||
"order": "desc"
|
||||
},
|
||||
"indexes": {
|
||||
"createdAt": {
|
||||
|
||||
@@ -136,8 +136,8 @@
|
||||
}
|
||||
},
|
||||
"collection": {
|
||||
"sortBy": "createdAt",
|
||||
"asc": false
|
||||
"orderBy": "createdAt",
|
||||
"order": "desc"
|
||||
},
|
||||
"indexes": {
|
||||
"dateStartStatus": {
|
||||
|
||||
@@ -726,8 +726,12 @@ class Activities extends \Espo\Core\Services\Base
|
||||
$offset = $selectParams['offset'];
|
||||
$limit = $selectParams['limit'];
|
||||
|
||||
$order = $selectParams['order'];
|
||||
$orderBy = $selectParams['orderBy'];
|
||||
$orderBy = null;
|
||||
$order = null;
|
||||
if (!empty($selectParams['orderBy'])) {
|
||||
$order = $selectParams['order'];
|
||||
$orderBy = $selectParams['orderBy'];
|
||||
}
|
||||
|
||||
unset($selectParams['offset']);
|
||||
unset($selectParams['limit']);
|
||||
@@ -737,6 +741,7 @@ class Activities extends \Espo\Core\Services\Base
|
||||
if ($entityType === 'Email') {
|
||||
if ($orderBy === 'dateStart') {
|
||||
$orderBy = 'dateSent';
|
||||
$order = 'desc';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -748,7 +753,9 @@ class Activities extends \Espo\Core\Services\Base
|
||||
|
||||
$sqlBase = $sql;
|
||||
|
||||
$sql = $query->order($sql, $seed, $orderBy, $order, true);
|
||||
if ($orderBy) {
|
||||
$sql = $query->order($sql, $seed, $orderBy, $order, true);
|
||||
}
|
||||
|
||||
$sql = $query->limit($sql, $offset, $limit);
|
||||
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
}
|
||||
},
|
||||
"defaults": {
|
||||
"sortBy": "dateSent",
|
||||
"asc": false,
|
||||
"orderBy": "dateSent",
|
||||
"order": "desc",
|
||||
"displayRecords": 5,
|
||||
"expandedLayout": {
|
||||
"rows": [
|
||||
|
||||
@@ -63,8 +63,8 @@
|
||||
}
|
||||
},
|
||||
"collection": {
|
||||
"sortBy": "lastAccess",
|
||||
"asc": false,
|
||||
"orderBy": "lastAccess",
|
||||
"order": "desc",
|
||||
"textFilterFields": ["ipAddress", "userName"]
|
||||
},
|
||||
"indexes": {
|
||||
|
||||
@@ -440,8 +440,8 @@
|
||||
}
|
||||
},
|
||||
"collection": {
|
||||
"sortBy": "dateSent",
|
||||
"asc": false,
|
||||
"orderBy": "dateSent",
|
||||
"order": "desc",
|
||||
"textFilterFields": ["name", "bodyPlain", "body"],
|
||||
"fullTextSearch": true
|
||||
},
|
||||
|
||||
@@ -152,7 +152,7 @@
|
||||
}
|
||||
},
|
||||
"collection": {
|
||||
"sortBy": "name",
|
||||
"asc": true
|
||||
"orderBy": "name",
|
||||
"order": "asc"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
"links": {
|
||||
},
|
||||
"collection": {
|
||||
"sortBy": "name",
|
||||
"asc": true
|
||||
"orderBy": "name",
|
||||
"order": "asc"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@
|
||||
}
|
||||
},
|
||||
"collection": {
|
||||
"sortBy": "createdAt",
|
||||
"asc": false
|
||||
"orderBy": "createdAt",
|
||||
"order": "desc"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
}
|
||||
},
|
||||
"collection": {
|
||||
"sortBy": "order",
|
||||
"asc": true
|
||||
"orderBy": "order",
|
||||
"order": "asc"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,8 +84,8 @@
|
||||
}
|
||||
},
|
||||
"collection": {
|
||||
"sortBy": "createdAt",
|
||||
"asc": false,
|
||||
"orderBy": "createdAt",
|
||||
"order": "desc",
|
||||
"textFilterFields": ["name", "bodyPlain", "body", "subject"]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,8 +73,8 @@
|
||||
}
|
||||
},
|
||||
"collection": {
|
||||
"sortBy": "parent",
|
||||
"asc": true
|
||||
"orderBy": "parent",
|
||||
"order": "asc"
|
||||
},
|
||||
"additionalTables": {
|
||||
"EmailTemplateCategoryPath": {
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
}
|
||||
},
|
||||
"collection": {
|
||||
"sortBy": "createdAt",
|
||||
"asc": false
|
||||
"orderBy": "createdAt",
|
||||
"order": "desc"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
}
|
||||
},
|
||||
"collection": {
|
||||
"sortBy": "createdAt",
|
||||
"asc": false
|
||||
"orderBy": "createdAt",
|
||||
"order": "desc"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -205,7 +205,7 @@
|
||||
}
|
||||
},
|
||||
"collection": {
|
||||
"sortBy": "name",
|
||||
"asc": true
|
||||
"orderBy": "name",
|
||||
"order": "asc"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,8 +72,8 @@
|
||||
}
|
||||
},
|
||||
"collection": {
|
||||
"sortBy": "createdAt",
|
||||
"asc": false,
|
||||
"orderBy": "createdAt",
|
||||
"order": "desc",
|
||||
"textFilterFields": ["name", "methodName", "serviceName", "scheduledJobName"]
|
||||
},
|
||||
"indexes": {
|
||||
|
||||
@@ -140,7 +140,7 @@
|
||||
}
|
||||
},
|
||||
"collection": {
|
||||
"sortBy": "name",
|
||||
"asc": true
|
||||
"orderBy": "name",
|
||||
"order": "asc"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
}
|
||||
},
|
||||
"collection": {
|
||||
"sortBy": "number",
|
||||
"asc": false
|
||||
"orderBy": "number",
|
||||
"order": "desc"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,8 +121,8 @@
|
||||
}
|
||||
},
|
||||
"collection": {
|
||||
"sortBy": "number",
|
||||
"asc": false,
|
||||
"orderBy": "number",
|
||||
"order": "desc",
|
||||
"textFilterFields": ["post"]
|
||||
},
|
||||
"statusStyles": {
|
||||
|
||||
@@ -52,8 +52,8 @@
|
||||
}
|
||||
},
|
||||
"collection": {
|
||||
"sortBy": "number",
|
||||
"asc": false
|
||||
"orderBy": "number",
|
||||
"order": "desc"
|
||||
},
|
||||
"indexes": {
|
||||
"createdAt": {
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
"links": {
|
||||
},
|
||||
"collection": {
|
||||
"sortBy": "name",
|
||||
"asc": true
|
||||
"orderBy": "name",
|
||||
"order": "asc"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@
|
||||
}
|
||||
},
|
||||
"collection": {
|
||||
"sortBy": "name",
|
||||
"asc": true
|
||||
"orderBy": "name",
|
||||
"order": "asc"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
}
|
||||
},
|
||||
"collection": {
|
||||
"sortBy": "name",
|
||||
"asc": true
|
||||
"orderBy": "name",
|
||||
"order": "asc"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@
|
||||
}
|
||||
},
|
||||
"collection": {
|
||||
"sortBy": "name",
|
||||
"asc": true
|
||||
"orderBy": "name",
|
||||
"order": "asc"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,8 +64,8 @@
|
||||
}
|
||||
},
|
||||
"collection": {
|
||||
"sortBy": "name",
|
||||
"asc": true
|
||||
"orderBy": "name",
|
||||
"order": "asc"
|
||||
},
|
||||
"jobSchedulingMap": {
|
||||
"CheckInboundEmails": "*/2 * * * *",
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
}
|
||||
},
|
||||
"collection": {
|
||||
"sortBy": "executionTime",
|
||||
"asc": false
|
||||
"orderBy": "executionTime",
|
||||
"order": "desc"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
}
|
||||
},
|
||||
"collection": {
|
||||
"sortBy": "name",
|
||||
"asc": true
|
||||
"orderBy": "name",
|
||||
"order": "asc"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@
|
||||
}
|
||||
},
|
||||
"collection": {
|
||||
"sortBy": "name",
|
||||
"asc": true
|
||||
"orderBy": "name",
|
||||
"order": "asc"
|
||||
}
|
||||
}
|
||||
@@ -33,7 +33,7 @@
|
||||
}
|
||||
},
|
||||
"collection": {
|
||||
"sortBy": "createdAt",
|
||||
"asc": false
|
||||
"orderBy": "createdAt",
|
||||
"order": "desc"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -322,8 +322,8 @@
|
||||
}
|
||||
},
|
||||
"collection": {
|
||||
"sortBy": "userName",
|
||||
"asc": true,
|
||||
"orderBy": "userName",
|
||||
"order": "asc",
|
||||
"textFilterFields": ["name", "userName"]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1664,10 +1664,11 @@ class Record extends \Espo\Core\Services\Base
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
$orderBy = $this->getMetadata()->get(['entityDefs', $this->getEntityType(), 'collection', 'sortBy']);
|
||||
$desc = !$this->getMetadata()->get(['entityDefs', $this->getEntityType(), 'collection', 'asc']);
|
||||
$orderBy = $this->getMetadata()->get(['entityDefs', $this->getEntityType(), 'collection', 'orderBy']);
|
||||
$order = $this->getMetadata()->get(['entityDefs', $this->getEntityType(), 'collection', 'order']);
|
||||
|
||||
if ($orderBy) {
|
||||
$selectManager->applyOrder($orderBy, $desc, $selectParams);
|
||||
$selectManager->applyOrder($orderBy, $order, $selectParams);
|
||||
}
|
||||
|
||||
$this->getEntityManager()->getRepository($this->getEntityType())->handleSelectParams($selectParams);
|
||||
@@ -2228,8 +2229,8 @@ class Record extends \Espo\Core\Services\Base
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($params['sortBy'])) {
|
||||
$sortByField = $params['sortBy'];
|
||||
if (!empty($params['orderBy'])) {
|
||||
$sortByField = $params['orderBy'];
|
||||
$sortByFieldType = $this->getMetadata()->get(['entityDefs', $this->getEntityType(), 'fields', $sortByField, 'type']);
|
||||
|
||||
if ($sortByFieldType === 'currency') {
|
||||
|
||||
@@ -33,7 +33,7 @@ Espo.define('crm:views/knowledge-base-article/record/row-actions/default', 'view
|
||||
getActionList: function () {
|
||||
var actionList = Dep.prototype.getActionList.call(this);
|
||||
|
||||
if (this.options.acl.edit && this.model.collection && this.model.collection.sortBy == 'order' && this.model.collection.asc) {
|
||||
if (this.options.acl.edit && this.model.collection && this.model.collection.orderBy == 'order' && this.model.collection.order === 'asc') {
|
||||
actionList.push({
|
||||
action: 'moveToTop',
|
||||
label: 'Move to Top',
|
||||
|
||||
@@ -32,11 +32,11 @@ Espo.define('crm:views/record/panels/activities', ['views/record/panels/relation
|
||||
|
||||
name: 'activities',
|
||||
|
||||
sortBy: 'dateStart',
|
||||
orderBy: 'dateStart',
|
||||
|
||||
serviceName: 'Activities',
|
||||
|
||||
asc: false,
|
||||
order: 'desc',
|
||||
|
||||
rowActionsView: 'crm:views/record/row-actions/activities',
|
||||
|
||||
@@ -141,8 +141,8 @@ Espo.define('crm:views/record/panels/activities', ['views/record/panels/relation
|
||||
this.collection = new MultiCollection();
|
||||
this.collection.seeds = this.seeds;
|
||||
this.collection.url = this.url;
|
||||
this.collection.sortBy = this.sortBy;
|
||||
this.collection.asc = this.asc;
|
||||
this.collection.orderBy = this.orderBy;
|
||||
this.collection.order = this.order;
|
||||
this.collection.maxSize = this.getConfig().get('recordsPerPageSmall') || 5;
|
||||
|
||||
this.setFilter(this.filter);
|
||||
|
||||
@@ -32,9 +32,9 @@ Espo.define('crm:views/record/panels/history', 'crm:views/record/panels/activiti
|
||||
|
||||
name: 'history',
|
||||
|
||||
sortBy: 'dateStart',
|
||||
orderBy: 'dateStart',
|
||||
|
||||
asc: false,
|
||||
orderDirection: 'desc',
|
||||
|
||||
rowActionsView: 'crm:views/record/row-actions/history',
|
||||
|
||||
|
||||
@@ -38,9 +38,9 @@ Espo.define('crm:views/record/panels/tasks', 'views/record/panels/relationship',
|
||||
|
||||
defaultTab: 'actual',
|
||||
|
||||
sortBy: 'createdAt',
|
||||
orderBy: 'createdAt',
|
||||
|
||||
asc: false,
|
||||
orderDirection: 'desc',
|
||||
|
||||
rowActionsView: 'crm:views/record/row-actions/tasks',
|
||||
|
||||
@@ -110,8 +110,8 @@ Espo.define('crm:views/record/panels/tasks', 'views/record/panels/relationship',
|
||||
this.collection = collection;
|
||||
collection.seeds = this.seeds;
|
||||
collection.url = this.url;
|
||||
collection.sortBy = this.defaultSortBy;
|
||||
collection.asc = this.defaultAsc;
|
||||
collection.orderBy = this.defaultOrderBy;
|
||||
collection.order = this.defaultOrder;
|
||||
collection.maxSize = this.getConfig().get('recordsPerPageSmall') || 5;
|
||||
|
||||
this.setFilter(this.filter);
|
||||
|
||||
@@ -43,17 +43,16 @@
|
||||
context = context || this;
|
||||
|
||||
this.modelFactory.getSeed(name, function (seed) {
|
||||
var orderBy = this.modelFactory.metadata.get(['entityDefs', name, 'collection', 'orderBy']);
|
||||
var order = this.modelFactory.metadata.get(['entityDefs', name, 'collection', 'order']);
|
||||
|
||||
var asc = this.modelFactory.metadata.get('entityDefs.' + name + '.collection.asc');
|
||||
var sortBy = this.modelFactory.metadata.get('entityDefs.' + name + '.collection.sortBy');
|
||||
|
||||
var className = this.modelFactory.metadata.get('clientDefs.' + name + '.collection') || 'collection';
|
||||
var className = this.modelFactory.metadata.get(['clientDefs', name, 'collection']) || 'collection';
|
||||
|
||||
Espo.loader.require(className, function (collectionClass) {
|
||||
var collection = new collectionClass(null, {
|
||||
name: name,
|
||||
asc: asc,
|
||||
sortBy: sortBy
|
||||
orderBy: orderBy,
|
||||
order: order
|
||||
});
|
||||
collection.model = seed;
|
||||
collection._user = this.modelFactory.user;
|
||||
@@ -67,4 +66,3 @@
|
||||
return CollectionFactory;
|
||||
|
||||
});
|
||||
|
||||
|
||||
+36
-13
@@ -38,9 +38,11 @@ Espo.define('collection', [], function () {
|
||||
|
||||
maxSize: 20,
|
||||
|
||||
sortBy: 'id',
|
||||
asc: null, // TODO remove in 5.7
|
||||
|
||||
asc: false,
|
||||
order: null,
|
||||
|
||||
orderBy: null,
|
||||
|
||||
where: null,
|
||||
|
||||
@@ -56,10 +58,15 @@ Espo.define('collection', [], function () {
|
||||
this.urlRoot = this.urlRoot || this.name;
|
||||
this.url = this.url || this.urlRoot;
|
||||
|
||||
this.sortBy = options.sortBy || this.sortBy;
|
||||
this.defaultSortBy = this.sortBy;
|
||||
this.asc = ('asc' in options) ? options.asc : this.asc;
|
||||
this.defaultAsc = this.asc;
|
||||
this.orderBy = this.sortBy = options.orderBy || options.sortBy || this.orderBy || this.sortBy;
|
||||
this.order = options.order || this.order;
|
||||
|
||||
this.asc = ('asc' in options) ? options.asc : this.asc; // TODO remove in 5.7
|
||||
|
||||
this.defaultOrder = this.order;
|
||||
this.defaultOrderBy = this.orderBy;
|
||||
|
||||
|
||||
this.data = {};
|
||||
|
||||
Backbone.Collection.prototype.initialize.call(this);
|
||||
@@ -75,9 +82,16 @@ Espo.define('collection', [], function () {
|
||||
Backbone.Collection.prototype.reset.call(this, models, options);
|
||||
},
|
||||
|
||||
sort: function (field, asc) {
|
||||
this.sortBy = field;
|
||||
this.asc = asc;
|
||||
sort: function (orderBy, order) {
|
||||
this.orderBy = orderBy;
|
||||
|
||||
if (order === true) {
|
||||
order = 'desc';
|
||||
} else if (order === false) {
|
||||
order = 'asc';
|
||||
}
|
||||
this.order = order || 'asc';
|
||||
|
||||
this.fetch();
|
||||
},
|
||||
|
||||
@@ -127,9 +141,18 @@ Espo.define('collection', [], function () {
|
||||
var options = options || {};
|
||||
options.data = _.extend(options.data || {}, this.data);
|
||||
|
||||
if (this.asc === true || this.asc === false) { // TODO remove in 5.7
|
||||
this.order = this.asc ? 'asc' : 'desc';
|
||||
}
|
||||
|
||||
this.offset = options.offset || this.offset;
|
||||
this.sortBy = options.sortBy || this.sortBy;
|
||||
this.asc = options.asc || this.asc;
|
||||
this.orderBy = options.orderBy || options.sortBy || this.orderBy;
|
||||
this.order = options.order || this.order;
|
||||
|
||||
if (options.asc) { // TODO remove in 5.7
|
||||
this.order = 'asc';
|
||||
}
|
||||
|
||||
this.where = options.where || this.where;
|
||||
|
||||
if (!('maxSize' in options)) {
|
||||
@@ -139,8 +162,8 @@ Espo.define('collection', [], function () {
|
||||
}
|
||||
|
||||
options.data.offset = options.more ? this.length + this.lengthCorrection : this.offset;
|
||||
options.data.sortBy = this.sortBy;
|
||||
options.data.asc = this.asc;
|
||||
options.data.orderBy = this.orderBy;
|
||||
options.data.order = this.order;
|
||||
options.data.where = this.getWhere();
|
||||
|
||||
this.lastXhr = Backbone.Collection.prototype.fetch.call(this, options);
|
||||
|
||||
@@ -26,7 +26,8 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
Espo.define('MultiCollection', 'Collection', function (Collection) {
|
||||
Espo.define('multi-collection', 'collection', function (Collection) {
|
||||
|
||||
var MultiCollection = Collection.extend({
|
||||
|
||||
/**
|
||||
@@ -37,9 +38,6 @@ Espo.define('MultiCollection', 'Collection', function (Collection) {
|
||||
initialize: function (models, options) {
|
||||
options = options || {};
|
||||
|
||||
this.sortBy = options.sortBy || this.sortBy;
|
||||
this.asc = ('asc' in options) ? options.asc : this.asc;
|
||||
|
||||
this.data = {};
|
||||
|
||||
Backbone.Collection.prototype.initialize.call(this);
|
||||
@@ -57,5 +55,4 @@ Espo.define('MultiCollection', 'Collection', function (Collection) {
|
||||
});
|
||||
|
||||
return MultiCollection;
|
||||
|
||||
});
|
||||
|
||||
@@ -61,8 +61,8 @@ Espo.define('views/admin/entity-manager/modals/edit-entity', ['views/modal', 'mo
|
||||
this.model.set('stream', this.getMetadata().get('scopes.' + scope + '.stream') || false);
|
||||
this.model.set('disabled', this.getMetadata().get('scopes.' + scope + '.disabled') || false);
|
||||
|
||||
this.model.set('sortBy', this.getMetadata().get('entityDefs.' + scope + '.collection.sortBy'));
|
||||
this.model.set('sortDirection', this.getMetadata().get('entityDefs.' + scope + '.collection.asc') ? 'asc' : 'desc');
|
||||
this.model.set('sortBy', this.getMetadata().get('entityDefs.' + scope + '.collection.orderBy'));
|
||||
this.model.set('sortDirection', this.getMetadata().get('entityDefs.' + scope + '.collection.order'));
|
||||
|
||||
this.model.set('textFilterFields', this.getMetadata().get(['entityDefs', scope, 'collection', 'textFilterFields']) || ['name']);
|
||||
this.model.set('fullTextSearch', this.getMetadata().get(['entityDefs', scope, 'collection', 'fullTextSearch']) || false);
|
||||
|
||||
@@ -144,11 +144,13 @@ Espo.define('views/dashlets/abstract/base', 'view', function (Dep) {
|
||||
|
||||
setupButtonList: function () {},
|
||||
|
||||
hasOption: function (key) {
|
||||
return key in this.optionsData;
|
||||
},
|
||||
|
||||
getOption: function (key) {
|
||||
return this.optionsData[key];
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -85,13 +85,27 @@ Espo.define('views/dashlets/abstract/record-list', ['views/dashlets/abstract/bas
|
||||
}
|
||||
|
||||
this.collection = collection;
|
||||
collection.sortBy = this.getOption('sortBy') || this.collection.sortBy;
|
||||
collection.asc = this.getOption('asc') || this.collection.asc;
|
||||
|
||||
collection.orderBy = this.getOption('orderBy') || this.getOption('sortBy') || this.collection.orderBy;
|
||||
|
||||
if (this.getOption('orderBy')) {
|
||||
collection.order = 'asc';
|
||||
}
|
||||
|
||||
if (this.hasOption('asc')) {
|
||||
collection.order = this.getOption('asc') ? 'asc' : false;
|
||||
}
|
||||
|
||||
if (this.getOption('sortDirection') === 'asc') {
|
||||
collection.asc = true;
|
||||
collection.order = 'asc';
|
||||
} else if (this.getOption('sortDirection') === 'desc') {
|
||||
collection.asc = false;
|
||||
collection.order = 'desc';
|
||||
}
|
||||
|
||||
if (this.getOption('order') === 'asc') {
|
||||
collection.order = 'order';
|
||||
} else if (this.getOption('order') === 'desc') {
|
||||
collection.order = 'desc';
|
||||
}
|
||||
|
||||
collection.maxSize = this.getOption('displayRecords');
|
||||
|
||||
@@ -46,12 +46,12 @@ Espo.define('views/dashlets/fields/records/entity-type', 'views/fields/enum', fu
|
||||
var entityType = this.model.get('entityType');
|
||||
if (entityType) {
|
||||
o.title = this.translate(entityType, 'scopeNamesPlural');
|
||||
o.sortBy = this.getMetadata().get(['entityDefs', entityType, 'collection', 'sortBy']);
|
||||
var asc = this.getMetadata().get(['entityDefs', entityType, 'collection', 'asc']);
|
||||
if (asc) {
|
||||
o.sortDirection = 'asc';
|
||||
o.sortBy = this.getMetadata().get(['entityDefs', entityType, 'collection', 'orderBy']);
|
||||
var order = this.getMetadata().get(['entityDefs', entityType, 'collection', 'order']);
|
||||
if (order) {
|
||||
o.sortDirection = order;
|
||||
} else {
|
||||
o.sortDirection = 'desc';
|
||||
o.sortDirection = 'asc';
|
||||
}
|
||||
o.expandedLayout = {
|
||||
rows: [[{name: "name", link: true, scope: entityType}]]
|
||||
|
||||
@@ -169,7 +169,7 @@ Espo.define('views/fields/link-multiple', 'views/fields/base', function (Dep) {
|
||||
},
|
||||
|
||||
getAutocompleteUrl: function () {
|
||||
var url = this.foreignScope + '?sortBy=name&maxCount=' + this.AUTOCOMPLETE_RESULT_MAX_COUNT;
|
||||
var url = this.foreignScope + '?orderBy=name&maxCount=' + this.AUTOCOMPLETE_RESULT_MAX_COUNT;
|
||||
var boolList = this.getSelectBoolFilterList();
|
||||
var where = [];
|
||||
if (boolList) {
|
||||
|
||||
@@ -192,7 +192,7 @@ Espo.define('views/fields/link-parent', 'views/fields/base', function (Dep) {
|
||||
},
|
||||
|
||||
getAutocompleteUrl: function () {
|
||||
var url = this.foreignScope + '?sortBy=name&maxCount=' + this.AUTOCOMPLETE_RESULT_MAX_COUNT;
|
||||
var url = this.foreignScope + '?orderBy=name&maxCount=' + this.AUTOCOMPLETE_RESULT_MAX_COUNT;
|
||||
var boolList = this.getSelectBoolFilterList();
|
||||
var where = [];
|
||||
if (boolList) {
|
||||
|
||||
@@ -213,7 +213,7 @@ Espo.define('views/fields/link', 'views/fields/base', function (Dep) {
|
||||
},
|
||||
|
||||
getAutocompleteUrl: function () {
|
||||
var url = this.foreignScope + '?sortBy=name&maxCount=' + this.AUTOCOMPLETE_RESULT_MAX_COUNT;
|
||||
var url = this.foreignScope + '?orderBy=name&maxCount=' + this.AUTOCOMPLETE_RESULT_MAX_COUNT;
|
||||
var boolList = this.getSelectBoolFilterList();
|
||||
var where = [];
|
||||
if (boolList) {
|
||||
|
||||
@@ -92,7 +92,7 @@ Espo.define('views/fields/user', 'views/fields/link', function (Dep) {
|
||||
var $elemeneTeams = this.$el.find('input.element-teams');
|
||||
$elemeneTeams.autocomplete({
|
||||
serviceUrl: function (q) {
|
||||
return 'Team?sortBy=name&maxCount=' + this.AUTOCOMPLETE_RESULT_MAX_COUNT;
|
||||
return 'Team?orderBy=name&maxCount=' + this.AUTOCOMPLETE_RESULT_MAX_COUNT;
|
||||
}.bind(this),
|
||||
minChars: 1,
|
||||
paramName: 'q',
|
||||
|
||||
+12
-11
@@ -96,8 +96,8 @@ Espo.define('views/list', ['views/main', 'search-manager'], function (Dep, Searc
|
||||
this.setupSearchManager();
|
||||
}
|
||||
|
||||
this.defaultSortBy = this.collection.sortBy;
|
||||
this.defaultAsc = this.collection.asc;
|
||||
this.defaultOrderBy = this.collection.orderBy;
|
||||
this.defaultOrder = this.collection.order;
|
||||
|
||||
this.setupSorting();
|
||||
|
||||
@@ -233,13 +233,13 @@ Espo.define('views/list', ['views/main', 'search-manager'], function (Dep, Searc
|
||||
this.collection.url = this.scope + '/action/listKanban';
|
||||
this.collection.maxSize = this.getConfig().get('recordsPerPageSmall');
|
||||
|
||||
this.collection.sortBy = this.collection.defaultSortBy;
|
||||
this.collection.asc = this.collection.defaultAsc;
|
||||
this.collection.orderBy = this.collection.defaultOrderBy;
|
||||
this.collection.order = this.collection.defaultOrder;
|
||||
},
|
||||
|
||||
resetSorting: function () {
|
||||
this.collection.sortBy = this.defaultSortBy;
|
||||
this.collection.asc = this.defaultAsc;
|
||||
this.collection.orderBy = this.defaultOrderBy;
|
||||
this.collection.order = this.defaultOrder;
|
||||
this.getStorage().clear('listSorting', this.collection.name);
|
||||
},
|
||||
|
||||
@@ -265,12 +265,13 @@ Espo.define('views/list', ['views/main', 'search-manager'], function (Dep, Searc
|
||||
},
|
||||
|
||||
applyStoredSorting: function () {
|
||||
var sortingParams = this.getStorage().get('listSorting', this.collection.name) || {};
|
||||
if ('sortBy' in sortingParams) {
|
||||
this.collection.sortBy = sortingParams.sortBy;
|
||||
var sortingParams = this.getStorage().get('listSorting', this.collection.entityType) || {};
|
||||
|
||||
if ('orderBy' in sortingParams) {
|
||||
this.collection.orderBy = sortingParams.orderBy;
|
||||
}
|
||||
if ('asc' in sortingParams) {
|
||||
this.collection.asc = sortingParams.asc;
|
||||
if ('order' in sortingParams) {
|
||||
this.collection.order = sortingParams.order;
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -72,8 +72,8 @@ Espo.define('views/modals/related-list', ['views/modal', 'search-manager'], func
|
||||
|
||||
this.scope = this.options.scope || this.scope;
|
||||
|
||||
this.defaultSortBy = this.options.defaultSortBy;
|
||||
this.defaultAsc = this.options.defaultAsc;
|
||||
this.defaultOrderBy = this.options.defaultOrderBy;
|
||||
this.defaultOrder = this.options.defaultOrder;
|
||||
|
||||
this.panelName = this.options.panelName;
|
||||
this.link = this.options.link;
|
||||
@@ -147,8 +147,8 @@ Espo.define('views/modals/related-list', ['views/modal', 'search-manager'], func
|
||||
|
||||
this.collection = collection;
|
||||
|
||||
collection.sortBy = this.defaultSortBy;
|
||||
collection.asc = this.defaultAsc;
|
||||
collection.orderBy = this.defaultOrderBy;
|
||||
collection.order = this.defaultOrder;
|
||||
|
||||
this.listenTo(collection, 'change', function (model) {
|
||||
var panelModel = this.panelCollection.get(model.id);
|
||||
@@ -210,8 +210,8 @@ Espo.define('views/modals/related-list', ['views/modal', 'search-manager'], func
|
||||
filterList: filterList
|
||||
}, function (view) {
|
||||
this.listenTo(view, 'reset', function () {
|
||||
this.collection.sortBy = this.defaultSortBy;
|
||||
this.collection.asc = this.defaultAsc;
|
||||
this.collection.orderBy = this.defaultOrderBy;
|
||||
this.collection.order = this.defaultOrder;
|
||||
}, this);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -143,8 +143,8 @@ Espo.define('views/modals/select-records', ['views/modal', 'search-manager'], fu
|
||||
collection.maxSize = this.getConfig().get('recordsPerPageSmall') || 5;
|
||||
this.collection = collection;
|
||||
|
||||
this.defaultSortBy = collection.sortBy;
|
||||
this.defaultAsc = collection.asc;
|
||||
this.defaultOrderBy = collection.orderBy;
|
||||
this.defaultOrder = collection.defaultOrder;
|
||||
|
||||
this.loadSearch();
|
||||
this.wait(true);
|
||||
@@ -183,8 +183,8 @@ Espo.define('views/modals/select-records', ['views/modal', 'search-manager'], fu
|
||||
disableSavePreset: true,
|
||||
}, function (view) {
|
||||
this.listenTo(view, 'reset', function () {
|
||||
this.collection.sortBy = this.defaultSortBy;
|
||||
this.collection.asc = this.defaultAsc;
|
||||
this.collection.orderBy = this.defaultOrderBy;
|
||||
this.collection.order = this.defaultOrder;
|
||||
}, this);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -193,8 +193,8 @@ Espo.define('views/record/kanban', ['views/record/list'], function (Dep) {
|
||||
this.seedCollection.url = this.scope;
|
||||
this.seedCollection.maxSize = this.collection.maxSize;
|
||||
this.seedCollection.name = this.collection.name;
|
||||
this.seedCollection.sortBy = this.collection.defaultSortBy;
|
||||
this.seedCollection.asc = this.collection.defaultAsc;
|
||||
this.seedCollection.orderBy = this.collection.defaultOrderBy;
|
||||
this.seedCollection.order = this.collection.defaultOrder;
|
||||
|
||||
this.listenTo(this.collection, 'sync', function (c, r, options) {
|
||||
if (this.hasView('modal') && this.getView('modal').isRendered()) return;
|
||||
@@ -429,8 +429,8 @@ Espo.define('views/record/kanban', ['views/record/list'], function (Dep) {
|
||||
collection.where = this.collection.where;
|
||||
collection.name = this.seedCollection.name;
|
||||
collection.maxSize = this.seedCollection.maxSize;
|
||||
collection.sortBy = this.seedCollection.sortBy;
|
||||
collection.asc = this.seedCollection.asc;
|
||||
collection.orderBy = this.seedCollection.orderBy;
|
||||
collection.order = this.seedCollection.order;
|
||||
collection.whereAdditional = [
|
||||
{
|
||||
field: this.statusField,
|
||||
|
||||
@@ -160,21 +160,24 @@ Espo.define('views/record/list', 'view', function (Dep) {
|
||||
}
|
||||
},
|
||||
|
||||
toggleSort: function (field) {
|
||||
toggleSort: function (orderBy) {
|
||||
var asc = true;
|
||||
if (field === this.collection.sortBy && this.collection.asc) {
|
||||
if (orderBy === this.collection.orderBy && this.collection.order === 'asc') {
|
||||
asc = false;
|
||||
}
|
||||
var order = asc ? 'asc' : 'desc';
|
||||
|
||||
this.notify('Please wait...');
|
||||
this.collection.once('sync', function () {
|
||||
this.notify(false);
|
||||
this.trigger('sort', {sortBy: field, asc: asc});
|
||||
this.trigger('sort', {orderBy: orderBy, order: order});
|
||||
}, this);
|
||||
|
||||
var maxSizeLimit = this.getConfig().get('recordListMaxSizeLimit') || 200;
|
||||
while (this.collection.length > maxSizeLimit) {
|
||||
this.collection.pop();
|
||||
}
|
||||
this.collection.sort(field, asc);
|
||||
this.collection.sort(orderBy, order);
|
||||
this.deactivate();
|
||||
},
|
||||
|
||||
@@ -993,9 +996,9 @@ Espo.define('views/record/list', 'view', function (Dep) {
|
||||
item.hasCustomLabel = true;
|
||||
}
|
||||
if (item.sortable) {
|
||||
item.sorted = this.collection.sortBy === this.listLayout[i].name;
|
||||
item.sorted = this.collection.orderBy === this.listLayout[i].name;
|
||||
if (item.sorted) {
|
||||
item.asc = this.collection.asc;
|
||||
item.asc = this.collection.order === 'asc' ;
|
||||
}
|
||||
}
|
||||
defs.push(item);
|
||||
|
||||
@@ -170,11 +170,11 @@ Espo.define('views/record/panels/relationship', ['views/record/panels/bottom', '
|
||||
}
|
||||
|
||||
collection.url = collection.urlRoot = url;
|
||||
if (this.defaultSortBy) {
|
||||
collection.sortBy = this.defaultSortBy;
|
||||
if (this.defaultOrderBy) {
|
||||
collection.orderBy = this.defaultOrderBy;
|
||||
}
|
||||
if (this.defaultAsc) {
|
||||
collection.asc = this.defaultAsc;
|
||||
if (this.defaultOrder) {
|
||||
collection.order = this.defaultOrder;
|
||||
}
|
||||
this.collection = collection;
|
||||
|
||||
@@ -248,21 +248,19 @@ Espo.define('views/record/panels/relationship', ['views/record/panels/bottom', '
|
||||
},
|
||||
|
||||
setupSorting: function () {
|
||||
var sortBy = this.defs.sortBy || this.sortBy;
|
||||
var asc = this.defs.asc || this.asc;
|
||||
var orderBy = this.defs.orderBy || this.defs.sortBy || this.orderBy;
|
||||
var order = this.defs.orderDirection || this.orderDirection || this.order;
|
||||
|
||||
if (this.defs.orderBy) {
|
||||
sortBy = this.defs.orderBy;
|
||||
asc = true;
|
||||
if (this.defs.orderDirection) {
|
||||
if (this.defs.orderDirection && (this.defs.orderDirection === true || this.defs.orderDirection.toLowerCase() === 'DESC')) {
|
||||
asc = false;
|
||||
}
|
||||
}
|
||||
if ('asc' in this.defs) { // TODO remove in 5.8
|
||||
order = this.defs.asc ? 'asc' : 'desc';
|
||||
}
|
||||
|
||||
this.defaultSortBy = sortBy;
|
||||
this.defaultAsc = asc;
|
||||
if (orderBy && !order) {
|
||||
order = 'asc';
|
||||
}
|
||||
|
||||
this.defaultOrderBy = orderBy;
|
||||
this.defaultOrder = order;
|
||||
},
|
||||
|
||||
setupListLayout: function () {},
|
||||
@@ -374,8 +372,8 @@ Espo.define('views/record/panels/relationship', ['views/record/panels/bottom', '
|
||||
filterList: this.filterList,
|
||||
filter: filter,
|
||||
layoutName: this.layoutName,
|
||||
defaultAsc: this.defaultAsc,
|
||||
defaultSortBy: this.defaultSortBy,
|
||||
defaultOrder: this.defaultOrder,
|
||||
defaultOrderBy: this.defaultOrderBy,
|
||||
url: data.url || this.url,
|
||||
listViewName: this.listViewName,
|
||||
createDisabled: !this.isCreateAvailable(scope),
|
||||
|
||||
Reference in New Issue
Block a user