From 696fdeb084781e5da12a6b7142b8d8ec003a87f0 Mon Sep 17 00:00:00 2001 From: Kurund Jalmi Date: Tue, 26 Sep 2023 15:27:42 +0100 Subject: [PATCH] move process task to afform --- ext/afform/core/afform.php | 16 ++++++++++++++++ ext/afform/core/ang/afSearchTasks.ang.php | 15 +++++++++++++++ ext/afform/core/ang/afSearchTasks.module.js | 7 +++++++ .../afformSubmissionProcessTask.ctrl..js} | 4 ++-- .../afformSubmissionProcessTask.html} | 4 ++-- .../Api4/Action/SearchDisplay/GetSearchTasks.php | 7 ------- 6 files changed, 42 insertions(+), 11 deletions(-) create mode 100644 ext/afform/core/ang/afSearchTasks.ang.php create mode 100644 ext/afform/core/ang/afSearchTasks.module.js rename ext/{search_kit/ang/crmSearchTasks/crmSearchTaskProcess.ctrl.js => afform/core/ang/afSearchTasks/afformSubmissionProcessTask.ctrl..js} (89%) rename ext/{search_kit/ang/crmSearchTasks/crmSearchTaskProcess.html => afform/core/ang/afSearchTasks/afformSubmissionProcessTask.html} (69%) diff --git a/ext/afform/core/afform.php b/ext/afform/core/afform.php index 1cb373eb4e..0725a2bd19 100644 --- a/ext/afform/core/afform.php +++ b/ext/afform/core/afform.php @@ -645,3 +645,19 @@ function afform_shortcode_content($content, $atts, $args, $context) { } return $content; } + +/** + * Implements hook_civicrm_searchKitTasks(). + * + * @param array[] $tasks + * @param bool $checkPermissions + * @param int|null $userID + */ +function afform_civicrm_searchKitTasks(array &$tasks, bool $checkPermissions, ?int $userID) { + $tasks['AfformSubmission']['process'] = [ + 'module' => 'afSearchTasks', + 'title' => E::ts('Process Submissions'), + 'icon' => 'fa-check-square-o', + 'uiDialog' => ['templateUrl' => '~/afSearchTasks/afformSubmissionProcessTask.html'], + ]; +} diff --git a/ext/afform/core/ang/afSearchTasks.ang.php b/ext/afform/core/ang/afSearchTasks.ang.php new file mode 100644 index 0000000000..47d50ff0d0 --- /dev/null +++ b/ext/afform/core/ang/afSearchTasks.ang.php @@ -0,0 +1,15 @@ + [ + 'ang/afSearchTasks.module.js', + 'ang/afSearchTasks/*.js', + 'ang/afSearchTasks/*/*.js', + ], + 'partials' => [ + 'ang/afSearchTasks', + ], + 'css' => [], + 'settings' => [], + 'requires' => [], +]; diff --git a/ext/afform/core/ang/afSearchTasks.module.js b/ext/afform/core/ang/afSearchTasks.module.js new file mode 100644 index 0000000000..35a07ee448 --- /dev/null +++ b/ext/afform/core/ang/afSearchTasks.module.js @@ -0,0 +1,7 @@ +(function(angular, $, _) { + "use strict"; + + // Declare module + angular.module('afSearchTasks', CRM.angRequires('afSearchTasks')); + +})(angular, CRM.$, CRM._); diff --git a/ext/search_kit/ang/crmSearchTasks/crmSearchTaskProcess.ctrl.js b/ext/afform/core/ang/afSearchTasks/afformSubmissionProcessTask.ctrl..js similarity index 89% rename from ext/search_kit/ang/crmSearchTasks/crmSearchTaskProcess.ctrl.js rename to ext/afform/core/ang/afSearchTasks/afformSubmissionProcessTask.ctrl..js index 5270a9f286..8ad6d9e3b1 100644 --- a/ext/search_kit/ang/crmSearchTasks/crmSearchTaskProcess.ctrl.js +++ b/ext/afform/core/ang/afSearchTasks/afformSubmissionProcessTask.ctrl..js @@ -1,8 +1,8 @@ (function(angular, $, _) { "use strict"; - angular.module('crmSearchTasks').controller('crmSearchTaskProcess', function ($scope, $timeout, crmApi4, searchTaskBaseTrait) { - var ts = $scope.ts = CRM.ts('org.civicrm.search_kit'), + angular.module('afSearchTasks').controller('afformSubmissionProcessTask', function ($scope, $timeout, crmApi4, searchTaskBaseTrait) { + var ts = $scope.ts = CRM.ts('org.civicrm.afform'), // Combine this controller with model properties (ids, entity, entityInfo) and searchTaskBaseTrait ctrl = angular.extend(this, $scope.model, searchTaskBaseTrait); diff --git a/ext/search_kit/ang/crmSearchTasks/crmSearchTaskProcess.html b/ext/afform/core/ang/afSearchTasks/afformSubmissionProcessTask.html similarity index 69% rename from ext/search_kit/ang/crmSearchTasks/crmSearchTaskProcess.html rename to ext/afform/core/ang/afSearchTasks/afformSubmissionProcessTask.html index 4ca8fbe3ba..8c34126691 100644 --- a/ext/search_kit/ang/crmSearchTasks/crmSearchTaskProcess.html +++ b/ext/afform/core/ang/afSearchTasks/afformSubmissionProcessTask.html @@ -1,7 +1,7 @@
-
+

{{:: ts('Process the %1 selected %2 submission(s):', {1: model.ids.length, 2: $ctrl.entityTitle}) }}

- +
diff --git a/ext/search_kit/Civi/Api4/Action/SearchDisplay/GetSearchTasks.php b/ext/search_kit/Civi/Api4/Action/SearchDisplay/GetSearchTasks.php index bf36ac6476..56595b207a 100644 --- a/ext/search_kit/Civi/Api4/Action/SearchDisplay/GetSearchTasks.php +++ b/ext/search_kit/Civi/Api4/Action/SearchDisplay/GetSearchTasks.php @@ -71,13 +71,6 @@ class GetSearchTasks extends \Civi\Api4\Generic\AbstractAction { 'number' => '>= 0', ]; - $tasks[$entity['name']]['process'] = [ - 'module' => 'crmSearchTasks', - 'title' => E::ts('Process Submissions'), - 'icon' => 'fa-check-square-o', - 'uiDialog' => ['templateUrl' => '~/crmSearchTasks/crmSearchTaskProcess.html'], - ]; - if (array_key_exists('update', $entity['actions'])) { $tasks[$entity['name']]['update'] = [ 'module' => 'crmSearchTasks', -- 2.25.1