diff --git a/application/Espo/Controllers/EntityManager.php b/application/Espo/Controllers/EntityManager.php index 79210b5224..83e4a59e1c 100644 --- a/application/Espo/Controllers/EntityManager.php +++ b/application/Espo/Controllers/EntityManager.php @@ -92,6 +92,9 @@ class EntityManager extends \Espo\Core\Controllers\Base if (isset($data['fullTextSearch'])) { $params['fullTextSearch'] = $data['fullTextSearch']; } + if (isset($data['countDisabled'])) { + $params['countDisabled'] = $data['countDisabled']; + } $params['kanbanViewMode'] = !empty($data['kanbanViewMode']); if (!empty($data['kanbanStatusIgnoreList'])) { diff --git a/application/Espo/Core/Utils/EntityManager.php b/application/Espo/Core/Utils/EntityManager.php index adc956ad26..9b0a8b75df 100644 --- a/application/Espo/Core/Utils/EntityManager.php +++ b/application/Espo/Core/Utils/EntityManager.php @@ -454,6 +454,15 @@ class EntityManager $this->getMetadata()->set('entityDefs', $name, $entityDefsData); } + if (isset($data['countDisabled'])) { + $entityDefsData = [ + 'collection' => [ + 'countDisabled' => !!$data['countDisabled'] + ] + ]; + $this->getMetadata()->set('entityDefs', $name, $entityDefsData); + } + if (array_key_exists('kanbanStatusIgnoreList', $data)) { $scopeData['kanbanStatusIgnoreList'] = $data['kanbanStatusIgnoreList']; $this->getMetadata()->set('scopes', $name, $scopeData); diff --git a/application/Espo/Core/defaults/config.php b/application/Espo/Core/defaults/config.php index 4e9df19d05..7df3e73d6f 100644 --- a/application/Espo/Core/defaults/config.php +++ b/application/Espo/Core/defaults/config.php @@ -121,7 +121,6 @@ return [ 'emailNotificationsDelay' => 30, 'emailMessageMaxSize' => 10, 'notificationsCheckInterval' => 10, - 'disabledCountQueryEntityList' => ['Email'], 'maxEmailAccountCount' => 2, 'followCreatedEntities' => false, 'b2cMode' => false, diff --git a/application/Espo/Resources/i18n/en_US/EntityManager.json b/application/Espo/Resources/i18n/en_US/EntityManager.json index 0197aeb6fc..3faaee36e3 100644 --- a/application/Espo/Resources/i18n/en_US/EntityManager.json +++ b/application/Espo/Resources/i18n/en_US/EntityManager.json @@ -33,6 +33,7 @@ "kanbanViewMode": "Kanban View", "kanbanStatusIgnoreList": "Ignored groups in Kanban view", "iconClass": "Icon", + "countDisabled": "Disable record count", "fullTextSearch": "Full-Text Search" }, "options": { @@ -70,6 +71,7 @@ "linkAudited": "Creating related record and linking with existing record will be logged in Stream.", "linkMultipleField": "Link Multiple field provides a handy way to edit relations. Don't use it if you can have a large number of related records.", "entityType": "Base Plus - has Activities, History and Tasks panels.\n\nEvent - available in Calendar and Activities panel.", + "countDisabled": "Total number won't be displayed on the list view. Can decrease loading time when the DB table is big.", "fullTextSearch": "Running rebuild is required." } } diff --git a/application/Espo/Resources/metadata/entityDefs/Email.json b/application/Espo/Resources/metadata/entityDefs/Email.json index e4b880a6d8..bda181f074 100644 --- a/application/Espo/Resources/metadata/entityDefs/Email.json +++ b/application/Espo/Resources/metadata/entityDefs/Email.json @@ -469,6 +469,7 @@ "orderBy": "dateSent", "order": "desc", "textFilterFields": ["name", "bodyPlain", "body"], + "countDisabled": true, "fullTextSearch": true }, "indexes": { diff --git a/application/Espo/Services/Record.php b/application/Espo/Services/Record.php index 4bc0647755..6a4e28ea41 100644 --- a/application/Espo/Services/Record.php +++ b/application/Espo/Services/Record.php @@ -1080,7 +1080,7 @@ class Record extends \Espo\Core\Services\Base if ( $this->listCountQueryDisabled || - in_array($this->entityType, $this->getConfig()->get('disabledCountQueryEntityList', [])) + $this->getMetadata()->get(['entityDefs', $this->entityType, 'collection', 'countDisabled']) ) { $disableCount = true; } @@ -1140,7 +1140,7 @@ class Record extends \Espo\Core\Services\Base if ( $this->listCountQueryDisabled || - in_array($this->entityType, $this->getConfig()->get('disabledCountQueryEntityList', [])) + $this->getMetadata()->get(['entityDefs', $this->entityType, 'collection', 'countDisabled']) ) { $disableCount = true; } @@ -1316,24 +1316,22 @@ class Record extends \Espo\Core\Services\Base return $this->$methodName($id, $params); } - $foreignEntityName = $entity->relations[$link]['entity']; + $foreignEntityType = $entity->relations[$link]['entity']; $linkParams = $this->linkParams[$link] ?? []; $skipAcl = $linkParams['skipAcl'] ?? false; if (!$skipAcl) { - if (!$this->getAcl()->check($foreignEntityName, 'read')) { + if (!$this->getAcl()->check($foreignEntityType, 'read')) { throw new Forbidden(); } } - $recordService = $this->getRecordService($foreignEntityName); + $recordService = $this->getRecordService($foreignEntityType); $disableCount = false; $disableCountPropertyName = 'findLinked' . ucfirst($link) . 'CountQueryDisabled'; if ( - in_array($this->entityType, $this->getConfig()->get('disabledCountQueryEntityList', [])) - || !empty($this->$disableCountPropertyName) ) { $disableCount = true; @@ -1347,7 +1345,7 @@ class Record extends \Espo\Core\Services\Base } } - $selectParams = $this->getSelectManager($foreignEntityName)->getSelectParams($params, !$skipAcl, true); + $selectParams = $this->getSelectManager($foreignEntityType)->getSelectParams($params, !$skipAcl, true); if (array_key_exists($link, $this->linkSelectParams)) { $selectParams = array_merge($selectParams, $this->linkSelectParams[$link]); diff --git a/application/Espo/Services/Settings.php b/application/Espo/Services/Settings.php index 6c51736588..f432236df7 100644 --- a/application/Espo/Services/Settings.php +++ b/application/Espo/Services/Settings.php @@ -119,7 +119,6 @@ class Settings extends \Espo\Core\Services\Base 'assignmentEmailNotificationsEntityList', 'assignmentNotificationsEntityList', 'calendarEntityList', - 'disabledCountQueryEntityList', 'streamEmailNotificationsEntityList', 'activitiesEntityList', 'historyEntityList', diff --git a/client/res/templates/admin/entity-manager/modals/edit-entity.tpl b/client/res/templates/admin/entity-manager/modals/edit-entity.tpl index ea5e9445bf..6c94f771e6 100644 --- a/client/res/templates/admin/entity-manager/modals/edit-entity.tpl +++ b/client/res/templates/admin/entity-manager/modals/edit-entity.tpl @@ -84,6 +84,12 @@ {{{fullTextSearch}}} +
+ +
+ {{{countDisabled}}} +
+
diff --git a/client/src/views/admin/entity-manager/modals/edit-entity.js b/client/src/views/admin/entity-manager/modals/edit-entity.js index 5493c3462a..fd63f732cc 100644 --- a/client/src/views/admin/entity-manager/modals/edit-entity.js +++ b/client/src/views/admin/entity-manager/modals/edit-entity.js @@ -26,7 +26,7 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -Espo.define('views/admin/entity-manager/modals/edit-entity', ['views/modal', 'model'], function (Dep, Model) { +define('views/admin/entity-manager/modals/edit-entity', ['views/modal', 'model'], function (Dep, Model) { return Dep.extend({ @@ -66,6 +66,7 @@ Espo.define('views/admin/entity-manager/modals/edit-entity', ['views/modal', 'mo this.model.set('textFilterFields', this.getMetadata().get(['entityDefs', scope, 'collection', 'textFilterFields']) || ['name']); this.model.set('fullTextSearch', this.getMetadata().get(['entityDefs', scope, 'collection', 'fullTextSearch']) || false); + this.model.set('countDisabled', this.getMetadata().get(['entityDefs', scope, 'collection', 'countDisabled']) || false); this.model.set('statusField', this.getMetadata().get('scopes.' + scope + '.statusField') || null); @@ -272,6 +273,16 @@ Espo.define('views/admin/entity-manager/modals/edit-entity', ['views/modal', 'mo tooltip: true }); + this.createView('countDisabled', 'views/fields/bool', { + model: model, + mode: 'edit', + el: this.options.el + ' .field[data-name="countDisabled"]', + defs: { + name: 'countDisabled' + }, + tooltip: true, + }); + this.createView('kanbanViewMode', 'views/fields/bool', { model: model, mode: 'edit', @@ -523,6 +534,7 @@ Espo.define('views/admin/entity-manager/modals/edit-entity', ['views/modal', 'mo disabled: this.model.get('disabled'), textFilterFields: this.model.get('textFilterFields'), fullTextSearch: this.model.get('fullTextSearch'), + countDisabled: this.model.get('countDisabled'), statusField: this.model.get('statusField'), iconClass: this.model.get('iconClass') };