From: colemanw Date: Sun, 28 May 2023 18:14:09 +0000 (-0400) Subject: SearchKit - Remove redundant param from GetSearchTasks api X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=174e739b2c8c5cfac72535bdddc344472206c485;p=civicrm-core.git SearchKit - Remove redundant param from GetSearchTasks api --- diff --git a/ext/search_kit/Civi/Api4/Action/SearchDisplay/GetSearchTasks.php b/ext/search_kit/Civi/Api4/Action/SearchDisplay/GetSearchTasks.php index 17b3b91c53..ef6fe74dd7 100644 --- a/ext/search_kit/Civi/Api4/Action/SearchDisplay/GetSearchTasks.php +++ b/ext/search_kit/Civi/Api4/Action/SearchDisplay/GetSearchTasks.php @@ -21,20 +21,17 @@ class GetSearchTasks extends \Civi\Api4\Generic\AbstractAction { */ protected $display; - /** - * Name of entity - * @var string - * @required - */ - protected $entity; - /** * @param \Civi\Api4\Generic\Result $result * @throws \CRM_Core_Exception */ public function _run(\Civi\Api4\Generic\Result $result) { + $this->loadSavedSearch(); + $this->loadSearchDisplay(); + // Adding checkPermissions filters out actions the user is not allowed to perform - $entityName = ($this->entity === 'RelationshipCache') ? 'Relationship' : $this->entity; + $entityName = $this->savedSearch['api_entity']; + $entityName = ($entityName === 'RelationshipCache') ? 'Relationship' : $entityName; $entity = Entity::get($this->checkPermissions)->addWhere('name', '=', $entityName) ->addSelect('name', 'title_plural') ->setChain([ @@ -47,9 +44,6 @@ class GetSearchTasks extends \Civi\Api4\Generic\AbstractAction { return; } - $this->loadSavedSearch(); - $this->loadSearchDisplay(); - $tasks = [$entity['name'] => []]; if (array_key_exists($entity['name'], \CRM_Export_BAO_Export::getComponents())) { @@ -233,9 +227,9 @@ class GetSearchTasks extends \Civi\Api4\Generic\AbstractAction { // 2. To allow tasks to be added/removed per search display // Note: Use Events::W_LATE to do so after the tasks are filtered per search-display settings. // 3. To get a full list of Angular modules which provide tasks. - // Note: That's why this hook needs the base-level array and not just the array of tasks for `$this->entity`. + // Note: That's why this hook needs the base-level array and not just the array of tasks for `$entity`. // Although it may seem wasteful to have extensions add tasks for all possible entities and then - // discard most of it (all but the ones relevant to `$this->entity`), it's necessary to do it this way + // discard most of it (all but the ones relevant to `$entity`), it's necessary to do it this way // so that they can be declared as angular dependencies - see search_kit_civicrm_angularModules(). $null = NULL; $checkPermissions = $this->checkPermissions; diff --git a/ext/search_kit/ang/crmSearchAdmin/displays/common/searchAdminTasksConfig.component.js b/ext/search_kit/ang/crmSearchAdmin/displays/common/searchAdminTasksConfig.component.js index 11887b9570..0451576f05 100644 --- a/ext/search_kit/ang/crmSearchAdmin/displays/common/searchAdminTasksConfig.component.js +++ b/ext/search_kit/ang/crmSearchAdmin/displays/common/searchAdminTasksConfig.component.js @@ -14,7 +14,6 @@ this.$onInit = function() { crmApi4('SearchDisplay', 'getSearchTasks', { - entity: ctrl.apiEntity, savedSearch: {api_entity: ctrl.apiEntity, api_params: ctrl.apiParams} }).then(function(tasks) { ctrl.allTasks = tasks; diff --git a/ext/search_kit/ang/crmSearchTasks/traits/searchDisplayTasksTrait.service.js b/ext/search_kit/ang/crmSearchTasks/traits/searchDisplayTasksTrait.service.js index d7e916b919..56a439a23e 100644 --- a/ext/search_kit/ang/crmSearchTasks/traits/searchDisplayTasksTrait.service.js +++ b/ext/search_kit/ang/crmSearchTasks/traits/searchDisplayTasksTrait.service.js @@ -19,7 +19,7 @@ } fetchedMetadata = crmApi4({ entityInfo: ['Entity', 'get', {select: ['name', 'title', 'title_plural', 'primary_key'], where: [['name', '=', mngr.getEntityName()]]}, 0], - tasks: ['SearchDisplay', 'getSearchTasks', {entity: displayCtrl.apiEntity, savedSearch: displayCtrl.search, display: displayCtrl.display}] + tasks: ['SearchDisplay', 'getSearchTasks', {savedSearch: displayCtrl.search, display: displayCtrl.display}] }).then(function(result) { mngr.entityInfo = result.entityInfo; mngr.tasks = result.tasks;