orderDisabled parameter

This commit is contained in:
Yuri Kuznetsov
2024-04-01 17:05:57 +03:00
parent f2d5b2685e
commit 3044f83690
28 changed files with 124 additions and 10 deletions
@@ -62,7 +62,7 @@ class Applier
$orderBy = $params->getOrderBy();
if (/*$params->forbidComplexExpressions() && */$orderBy) {
if ($orderBy) {
if (
!is_string($orderBy) ||
str_contains($orderBy, '.') ||
@@ -70,6 +70,10 @@ class Applier
) {
throw new Forbidden("Complex expressions are forbidden in 'orderBy'.");
}
if ($this->metadataProvider->isFieldOrderDisabled($this->entityType, $orderBy)) {
throw new Forbidden("Order by the field '$orderBy' is disabled.");
}
}
if ($orderBy === null) {
@@ -58,6 +58,11 @@ class MetadataProvider
]) ?? null;
}
public function isFieldOrderDisabled(string $entityType, string $field): bool
{
return $this->metadata->get("entityDefs.$entityType.fields.$field.orderDisabled") ?? false;
}
public function hasAttribute(string $entityType, string $attribute): bool
{
return $this->entityManager
@@ -40,7 +40,8 @@
"childList": {
"type": "jsonArray",
"notStorable": true,
"utility": true
"utility": true,
"orderDisabled": true
}
},
"links": {
@@ -65,6 +65,7 @@
"reminders": {
"type": "jsonArray",
"notStorable": true,
"orderDisabled": true,
"view": "crm:views/meeting/fields/reminders",
"layoutListDisabled": true,
"validatorClassNameList": [
@@ -93,6 +93,7 @@
"type": "varchar",
"notStorable": true,
"utility": true,
"orderDisabled": true,
"maxLength": 100,
"pattern": "$noBadCharacters",
"layoutMassUpdateDisabled": true,
@@ -106,6 +107,7 @@
"contactIsInactive": {
"type": "bool",
"notStorable": true,
"orderDisabled": true,
"default": false,
"utility": true
},
@@ -201,6 +203,7 @@
"targetList": {
"type": "link",
"notStorable": true,
"orderDisabled": true,
"layoutDetailDisabled": true,
"layoutListDisabled": true,
"layoutMassUpdateDisabled": true,
@@ -216,6 +219,7 @@
"targetListIsOptedOut": {
"type": "bool",
"notStorable": true,
"orderDisabled": true,
"readOnly": true,
"utility": true
}
@@ -47,6 +47,7 @@
"reminders": {
"type": "jsonArray",
"notStorable": true,
"orderDisabled": true,
"view": "crm:views/meeting/fields/reminders",
"layoutListDisabled": true,
"validatorClassNameList": [
@@ -82,6 +83,7 @@
},
"layoutDetailDisabled": true,
"layoutMassUpdateDisabled": true,
"orderDisabled": true,
"importDisabled": true,
"exportDisabled": true,
"customizationDefaultDisabled": true,
@@ -304,6 +306,7 @@
"phoneNumbersMap": {
"type": "jsonObject",
"notStorable": true,
"orderDisabled": true,
"utility": true,
"customizationDisabled": true
},
@@ -86,6 +86,7 @@
"sentCount": {
"type": "int",
"notStorable": true,
"orderDisabled": true,
"directAccessDisabled": true,
"readOnly": true,
"utility": true
@@ -94,6 +95,7 @@
"view": "crm:views/campaign/fields/int-with-percentage",
"type": "int",
"notStorable": true,
"orderDisabled": true,
"directAccessDisabled": true,
"readOnly": true,
"utility": true
@@ -102,6 +104,7 @@
"view": "crm:views/campaign/fields/int-with-percentage",
"type": "int",
"notStorable": true,
"orderDisabled": true,
"directAccessDisabled": true,
"readOnly": true,
"utility": true
@@ -109,6 +112,7 @@
"optedInCount": {
"type": "int",
"notStorable": true,
"orderDisabled": true,
"directAccessDisabled": true,
"readOnly": true,
"utility": true
@@ -117,6 +121,7 @@
"view": "crm:views/campaign/fields/int-with-percentage",
"type": "int",
"notStorable": true,
"orderDisabled": true,
"directAccessDisabled": true,
"readOnly": true,
"utility": true
@@ -125,6 +130,7 @@
"view": "crm:views/campaign/fields/int-with-percentage",
"type": "int",
"notStorable": true,
"orderDisabled": true,
"directAccessDisabled": true,
"readOnly": true,
"utility": true
@@ -132,6 +138,7 @@
"hardBouncedCount": {
"type": "int",
"notStorable": true,
"orderDisabled": true,
"directAccessDisabled": true,
"readOnly": true,
"utility": true
@@ -139,6 +146,7 @@
"softBouncedCount": {
"type": "int",
"notStorable": true,
"orderDisabled": true,
"directAccessDisabled": true,
"readOnly": true,
"utility": true
@@ -146,6 +154,7 @@
"leadCreatedCount": {
"type": "int",
"notStorable": true,
"orderDisabled": true,
"directAccessDisabled": true,
"readOnly": true,
"utility": true
@@ -153,6 +162,7 @@
"openedPercentage": {
"type": "int",
"notStorable": true,
"orderDisabled": true,
"directAccessDisabled": true,
"readOnly": true,
"utility": true
@@ -160,6 +170,7 @@
"clickedPercentage": {
"type": "int",
"notStorable": true,
"orderDisabled": true,
"directAccessDisabled": true,
"readOnly": true,
"utility": true
@@ -167,6 +178,7 @@
"optedOutPercentage": {
"type": "int",
"notStorable": true,
"orderDisabled": true,
"directAccessDisabled": true,
"readOnly": true,
"utility": true
@@ -174,6 +186,7 @@
"bouncedPercentage": {
"type": "int",
"notStorable": true,
"orderDisabled": true,
"directAccessDisabled": true,
"readOnly": true,
"utility": true
@@ -181,6 +194,7 @@
"revenue": {
"type": "currency",
"notStorable": true,
"orderDisabled": true,
"directAccessDisabled": true,
"readOnly": true,
"utility": true
@@ -11,6 +11,7 @@
"urlToUse": {
"type": "varchar",
"notStorable": true,
"orderDisabled": true,
"readOnly": true
},
"campaign": {
@@ -74,6 +74,7 @@
"originalEmail": {
"type": "link",
"notStorable": true,
"orderDisabled": true,
"entity": "Email",
"customizationDisabled": true,
"layoutAvailabilityList": [],
@@ -19,6 +19,7 @@
},
"accountAnyId": {
"notStorable": true,
"orderDisabled": true,
"customizationDisabled": true,
"utility": true,
"type": "varchar",
@@ -277,6 +278,7 @@
"accountRole": {
"type": "varchar",
"notStorable": true,
"orderDisabled": true,
"directUpdateDisabled": true,
"layoutDetailDisabled": true,
"layoutMassUpdateDisabled": true,
@@ -377,6 +379,7 @@
"opportunityRole": {
"type": "enum",
"notStorable": true,
"orderDisabled": true,
"options": ["", "Decision Maker", "Evaluator", "Influencer"],
"layoutMassUpdateDisabled": true,
"layoutListDisabled": true,
@@ -397,6 +400,7 @@
"acceptanceStatus": {
"type": "varchar",
"notStorable": true,
"orderDisabled": true,
"exportDisabled": true,
"utility": true,
"fieldManagerParamList": []
@@ -404,6 +408,7 @@
"acceptanceStatusMeetings": {
"type": "enum",
"notStorable": true,
"orderDisabled": true,
"directUpdateDisabled": true,
"layoutAvailabilityList": ["filters"],
"importDisabled": true,
@@ -416,6 +421,7 @@
"acceptanceStatusCalls": {
"type": "enum",
"notStorable": true,
"orderDisabled": true,
"directUpdateDisabled": true,
"layoutAvailabilityList": ["filters"],
"importDisabled": true,
@@ -472,6 +478,7 @@
"targetList": {
"type": "link",
"notStorable": true,
"orderDisabled": true,
"layoutDetailDisabled": true,
"layoutListDisabled": true,
"layoutMassUpdateDisabled": true,
@@ -528,12 +535,14 @@
"targetListIsOptedOut": {
"type": "bool",
"notStorable": true,
"orderDisabled": true,
"readOnly": true,
"utility": true
},
"originalEmail": {
"type": "link",
"notStorable": true,
"orderDisabled": true,
"entity": "Email",
"customizationDisabled": true,
"layoutAvailabilityList": [],
@@ -41,7 +41,8 @@
},
"childList": {
"type": "jsonArray",
"notStorable": true
"notStorable": true,
"orderDisabled": true
}
},
"links": {
@@ -47,7 +47,8 @@
},
"childList": {
"type": "jsonArray",
"notStorable": true
"notStorable": true,
"orderDisabled": true
}
},
"links": {
@@ -168,6 +168,7 @@
"acceptanceStatus": {
"type": "varchar",
"notStorable": true,
"orderDisabled": true,
"exportDisabled": true,
"utility": true,
"fieldManagerParamList": []
@@ -175,6 +176,7 @@
"acceptanceStatusMeetings": {
"type": "enum",
"notStorable": true,
"orderDisabled": true,
"directUpdateDisabled": true,
"layoutAvailabilityList": ["filters"],
"importDisabled": true,
@@ -187,6 +189,7 @@
"acceptanceStatusCalls": {
"type": "enum",
"notStorable": true,
"orderDisabled": true,
"directUpdateDisabled": true,
"layoutAvailabilityList": ["filters"],
"importDisabled": true,
@@ -230,6 +233,7 @@
"targetList": {
"type": "link",
"notStorable": true,
"orderDisabled": true,
"layoutDetailDisabled": true,
"layoutListDisabled": true,
"layoutMassUpdateDisabled": true,
@@ -240,12 +244,14 @@
"targetListIsOptedOut": {
"type": "bool",
"notStorable": true,
"orderDisabled": true,
"readOnly": true,
"utility": true
},
"originalEmail": {
"type": "link",
"notStorable": true,
"orderDisabled": true,
"entity": "Email",
"customizationDisabled": true,
"layoutAvailabilityList": [],
@@ -72,6 +72,7 @@
"smtpAccount": {
"type": "base",
"notStorable": true,
"orderDisabled": true,
"view": "crm:views/mass-email/fields/smtp-account"
},
"createdAt": {
@@ -55,6 +55,7 @@
"reminders": {
"type": "jsonArray",
"notStorable": true,
"orderDisabled": true,
"view": "crm:views/meeting/fields/reminders",
"layoutListDisabled": true,
"validatorClassNameList": [
@@ -77,6 +78,7 @@
"acceptanceStatus": {
"type": "enum",
"notStorable": true,
"orderDisabled": true,
"options": ["None", "Accepted", "Tentative", "Declined"],
"style": {
"Accepted": "success",
@@ -281,6 +283,7 @@
"sourceEmail": {
"type": "link",
"notStorable": true,
"orderDisabled": true,
"layoutDetailDisabled": true,
"layoutListDisabled": true,
"layoutMassUpdateDisabled": true,
@@ -224,6 +224,7 @@
"contactRole": {
"type": "enum",
"notStorable": true,
"orderDisabled": true,
"layoutMassUpdateDisabled": true,
"layoutDetailDisabled": true,
"layoutAvailabilityList": ["listForContact"],
@@ -9,6 +9,7 @@
"type": "int",
"readOnly": true,
"notStorable": true,
"orderDisabled": true,
"layoutFiltersDisabled": true,
"layoutMassUpdateDisabled": true
},
@@ -16,6 +17,7 @@
"type": "int",
"readOnly": true,
"notStorable": true,
"orderDisabled": true,
"layoutListDisabled": true,
"layoutFiltersDisabled": true,
"layoutMassUpdateDisabled": true
@@ -26,6 +28,7 @@
"sourceCampaign": {
"type": "link",
"notStorable": true,
"orderDisabled": true,
"directAccessDisabled": true,
"customizationDisabled": true,
"layoutAvailabilityList": []
@@ -71,6 +74,7 @@
"layoutFiltersDisabled": true,
"layoutLinkDisabled": true,
"notStorable": true,
"orderDisabled": true,
"utility": true
},
"excludingActionList": {
@@ -80,12 +84,14 @@
"layoutFiltersDisabled": true,
"layoutLinkDisabled": true,
"notStorable": true,
"orderDisabled": true,
"utility": true
},
"targetStatus": {
"type": "enum",
"options": ["Listed", "Opted Out"],
"notStorable": true,
"orderDisabled": true,
"readOnly": true,
"layoutListDisabled": true,
"layoutDetailDisabled": true,
@@ -98,6 +104,7 @@
"isOptedOut": {
"type": "bool",
"notStorable": true,
"orderDisabled": true,
"readOnly": true,
"layoutListDisabled": true,
"layoutDetailDisabled": true,
@@ -73,12 +73,14 @@
"type": "bool",
"readOnly": true,
"notStorable": true,
"orderDisabled": true,
"view": "crm:views/task/fields/is-overdue",
"utility": true
},
"reminders": {
"type": "jsonArray",
"notStorable": true,
"orderDisabled": true,
"view": "crm:views/meeting/fields/reminders",
"dateField": "dateEnd",
"validatorClassNameList": [
@@ -3,6 +3,7 @@
"targetListIsOptedOut": {
"type": "bool",
"notStorable": true,
"orderDisabled": true,
"readOnly": true,
"utility": true,
"fieldManagerParamList": []
@@ -10,6 +10,7 @@
"type": "varchar",
"required": true,
"notStorable": true,
"orderDisabled": true,
"view": "views/email/fields/subject",
"utility": true
},
@@ -27,6 +28,7 @@
"type": "varchar",
"readOnly": true,
"notStorable": true,
"orderDisabled": true,
"textFilterDisabled": true,
"layoutFiltersDisabled": true,
"customizationDisabled": true,
@@ -49,6 +51,7 @@
"type": "varchar",
"readOnly": true,
"notStorable": true,
"orderDisabled": true,
"textFilterDisabled": true,
"layoutFiltersDisabled": true,
"customizationDisabled": true,
@@ -58,6 +61,7 @@
"type": "varchar",
"readOnly": true,
"notStorable": true,
"orderDisabled": true,
"textFilterDisabled": true,
"layoutFiltersDisabled": true,
"customizationDisabled": true,
@@ -72,6 +76,7 @@
"from": {
"type": "varchar",
"notStorable": true,
"orderDisabled": true,
"required": true,
"view": "views/email/fields/from-address-varchar",
"textFilterDisabled": true,
@@ -82,6 +87,7 @@
"to": {
"type": "varchar",
"notStorable": true,
"orderDisabled": true,
"required": true,
"view": "views/email/fields/email-address-varchar",
"validatorClassName": "Espo\\Classes\\FieldValidators\\Email\\EmailAddresses",
@@ -97,6 +103,7 @@
"cc": {
"type": "varchar",
"notStorable": true,
"orderDisabled": true,
"view": "views/email/fields/email-address-varchar",
"validatorClassNameList": [
"Espo\\Classes\\FieldValidators\\Email\\Addresses\\Valid",
@@ -110,6 +117,7 @@
"bcc": {
"type": "varchar",
"notStorable": true,
"orderDisabled": true,
"view": "views/email/fields/email-address-varchar",
"validatorClassNameList": [
"Espo\\Classes\\FieldValidators\\Email\\Addresses\\Valid",
@@ -123,6 +131,7 @@
"replyTo": {
"type": "varchar",
"notStorable": true,
"orderDisabled": true,
"view": "views/email/fields/email-address-varchar",
"textFilterDisabled": true,
"customizationDisabled": true,
@@ -132,6 +141,7 @@
"personStringData": {
"type": "varchar",
"notStorable": true,
"orderDisabled": true,
"utility": true,
"view": "views/email/fields/person-string-data",
"customizationDisabled": true
@@ -198,6 +208,7 @@
"folder": {
"type": "link",
"notStorable": true,
"orderDisabled": true,
"readOnly": true,
"entity": "EmailFolder",
"customizationDisabled": true
@@ -205,6 +216,7 @@
"nameHash": {
"type": "text",
"notStorable": true,
"orderDisabled": true,
"readOnly": true,
"utility": true,
"customizationDisabled": true
@@ -219,6 +231,7 @@
"idHash": {
"type": "text",
"notStorable": true,
"orderDisabled": true,
"readOnly": true,
"utility": true,
"customizationDisabled": true
@@ -10,7 +10,8 @@
},
"noteData": {
"type": "jsonObject",
"notStorable": true
"notStorable": true,
"orderDisabled": true
},
"type": {
"type": "varchar"
@@ -52,6 +52,7 @@
"internal": true,
"utility": true,
"notStorable": true,
"orderDisabled": true,
"directAccessDisabled": true,
"fieldManagerParamList": []
},
@@ -85,6 +86,7 @@
"maxLength": 100,
"readOnly": true,
"notStorable": true,
"orderDisabled": true,
"layoutMassUpdateDisabled": true,
"layoutDetailDisabled": true,
"layoutFiltersDisabled": true,
@@ -127,6 +129,7 @@
"type": "varchar",
"maxLength": 100,
"notStorable": true,
"orderDisabled": true,
"where": {
"LIKE": {
"whereClause": {
@@ -245,24 +248,28 @@
"token": {
"type": "varchar",
"notStorable": true,
"orderDisabled": true,
"utility": true,
"customizationDisabled": true
},
"authTokenId": {
"type": "varchar",
"notStorable": true,
"orderDisabled": true,
"utility": true,
"customizationDisabled": true
},
"authLogRecordId": {
"type": "varchar",
"notStorable": true,
"orderDisabled": true,
"utility": true,
"customizationDisabled": true
},
"ipAddress": {
"type": "varchar",
"notStorable": true,
"orderDisabled": true,
"utility": true,
"customizationDisabled": true
},
@@ -275,6 +282,7 @@
"acceptanceStatus": {
"type": "varchar",
"notStorable": true,
"orderDisabled": true,
"exportDisabled": true,
"utility": true,
"fieldManagerParamList": []
@@ -282,6 +290,7 @@
"acceptanceStatusMeetings": {
"type": "enum",
"notStorable": true,
"orderDisabled": true,
"directUpdateDisabled": true,
"layoutAvailabilityList": ["filters"],
"importDisabled": true,
@@ -294,6 +303,7 @@
"acceptanceStatusCalls": {
"type": "enum",
"notStorable": true,
"orderDisabled": true,
"directUpdateDisabled": true,
"layoutAvailabilityList": ["filters"],
"importDisabled": true,
@@ -306,6 +316,7 @@
"teamRole": {
"type": "varchar",
"notStorable": true,
"orderDisabled": true,
"utility": true,
"fieldManagerParamList": []
},
@@ -363,6 +374,7 @@
"account": {
"type": "link",
"notStorable": true,
"orderDisabled": true,
"directAccessDisabled": true,
"foreignAccessDisabled": true,
"layoutDetailDisabled": true,
@@ -373,6 +385,7 @@
"portal": {
"type": "link",
"notStorable": true,
"orderDisabled": true,
"readOnly": true,
"utility": true
},
@@ -386,6 +399,7 @@
"sendAccessInfo": {
"type": "bool",
"notStorable": true,
"orderDisabled": true,
"utility": true
},
"gender": {
@@ -446,6 +460,7 @@
"lastAccess": {
"type": "datetime",
"notStorable": true,
"orderDisabled": true,
"readOnly": true,
"layoutListDisabled": true,
"layoutFiltersDisabled": true,
@@ -41,6 +41,7 @@
"map": {
"type": "map",
"notStorable": true,
"orderDisabled": true,
"readOnly": true,
"layoutListDisabled": true,
"provider": "Google",
@@ -10,6 +10,7 @@
"notCreatable": true,
"notSortable": true,
"fieldDefs": {
"notStorable": true
"notStorable": true,
"orderDisabled": true
}
}
@@ -138,7 +138,7 @@ class EntityManagerEditView extends View {
return false;
}
if (fieldDefs[item].notStorable) {
if (fieldDefs[item].orderDisabled) {
return false;
}
@@ -53,7 +53,7 @@ define('views/dashlets/fields/records/sort-by', ['views/fields/enum'], function
var orderableFieldList = Object.keys(fieldDefs)
.filter(item => {
if (fieldDefs[item].notStorable) {
if (fieldDefs[item].orderDisabled) {
return false;
}
+15 -2
View File
@@ -2259,11 +2259,11 @@ class ListRecordView extends View {
forbiddenFieldList = [];
}
if (!forbiddenFieldList.length) {
/*if (!forbiddenFieldList.length) {
this._cachedFilteredListLayout = listLayout;
return this._cachedFilteredListLayout;
}
}*/
const filteredListLayout = Espo.Utils.cloneDeep(listLayout);
@@ -2282,6 +2282,19 @@ class ListRecordView extends View {
.reverse()
.forEach(index => filteredListLayout.splice(index, 1));
/** @type {Record<Record>} */
const fieldDefs = this.getMetadata().get(`entityDefs.${this.entityType}.fields`) || {};
filteredListLayout.forEach(item => {
if (!item.name || !fieldDefs[item.name]) {
return;
}
if (fieldDefs[item.name].orderDisabled) {
item.notSortable = true;
}
});
this._cachedFilteredListLayout = filteredListLayout;
return this._cachedFilteredListLayout;
+4
View File
@@ -735,6 +735,10 @@
},
"description": "A list of layout types the field won't be available in. As of v8.2."
},
"orderDisabled": {
"type": "boolean",
"default": "Disables the ability to order by the field."
},
"textFilterDisabled": {
"type": "boolean",
"description": "Disables the ability to add the field to text filters (in the Entity Manager tool)."