From: colemanw Date: Wed, 12 Jul 2023 01:22:58 +0000 (-0400) Subject: SearchKit - Add configuration to select tasks as links X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=61466cd5a973def1b8603d2faf479ea780b6d2bd;p=civicrm-core.git SearchKit - Add configuration to select tasks as links --- diff --git a/ext/search_kit/Civi/Api4/Action/SearchDisplay/GetSearchTasks.php b/ext/search_kit/Civi/Api4/Action/SearchDisplay/GetSearchTasks.php index c8c36f386a..9b04aaeeb2 100644 --- a/ext/search_kit/Civi/Api4/Action/SearchDisplay/GetSearchTasks.php +++ b/ext/search_kit/Civi/Api4/Action/SearchDisplay/GetSearchTasks.php @@ -269,7 +269,7 @@ class GetSearchTasks extends \Civi\Api4\Generic\AbstractAction { 'name' => 'icon', ], [ - 'number' => 'icon', + 'name' => 'number', ], [ 'name' => 'apiBatch', diff --git a/ext/search_kit/ang/crmSearchAdmin/crmSearchAdminDisplay.component.js b/ext/search_kit/ang/crmSearchAdmin/crmSearchAdminDisplay.component.js index e6e9bbdc06..f41155596e 100644 --- a/ext/search_kit/ang/crmSearchAdmin/crmSearchAdminDisplay.component.js +++ b/ext/search_kit/ang/crmSearchAdmin/crmSearchAdminDisplay.component.js @@ -249,6 +249,24 @@ this.getLinks = function(columnKey) { if (!ctrl.links) { ctrl.links = {'*': ctrl.crmSearchAdmin.buildLinks(), '0': []}; + ctrl.links[''] = _.filter(ctrl.links['*'], {join: ''}); + searchMeta.getSearchTasks(ctrl.savedSearch.api_entity).then(function(tasks) { + _.each(tasks, function (task) { + if (task.number === '> 0' || task.number === '=== 1') { + var link = { + text: task.title, + icon: task.icon, + task: task.name, + entity: ctrl.savedSearch.api_entity, + target: 'crm-popup', + join: '', + style: task.name === 'delete' ? 'danger' : 'default' + }; + ctrl.links['*'].push(link); + ctrl.links[''].push(link); + } + }); + }); } if (!columnKey) { return ctrl.links['*']; diff --git a/ext/search_kit/ang/crmSearchAdmin/crmSearchAdminLinkGroup.component.js b/ext/search_kit/ang/crmSearchAdmin/crmSearchAdminLinkGroup.component.js index 7d2c2be802..c766a4e86b 100644 --- a/ext/search_kit/ang/crmSearchAdmin/crmSearchAdminLinkGroup.component.js +++ b/ext/search_kit/ang/crmSearchAdmin/crmSearchAdminLinkGroup.component.js @@ -15,7 +15,7 @@ controller: function ($scope, $element, $timeout, searchMeta) { var ts = $scope.ts = CRM.ts('org.civicrm.search_kit'), ctrl = this, - linkProps = ['path', 'entity', 'action', 'join', 'target', 'icon', 'text', 'style', 'condition']; + linkProps = ['path', 'task', 'entity', 'action', 'join', 'target', 'icon', 'text', 'style', 'condition']; ctrl.permissionOperators = [ {key: '=', value: ts('Has')}, @@ -98,7 +98,7 @@ path: 'civicrm/' }); var defaultLinks = _.filter(ctrl.links, function(link) { - return !link.join; + return link.action && !link.join; }); _.each(ctrl.group, function(item) { setDefaults(item, item); diff --git a/ext/search_kit/ang/crmSearchAdmin/crmSearchAdminLinkSelect.component.js b/ext/search_kit/ang/crmSearchAdmin/crmSearchAdminLinkSelect.component.js index 8291b3af39..1c1f5f2487 100644 --- a/ext/search_kit/ang/crmSearchAdmin/crmSearchAdminLinkSelect.component.js +++ b/ext/search_kit/ang/crmSearchAdmin/crmSearchAdminLinkSelect.component.js @@ -32,7 +32,14 @@ }; this.getLink = function() { - return _.findWhere(ctrl.links, {action: ctrl.link.action, join: ctrl.link.join, entity: ctrl.link.entity}); + return _.find(ctrl.links, function(link) { + if (ctrl.link.task && link.task === ctrl.link.task && link.entity === ctrl.link.entity) { + return true; + } else if (ctrl.link.action && link.action === ctrl.link.action && link.entity === ctrl.link.entity && link.join == ctrl.link.join) { + return true; + } + return false; + }); }; } diff --git a/ext/search_kit/ang/crmSearchAdmin/crmSearchAdminLinkSelect.html b/ext/search_kit/ang/crmSearchAdmin/crmSearchAdminLinkSelect.html index 1fa7efac6a..b7d2b16870 100644 --- a/ext/search_kit/ang/crmSearchAdmin/crmSearchAdminLinkSelect.html +++ b/ext/search_kit/ang/crmSearchAdmin/crmSearchAdminLinkSelect.html @@ -1,22 +1,26 @@
- -
- -
- + diff --git a/ext/search_kit/ang/crmSearchAdmin/displays/colType/field.html b/ext/search_kit/ang/crmSearchAdmin/displays/colType/field.html index 3714137f3b..27aee9a6bb 100644 --- a/ext/search_kit/ang/crmSearchAdmin/displays/colType/field.html +++ b/ext/search_kit/ang/crmSearchAdmin/displays/colType/field.html @@ -20,7 +20,7 @@ - +