SearchKit - Rename crmSearchActions module to crmSearchTasks & add hook_civicrm_searc...
authorColeman Watts <coleman@civicrm.org>
Fri, 14 May 2021 15:52:09 +0000 (11:52 -0400)
committerColeman Watts <coleman@civicrm.org>
Fri, 14 May 2021 15:52:09 +0000 (11:52 -0400)
28 files changed:
ext/search_kit/Civi/Api4/Action/SearchDisplay/GetSearchTasks.php
ext/search_kit/ang/crmSearchAdmin.ang.php
ext/search_kit/ang/crmSearchAdmin/compose/controls.html
ext/search_kit/ang/crmSearchDisplayTable.ang.php
ext/search_kit/ang/crmSearchDisplayTable/crmSearchDisplayTable.html
ext/search_kit/ang/crmSearchTasks.ang.php [moved from ext/search_kit/ang/crmSearchActions.ang.php with 71% similarity]
ext/search_kit/ang/crmSearchTasks.module.js [moved from ext/search_kit/ang/crmSearchActions.module.js with 88% similarity]
ext/search_kit/ang/crmSearchTasks/crmSearchBatchRunner.component.js [moved from ext/search_kit/ang/crmSearchActions/crmSearchBatchRunner.component.js with 93% similarity]
ext/search_kit/ang/crmSearchTasks/crmSearchBatchRunner.html [moved from ext/search_kit/ang/crmSearchActions/crmSearchBatchRunner.html with 100% similarity]
ext/search_kit/ang/crmSearchTasks/crmSearchInput/boolean.html [moved from ext/search_kit/ang/crmSearchActions/crmSearchInput/boolean.html with 100% similarity]
ext/search_kit/ang/crmSearchTasks/crmSearchInput/crmMultiSelectDate.directive.js [moved from ext/search_kit/ang/crmSearchActions/crmSearchInput/crmMultiSelectDate.directive.js with 98% similarity]
ext/search_kit/ang/crmSearchTasks/crmSearchInput/crmSearchInput.component.js [moved from ext/search_kit/ang/crmSearchActions/crmSearchInput/crmSearchInput.component.js with 91% similarity]
ext/search_kit/ang/crmSearchTasks/crmSearchInput/crmSearchInput.html [moved from ext/search_kit/ang/crmSearchActions/crmSearchInput/crmSearchInput.html with 100% similarity]
ext/search_kit/ang/crmSearchTasks/crmSearchInput/crmSearchInputVal.component.js [moved from ext/search_kit/ang/crmSearchActions/crmSearchInput/crmSearchInputVal.component.js with 83% similarity]
ext/search_kit/ang/crmSearchTasks/crmSearchInput/date.html [moved from ext/search_kit/ang/crmSearchActions/crmSearchInput/date.html with 100% similarity]
ext/search_kit/ang/crmSearchTasks/crmSearchInput/entityRef.html [moved from ext/search_kit/ang/crmSearchActions/crmSearchInput/entityRef.html with 100% similarity]
ext/search_kit/ang/crmSearchTasks/crmSearchInput/float.html [moved from ext/search_kit/ang/crmSearchActions/crmSearchInput/float.html with 100% similarity]
ext/search_kit/ang/crmSearchTasks/crmSearchInput/integer.html [moved from ext/search_kit/ang/crmSearchActions/crmSearchInput/integer.html with 100% similarity]
ext/search_kit/ang/crmSearchTasks/crmSearchInput/select.html [moved from ext/search_kit/ang/crmSearchActions/crmSearchInput/select.html with 100% similarity]
ext/search_kit/ang/crmSearchTasks/crmSearchInput/text.html [moved from ext/search_kit/ang/crmSearchActions/crmSearchInput/text.html with 100% similarity]
ext/search_kit/ang/crmSearchTasks/crmSearchTaskDelete.ctrl.js [moved from ext/search_kit/ang/crmSearchActions/crmSearchActionDelete.ctrl.js with 76% similarity]
ext/search_kit/ang/crmSearchTasks/crmSearchTaskDelete.html [moved from ext/search_kit/ang/crmSearchActions/crmSearchActionDelete.html with 88% similarity]
ext/search_kit/ang/crmSearchTasks/crmSearchTaskUpdate.ctrl.js [moved from ext/search_kit/ang/crmSearchActions/crmSearchActionUpdate.ctrl.js with 90% similarity]
ext/search_kit/ang/crmSearchTasks/crmSearchTaskUpdate.html [moved from ext/search_kit/ang/crmSearchActions/crmSearchActionUpdate.html with 93% similarity]
ext/search_kit/ang/crmSearchTasks/crmSearchTasks.component.js [moved from ext/search_kit/ang/crmSearchActions/crmSearchActions.component.js with 89% similarity]
ext/search_kit/ang/crmSearchTasks/crmSearchTasks.html [moved from ext/search_kit/ang/crmSearchActions/crmSearchActions.html with 100% similarity]
ext/search_kit/css/crmSearchTasks.css [moved from ext/search_kit/css/crmSearchActions.css with 94% similarity]
ext/search_kit/search_kit.php

