order fixes
This commit is contained in:
@@ -74,20 +74,31 @@ class Entity extends \Espo\ORM\Entity
|
||||
$defs['additionalColumns'] = $columns;
|
||||
}
|
||||
|
||||
$idsAttribute = $field . 'Ids';
|
||||
|
||||
$foreignEntityType = $this->getRelationParam($field, 'entity');
|
||||
if ($foreignEntityType && $this->entityManager) {
|
||||
$foreignEntityDefs = $this->entityManager->getMetadata()->get($foreignEntityType);
|
||||
if ($foreignEntityDefs && !empty($foreignEntityDefs['collection'])) {
|
||||
$collectionDefs = $foreignEntityDefs['collection'];
|
||||
if (!empty($foreignEntityDefs['collection']['orderBy'])) {
|
||||
$orderBy = $foreignEntityDefs['collection']['orderBy'];
|
||||
$order = 'ASC';
|
||||
if (array_key_exists('order', $foreignEntityDefs['collection'])) {
|
||||
$order = $foreignEntityDefs['collection']['order'];
|
||||
}
|
||||
if (array_key_exists($orderBy, $foreignEntityDefs['fields'])) {
|
||||
$defs['orderBy'] = $orderBy;
|
||||
$defs['order'] = $order;
|
||||
|
||||
if ($this->getAttributeParam($idsAttribute, 'orderBy')) {
|
||||
$defs['orderBy'] = $this->getAttributeParam($idsAttribute, 'orderBy');
|
||||
$defs['order'] = 'ASC';
|
||||
if ($this->getAttributeParam($idsAttribute, 'orderDirection')) {
|
||||
$defs['order'] = $this->getAttributeParam($idsAttribute, 'orderDirection');
|
||||
}
|
||||
} else {
|
||||
if ($foreignEntityType && $this->entityManager) {
|
||||
$foreignEntityDefs = $this->entityManager->getMetadata()->get($foreignEntityType);
|
||||
if ($foreignEntityDefs && !empty($foreignEntityDefs['collection'])) {
|
||||
$collectionDefs = $foreignEntityDefs['collection'];
|
||||
if (!empty($foreignEntityDefs['collection']['orderBy'])) {
|
||||
$orderBy = $foreignEntityDefs['collection']['orderBy'];
|
||||
$order = 'ASC';
|
||||
if (array_key_exists('order', $foreignEntityDefs['collection'])) {
|
||||
$order = $foreignEntityDefs['collection']['order'];
|
||||
}
|
||||
if (array_key_exists($orderBy, $foreignEntityDefs['fields'])) {
|
||||
$defs['orderBy'] = $orderBy;
|
||||
$defs['order'] = $order;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -131,7 +142,7 @@ class Entity extends \Espo\ORM\Entity
|
||||
}
|
||||
}
|
||||
|
||||
$this->set($field . 'Ids', $ids);
|
||||
$this->set($idsAttribute, $ids);
|
||||
$this->set($field . 'Names', $names);
|
||||
if ($hasType) {
|
||||
$this->set($field . 'Types', $types);
|
||||
|
||||
@@ -44,17 +44,26 @@ class LinkMultiple extends Base
|
||||
),
|
||||
$fieldName.'Names' => array(
|
||||
'type' => 'varchar',
|
||||
'notStorable' => true,
|
||||
),
|
||||
),
|
||||
'notStorable' => true
|
||||
)
|
||||
)
|
||||
),
|
||||
'unset' => array(
|
||||
$entityName => array(
|
||||
'fields.'.$fieldName,
|
||||
),
|
||||
),
|
||||
'fields.'.$fieldName
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$fieldParams = $this->getFieldParams();
|
||||
|
||||
if (array_key_exists('orderBy', $fieldParams)) {
|
||||
$data[$entityName]['fields'][$fieldName . 'Ids']['orderBy'] = $fieldParams['orderBy'];
|
||||
if (array_key_exists('orderDirection', $fieldParams)) {
|
||||
$data[$entityName]['fields'][$fieldName . 'Ids']['orderDirection'] = $fieldParams['orderDirection'];
|
||||
}
|
||||
}
|
||||
|
||||
$columns = $this->getMetadata()->get("entityDefs.{$entityName}.fields.{$fieldName}.columns");
|
||||
if (!empty($columns)) {
|
||||
$data[$entityName]['fields'][$fieldName . 'Columns'] = array(
|
||||
|
||||
@@ -49,7 +49,8 @@
|
||||
"relationshipPanels": {
|
||||
"contacts": {
|
||||
"filterList": ["all", "accountActive"],
|
||||
"layout":"listForAccount"
|
||||
"layout":"listForAccount",
|
||||
"orderBy": "name"
|
||||
},
|
||||
"opportunities":{
|
||||
"layout":"listForAccount"
|
||||
|
||||
@@ -325,11 +325,14 @@
|
||||
}
|
||||
},
|
||||
"collection": {
|
||||
"sortBy": "name",
|
||||
"asc": true,
|
||||
"sortBy": "createdAt",
|
||||
"asc": false,
|
||||
"textFilterFields": ["name", "emailAddress"]
|
||||
},
|
||||
"indexes": {
|
||||
"createdAt": {
|
||||
"columns": ["createdAt", "deleted"]
|
||||
},
|
||||
"name": {
|
||||
"columns": ["name", "deleted"]
|
||||
},
|
||||
|
||||
@@ -93,7 +93,8 @@
|
||||
"view": "crm:views/meeting/fields/users",
|
||||
"columns": {
|
||||
"status": "acceptanceStatus"
|
||||
}
|
||||
},
|
||||
"orderBy": "name"
|
||||
},
|
||||
"contacts": {
|
||||
"type": "linkMultiple",
|
||||
@@ -102,7 +103,8 @@
|
||||
"view": "crm:views/meeting/fields/contacts",
|
||||
"columns": {
|
||||
"status": "acceptanceStatus"
|
||||
}
|
||||
},
|
||||
"orderBy": "name"
|
||||
},
|
||||
"leads": {
|
||||
"type": "linkMultiple",
|
||||
@@ -111,7 +113,8 @@
|
||||
"view": "crm:views/meeting/fields/attendees",
|
||||
"columns": {
|
||||
"status": "acceptanceStatus"
|
||||
}
|
||||
},
|
||||
"orderBy": "name"
|
||||
},
|
||||
"createdAt": {
|
||||
"type": "datetime",
|
||||
|
||||
@@ -48,7 +48,8 @@
|
||||
},
|
||||
"contacts": {
|
||||
"type": "linkMultiple",
|
||||
"view": "crm:views/case/fields/contacts"
|
||||
"view": "crm:views/case/fields/contacts",
|
||||
"orderBy": "name"
|
||||
},
|
||||
"inboundEmail": {
|
||||
"type": "link",
|
||||
|
||||
@@ -115,7 +115,8 @@
|
||||
"columns": {
|
||||
"role": "contactRole",
|
||||
"isInactive": "contactIsInactive"
|
||||
}
|
||||
},
|
||||
"orderBy": "name"
|
||||
},
|
||||
"accountRole": {
|
||||
"type": "varchar",
|
||||
@@ -404,11 +405,14 @@
|
||||
}
|
||||
},
|
||||
"collection": {
|
||||
"sortBy": "name",
|
||||
"asc": true,
|
||||
"sortBy": "createdAt",
|
||||
"asc": false,
|
||||
"textFilterFields": ["name", "emailAddress"]
|
||||
},
|
||||
"indexes": {
|
||||
"createdAt": {
|
||||
"columns": ["createdAt", "deleted"]
|
||||
},
|
||||
"firstName": {
|
||||
"columns": ["firstName", "deleted"]
|
||||
},
|
||||
|
||||
@@ -88,7 +88,8 @@
|
||||
"layoutListDisabled": true,
|
||||
"columns": {
|
||||
"status": "acceptanceStatus"
|
||||
}
|
||||
},
|
||||
"orderBy": "name"
|
||||
},
|
||||
"contacts": {
|
||||
"type": "linkMultiple",
|
||||
@@ -97,7 +98,8 @@
|
||||
"view": "crm:views/meeting/fields/contacts",
|
||||
"columns": {
|
||||
"status": "acceptanceStatus"
|
||||
}
|
||||
},
|
||||
"orderBy": "name"
|
||||
},
|
||||
"leads": {
|
||||
"type": "linkMultiple",
|
||||
@@ -106,7 +108,8 @@
|
||||
"layoutListDisabled": true,
|
||||
"columns": {
|
||||
"status": "acceptanceStatus"
|
||||
}
|
||||
},
|
||||
"orderBy": "name"
|
||||
},
|
||||
"createdAt": {
|
||||
"type": "datetime",
|
||||
|
||||
@@ -38,7 +38,8 @@
|
||||
"view": "crm:views/opportunity/fields/contacts",
|
||||
"columns": {
|
||||
"role": "opportunityRole"
|
||||
}
|
||||
},
|
||||
"orderBy": "name"
|
||||
},
|
||||
"stage": {
|
||||
"type": "enum",
|
||||
|
||||
@@ -131,6 +131,16 @@ Espo.define('views/record/panels/relationship', ['views/record/panels/bottom', '
|
||||
var sortBy = this.defs.sortBy || null;
|
||||
var asc = this.defs.asc || null;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.wait(true);
|
||||
this.getCollectionFactory().create(this.scope, function (collection) {
|
||||
collection.maxSize = this.getConfig().get('recordsPerPageSmall') || 5;
|
||||
|
||||
Reference in New Issue
Block a user