index ff34da0f2d6f19f161a525db23635fbc56a56e96..d09629433b9286f35f380e910271881820c3a26e 100644 (file)
@@ -26,17 +26,16 @@ class GetSearchTasks extends \Civi\Api4\Generic\AbstractAction {
   public function _run(\Civi\Api4\Generic\Result $result) {
     $entity = Entity::get($this->checkPermissions)->addWhere('name', '=', $this->entity)
       ->addSelect('name', 'title_plural')
-      ->setChain(['actions' => [$this->entity, 'getActions', ['where' => [['name', 'IN', ['update', 'delete']]]], 'name']])
+      ->setChain(['actions' => ['$name', 'getActions', ['where' => [['name', 'IN', ['update', 'delete']]]], 'name']])
       ->execute()->first();
 
     if (!$entity) {
       return;
     }
-    $tasks = [];
+    $tasks = [$entity['name'] => []];
 
     if (array_key_exists($entity['name'], \CRM_Export_BAO_Export::getComponents())) {
-      $tasks[] = [
-        'name' => 'export',
+      $tasks[$entity['name']]['export'] = [
         'title' => E::ts('Export %1', [1 => $entity['title_plural']]),
         'icon' => 'fa-file-excel-o',
         'crmPopup' => [
@@ -47,20 +46,20 @@ class GetSearchTasks extends \Civi\Api4\Generic\AbstractAction {
     }
 
     if (array_key_exists('update', $entity['actions'])) {
-      $tasks[] = [
-        'name' => 'update',
+      $tasks[$entity['name']]['update'] = [
+        'module' => 'crmSearchTasks',
         'title' => E::ts('Update %1', [1 => $entity['title_plural']]),
         'icon' => 'fa-save',
-        'uiDialog' => ['templateUrl' => '~/crmSearchActions/crmSearchActionUpdate.html'],
+        'uiDialog' => ['templateUrl' => '~/crmSearchTasks/crmSearchTaskUpdate.html'],
       ];
     }
 
     if (array_key_exists('delete', $entity['actions'])) {
-      $tasks[] = [
-        'name' => 'delete',
+      $tasks[$entity['name']]['delete'] = [
+        'module' => 'crmSearchTasks',
         'title' => E::ts('Delete %1', [1 => $entity['title_plural']]),
         'icon' => 'fa-trash',
-        'uiDialog' => ['templateUrl' => '~/crmSearchActions/crmSearchActionDelete.html'],
+        'uiDialog' => ['templateUrl' => '~/crmSearchTasks/crmSearchTaskDelete.html'],
       ];
     }
 
@@ -72,8 +71,7 @@ class GetSearchTasks extends \Civi\Api4\Generic\AbstractAction {
           if ($task['url'] === 'civicrm/task/pick-profile') {
             $task['title'] = E::ts('Profile Update');
           }
-          $tasks[] = [
-            'name' => 'contact.' . $id,
+          $tasks[$entity['name']]['contact.' . $id] = [
             'title' => $task['title'],
             'icon' => $task['icon'] ?? 'fa-gear',
             'crmPopup' => [
@@ -88,8 +86,7 @@ class GetSearchTasks extends \Civi\Api4\Generic\AbstractAction {
     if ($entity['name'] === 'Contribution') {
       foreach (\CRM_Contribute_Task::tasks() as $id => $task) {
         if (!empty($task['url'])) {
-          $tasks[] = [
-            'name' => 'contribution.' . $id,
+          $tasks[$entity['name']]['contribution.' . $id] = [
             'title' => $task['title'],
             'icon' => $task['icon'] ?? 'fa-gear',
             'crmPopup' => [
@@ -101,11 +98,20 @@ class GetSearchTasks extends \Civi\Api4\Generic\AbstractAction {
       }
     }
 
-    usort($tasks, function($a, $b) {
+    $null = NULL;
+    \CRM_Utils_Hook::singleton()->invoke(['tasks'], $tasks,
+      $null, $null, $null, $null, $null, 'civicrm_searchKitTasks'
+    );
+
+    usort($tasks[$entity['name']], function($a, $b) {
       return strnatcasecmp($a['title'], $b['title']);
     });
 
-    $result->exchangeArray($tasks);
+    foreach ($tasks[$entity['name']] as $name => &$task) {
+      $task['name'] = $name;
+    }
+
+    $result->exchangeArray(array_values($tasks[$entity['name']]));
   }
 
 }
index 29413f3fef714fb8e8fad0a15db25adabc334e48..a65b49531379f88ec831e5e9a2c384d6c458b54b 100644 (file)
@@ -14,6 +14,6 @@ return [
   ],
   'bundles' => ['bootstrap3'],
   'basePages' => ['civicrm/admin/search'],
-  'requires' => ['crmUi', 'crmUtil', 'ngRoute', 'ui.sortable', 'ui.bootstrap', 'api4', 'crmSearchActions', 'crmRouteBinder'],
+  'requires' => ['crmUi', 'crmUtil', 'ngRoute', 'ui.sortable', 'ui.bootstrap', 'api4', 'crmSearchTasks', 'crmRouteBinder'],
   'settingsFactory' => ['\Civi\Search\Admin', 'getAdminSettings'],
 ];
index 93407f44451be106e47781fdf2f99ae235290f99..bd2c52c2d4585a1ff2a30230014decd758b53e08 100644 (file)
@@ -10,5 +10,5 @@
       {{:: ts('Auto') }}
     </button>
   </div>
-  <crm-search-actions entity="$ctrl.savedSearch.api_entity" ids="$ctrl.selectedRows" refresh="$ctrl.refreshPage()"></crm-search-actions>
+  <crm-search-tasks entity="$ctrl.savedSearch.api_entity" ids="$ctrl.selectedRows" refresh="$ctrl.refreshPage()"></crm-search-tasks>
 </div>
index b1c65325e147c1e6691eef01418645722edf1d03..d010a2f97d6af24312033a5f6cff79a5b773a235 100644 (file)
@@ -9,7 +9,7 @@ return [
     'ang/crmSearchDisplayTable',
   ],
   'basePages' => ['civicrm/search', 'civicrm/admin/search'],
-  'requires' => ['crmSearchDisplay', 'crmUi', 'crmSearchActions', 'ui.bootstrap'],
+  'requires' => ['crmSearchDisplay', 'crmUi', 'crmSearchTasks', 'ui.bootstrap'],
   'bundles' => ['bootstrap3'],
   'exports' => [
     'crm-search-display-table' => 'E',
index e867270f728f1ae5e6b27748950011ddd4a5a6c8..9cf6fcfdbd43e0de2a939be425847a5350466f7c 100644 (file)
@@ -1,6 +1,6 @@
 <div class="crm-search-display crm-search-display-table">
   <div class="form-inline" ng-if="$ctrl.settings.actions">
-    <crm-search-actions entity="$ctrl.apiEntity" ids="$ctrl.selectedRows" refresh="$ctrl.getResults()"></crm-search-actions>
+    <crm-search-tasks entity="$ctrl.apiEntity" ids="$ctrl.selectedRows" refresh="$ctrl.getResults()"></crm-search-tasks>
   </div>
   <table>
     <thead>
similarity index 71%
rename from ext/search_kit/ang/crmSearchActions.ang.php
rename to ext/search_kit/ang/crmSearchTasks.ang.php
index 31e6290bf31227a51b93b7195a625ff969b41ef9..5604659a33e37c79e9bd6c134c3b0f140e988d92 100644 (file)
@@ -2,15 +2,15 @@
 // Search actions module - provides dropdown menu with bulk actions to take on selected rows.
 return [
   'js' => [
-    'ang/crmSearchActions.module.js',
-    'ang/crmSearchActions/*.js',
-    'ang/crmSearchActions/*/*.js',
+    'ang/crmSearchTasks.module.js',
+    'ang/crmSearchTasks/*.js',
+    'ang/crmSearchTasks/*/*.js',
   ],
   'partials' => [
-    'ang/crmSearchActions',
+    'ang/crmSearchTasks',
   ],
   'css' => [
-    'css/crmSearchActions.css',
+    'css/crmSearchTasks.css',
   ],
   'basePages' => [],
   'requires' => ['crmUi', 'crmUtil', 'dialogService', 'api4', 'checklist-model'],
similarity index 88%
rename from ext/search_kit/ang/crmSearchActions.module.js
rename to ext/search_kit/ang/crmSearchTasks.module.js
index 341e341287cf302abcbf70266338f8e89fef82ff..e1d9ce4b38da08a32d903e230accae70f03d9417 100644 (file)
@@ -2,7 +2,7 @@
   "use strict";
 
   // Declare module
-  angular.module('crmSearchActions', CRM.angRequires('crmSearchActions'))
+  angular.module('crmSearchTasks', CRM.angRequires('crmSearchTasks'))
 
     // Reformat an array of objects for compatibility with select2
     // Todo this probably belongs in core
similarity index 93%
rename from ext/search_kit/ang/crmSearchActions/crmSearchBatchRunner.component.js
rename to ext/search_kit/ang/crmSearchTasks/crmSearchBatchRunner.component.js
index ef66e518b819bae4068926105c7fcfd4e0bc5eb5..415d44d68a306c0c98d95d2a45ba4aaa5750f1e9 100644 (file)
@@ -1,7 +1,7 @@
 (function(angular, $, _) {
   "use strict";
 
-  angular.module('crmSearchActions').component('crmSearchBatchRunner', {
+  angular.module('crmSearchTasks').component('crmSearchBatchRunner', {
     bindings: {
       entity: '<',
       action: '@',
@@ -10,7 +10,7 @@
       success: '&',
       error: '&'
     },
-    templateUrl: '~/crmSearchActions/crmSearchBatchRunner.html',
+    templateUrl: '~/crmSearchTasks/crmSearchBatchRunner.html',
     controller: function($scope, $timeout, $interval, crmApi4) {
       var ts = $scope.ts = CRM.ts('org.civicrm.search_kit'),
         ctrl = this,
similarity index 98%
rename from ext/search_kit/ang/crmSearchActions/crmSearchInput/crmMultiSelectDate.directive.js
rename to ext/search_kit/ang/crmSearchTasks/crmSearchInput/crmMultiSelectDate.directive.js
index e830358fbbd293a86eae858671eb9babacf06fb9..8b97a054ae04e4aae650eeb70481fc8bf77e3708 100644 (file)
@@ -1,7 +1,7 @@
 (function(angular, $, _) {
   "use strict";
 
-  angular.module('crmSearchActions')
+  angular.module('crmSearchTasks')
     .directive('crmMultiSelectDate', function () {
       return {
         restrict: 'A',
similarity index 91%
rename from ext/search_kit/ang/crmSearchActions/crmSearchInput/crmSearchInput.component.js
rename to ext/search_kit/ang/crmSearchTasks/crmSearchInput/crmSearchInput.component.js
index 9accd4807ece7476ddf8afb4432651f040d99df2..c98d4705e5bf8270b3059c6ced3553bf0d260c29 100644 (file)
@@ -1,7 +1,7 @@
 (function(angular, $, _) {
   "use strict";
 
-  angular.module('crmSearchActions').component('crmSearchInput', {
+  angular.module('crmSearchTasks').component('crmSearchInput', {
     bindings: {
       field: '<',
       'op': '<',
@@ -9,7 +9,7 @@
       'optionKey': '<'
     },
     require: {ngModel: 'ngModel'},
-    templateUrl: '~/crmSearchActions/crmSearchInput/crmSearchInput.html',
+    templateUrl: '~/crmSearchTasks/crmSearchInput/crmSearchInput.html',
     controller: function($scope) {
       var ts = $scope.ts = CRM.ts('org.civicrm.search_kit'),
         ctrl = this;
similarity index 83%
rename from ext/search_kit/ang/crmSearchActions/crmSearchInput/crmSearchInputVal.component.js
rename to ext/search_kit/ang/crmSearchTasks/crmSearchInput/crmSearchInputVal.component.js
index f38f7a45e427ce0ddc6997d02a161ead52ef146b..cd6dfe78cd7cd34c9d9c0a5afd49ed65b5769688 100644 (file)
@@ -1,7 +1,7 @@
 (function(angular, $, _) {
   "use strict";
 
-  angular.module('crmSearchActions').component('crmSearchInputVal', {
+  angular.module('crmSearchTasks').component('crmSearchInputVal', {
     bindings: {
       field: '<',
       'multi': '<',
@@ -15,7 +15,7 @@
 
       this.$onInit = function() {
         var rendered = false;
-        ctrl.dateRanges = CRM.crmSearchActions.dateRanges;
+        ctrl.dateRanges = CRM.crmSearchTasks.dateRanges;
         ctrl.entity = ctrl.field.fk_entity || ctrl.field.entity;
 
         this.ngModel.$render = function() {
       this.getTemplate = function() {
 
         if (ctrl.field.input_type === 'Date') {
-          return '~/crmSearchActions/crmSearchInput/date.html';
+          return '~/crmSearchTasks/crmSearchInput/date.html';
         }
 
         if (ctrl.field.data_type === 'Boolean') {
-          return '~/crmSearchActions/crmSearchInput/boolean.html';
+          return '~/crmSearchTasks/crmSearchInput/boolean.html';
         }
 
         if (ctrl.field.options) {
-          return '~/crmSearchActions/crmSearchInput/select.html';
+          return '~/crmSearchTasks/crmSearchInput/select.html';
         }
 
         if (ctrl.field.fk_entity || ctrl.field.name === 'id') {
-          return '~/crmSearchActions/crmSearchInput/entityRef.html';
+          return '~/crmSearchTasks/crmSearchInput/entityRef.html';
         }
 
         if (ctrl.field.data_type === 'Integer') {
-          return '~/crmSearchActions/crmSearchInput/integer.html';
+          return '~/crmSearchTasks/crmSearchInput/integer.html';
         }
 
         if (ctrl.field.data_type === 'Float') {
-          return '~/crmSearchActions/crmSearchInput/float.html';
+          return '~/crmSearchTasks/crmSearchInput/float.html';
         }
 
-        return '~/crmSearchActions/crmSearchInput/text.html';
+        return '~/crmSearchTasks/crmSearchInput/text.html';
       };
 
       this.getFieldOptions = function() {
similarity index 76%
rename from ext/search_kit/ang/crmSearchActions/crmSearchActionDelete.ctrl.js
rename to ext/search_kit/ang/crmSearchTasks/crmSearchTaskDelete.ctrl.js
index 6e54266ab222e00eb3839062947726d02c1817fa..273a2063440683ba07d224104c6213dbcb91e16c 100644 (file)
@@ -1,7 +1,7 @@
 (function(angular, $, _) {
   "use strict";
 
-  angular.module('crmSearchActions').controller('crmSearchActionDelete', function($scope, dialogService) {
+  angular.module('crmSearchTasks').controller('crmSearchTaskDelete', function($scope, dialogService) {
     var ts = $scope.ts = CRM.ts('org.civicrm.search_kit'),
       model = $scope.model,
       ctrl = this;
@@ -9,7 +9,7 @@
     this.entityTitle = model.ids.length === 1 ? model.entityInfo.title : model.entityInfo.title_plural;
 
     this.cancel = function() {
-      dialogService.cancel('crmSearchAction');
+      dialogService.cancel('crmSearchTask');
     };
 
     this.delete = function() {
 
     this.onSuccess = function() {
       CRM.alert(ts('Successfully deleted %1 %2.', {1: model.ids.length, 2: ctrl.entityTitle}), ts('Deleted'), 'success');
-      dialogService.close('crmSearchAction');
+      dialogService.close('crmSearchTask');
     };
 
     this.onError = function() {
       CRM.alert(ts('An error occurred while attempting to delete %1 %2.', {1: model.ids.length, 2: ctrl.entityTitle}), ts('Error'), 'error');
-      dialogService.close('crmSearchAction');
+      dialogService.close('crmSearchTask');
     };
 
   });
similarity index 88%
rename from ext/search_kit/ang/crmSearchActions/crmSearchActionDelete.html
rename to ext/search_kit/ang/crmSearchTasks/crmSearchTaskDelete.html
index 7f924aa409e3073015ede12f4455654e56862c0d..74e0aec7ae4b54841ff04e2c792a2eaab191974a 100644 (file)
@@ -1,8 +1,8 @@
 <div id="bootstrap-theme">
-  <form ng-controller="crmSearchActionDelete as $ctrl">
+  <form ng-controller="crmSearchTaskDelete as $ctrl">
     <p><strong>{{:: ts('Are you sure you want to delete %1 %2?', {1: model.ids.length, 2: $ctrl.entityTitle}) }}</strong></p>
     <hr />
-    <div ng-if="$ctrl.run" class="crm-search-action-progress">
+    <div ng-if="$ctrl.run" class="crm-search-task-progress">
       <h5>{{:: ts('Deleting %1 %2...', {1: model.ids.length, 2: $ctrl.entityTitle}) }}</h5>
       <crm-search-batch-runner entity="model.entity" action="Delete" params="$ctrl.run" ids="model.ids" success="$ctrl.onSuccess()" error="$ctrl.onError()" ></crm-search-batch-runner>
     </div>
@@ -17,4 +17,5 @@
         {{:: ts('Delete %1', {1: $ctrl.entityTitle}) }}
       </button>
     </div>
+  </form>
 </div>
similarity index 90%
rename from ext/search_kit/ang/crmSearchActions/crmSearchActionUpdate.ctrl.js
rename to ext/search_kit/ang/crmSearchTasks/crmSearchTaskUpdate.ctrl.js
index d06dcf473bfaa463d5b6e17de33d5daa8342c501..bb684b03abf82671518f605f03a7bcf7a31b04e7 100644 (file)
@@ -1,7 +1,7 @@
 (function(angular, $, _) {
   "use strict";
 
-  angular.module('crmSearchActions').controller('crmSearchActionUpdate', function ($scope, $timeout, crmApi4, dialogService) {
+  angular.module('crmSearchTasks').controller('crmSearchTaskUpdate', function ($scope, $timeout, crmApi4, dialogService) {
     var ts = $scope.ts = CRM.ts('org.civicrm.search_kit'),
       model = $scope.model,
       ctrl = this;
@@ -68,7 +68,7 @@
     };
 
     this.cancel = function() {
-      dialogService.cancel('crmSearchAction');
+      dialogService.cancel('crmSearchTask');
     };
 
     this.save = function() {
 
     this.onSuccess = function() {
       CRM.alert(ts('Successfully updated %1 %2.', {1: model.ids.length, 2: ctrl.entityTitle}), ts('Saved'), 'success');
-      dialogService.close('crmSearchAction');
+      dialogService.close('crmSearchTask');
     };
 
     this.onError = function() {
       CRM.alert(ts('An error occurred while attempting to update %1 %2.', {1: model.ids.length, 2: ctrl.entityTitle}), ts('Error'), 'error');
-      dialogService.close('crmSearchAction');
+      dialogService.close('crmSearchTask');
     };
 
   });
similarity index 93%
rename from ext/search_kit/ang/crmSearchActions/crmSearchActionUpdate.html
rename to ext/search_kit/ang/crmSearchTasks/crmSearchTaskUpdate.html
index 58e5697537051bd361637fafe6281d0a1f74c428..9ae38110792efadda5f46d09c9a99311fff23cf4 100644 (file)
@@ -1,5 +1,5 @@
 <div id="bootstrap-theme">
-  <form ng-controller="crmSearchActionUpdate as $ctrl">
+  <form ng-controller="crmSearchTaskUpdate as $ctrl">
     <p><strong>{{:: ts('Update the %1 selected %2 with the following values:', {1: model.ids.length, 2: $ctrl.entityTitle}) }}</strong></p>
     <div class="form-inline" ng-repeat="clause in $ctrl.values" >
       <input class="form-control" ng-change="$ctrl.updateField($index)" ng-disabled="$ctrl.run" ng-model="clause[0]" crm-ui-select="{data: $ctrl.availableFields, allowClear: true, placeholder: 'Field'}" />
@@ -8,7 +8,7 @@
     <div class="form-inline" ng-hide="$ctrl.run">
       <input class="form-control twenty" style="width: 15em;" ng-model="$ctrl.add" ng-change="$ctrl.addField()" ng-disabled="!$ctrl.fields" ng-class="{loading: !$ctrl.fields}" crm-ui-select="{data: $ctrl.availableFields, placeholder: ts('Add Value')}"/>
     </div>
-    <div ng-if="$ctrl.run" class="crm-search-action-progress">
+    <div ng-if="$ctrl.run" class="crm-search-task-progress">
       <h5>{{:: ts('Updating %1 %2...', {1: model.ids.length, 2: $ctrl.entityTitle}) }}</h5>
       <crm-search-batch-runner entity="model.entity" action="Update" params="$ctrl.run" ids="model.ids" success="$ctrl.onSuccess()" error="$ctrl.onError()" ></crm-search-batch-runner>
     </div>
similarity index 89%
rename from ext/search_kit/ang/crmSearchActions/crmSearchActions.component.js
rename to ext/search_kit/ang/crmSearchTasks/crmSearchTasks.component.js
index f278c00e3ad337f8d1992d3fa61154fe4b6b1edb..0e1ae4a1a5ce3ded66bb0836c3aa3509d876a192 100644 (file)
@@ -1,13 +1,13 @@
 (function(angular, $, _) {
   "use strict";
 
-  angular.module('crmSearchActions').component('crmSearchActions', {
+  angular.module('crmSearchTasks').component('crmSearchTasks', {
     bindings: {
       entity: '<',
       refresh: '&',
       ids: '<'
     },
-    templateUrl: '~/crmSearchActions/crmSearchActions.html',
+    templateUrl: '~/crmSearchTasks/crmSearchTasks.html',
     controller: function($scope, crmApi4, dialogService) {
       var ts = $scope.ts = CRM.ts('org.civicrm.search_kit'),
         ctrl = this,
@@ -58,7 +58,7 @@
             autoOpen: false,
             title: action.title
           });
-          dialogService.open('crmSearchAction', action.uiDialog.templateUrl, data, options)
+          dialogService.open('crmSearchTask', action.uiDialog.templateUrl, data, options)
             .then(ctrl.refresh);
         }
       };
similarity index 94%
rename from ext/search_kit/css/crmSearchActions.css
rename to ext/search_kit/css/crmSearchTasks.css
index aab0e8c9dca1ff3487d870acb3a5f64e5e6a430c..bdb38fbc2d269a4f620c2cd2fc71417dede0778d 100644 (file)
@@ -1,4 +1,4 @@
-.crm-search-action-progress {
+.crm-search-task-progress {
   padding: 10px;
   margin-top: 10px;
   border: 1px solid lightgrey;
index 170a4a55e0fd6f370bb726ef6ace0f9ef443f945..6c94f751a7368004ffd9cc3f843c9365a7174b90 100644 (file)
@@ -45,6 +45,21 @@ function search_kit_civicrm_managed(&$entities) {
  */
 function search_kit_civicrm_angularModules(&$angularModules) {
   _search_kit_civix_civicrm_angularModules($angularModules);
+  // Fetch all search tasks provided by other modules and add them as crmSearchTasks dependencies
+  $tasks = $dependencies = [];
+  $null = NULL;
+  CRM_Utils_Hook::singleton()->invoke(['tasks'], $tasks,
+    $null, $null, $null, $null, $null, 'civicrm_searchKitTasks'
+  );
+  foreach ($tasks as $entityTasks) {
+    foreach ($entityTasks as $task) {
+      if (isset($task['module']) && $task['module'] !== 'crmSearchTasks' &&
+        !in_array($task['module'], $angularModules['crmSearchTasks']['requires'], TRUE)
+      ) {
+        $angularModules['crmSearchTasks']['requires'][] = $task['module'];
+      }
+    }
+  }
 }
 
 /**