Skip to content

Commit

Permalink
SearchKit - Make contribution tasks available as actions
Browse files Browse the repository at this point in the history
So far there is only one action (Send Receipt) available,
and it only works for contributions with status=Completed.
SearchKit doesn't yet respect that limitation and shows the action for every record.
  • Loading branch information
colemanw committed Apr 8, 2021
1 parent a04a742 commit dd87478
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
7 changes: 4 additions & 3 deletions CRM/Contribute/Task.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,9 @@ public static function tasks() {
'result' => FALSE,
'title_single_mode' => ts('Send Receipt'),
'name' => ts('Send Receipt'),
'is_support_standalone' => TRUE,
'url' => 'civicrm/contribute/task?reset=1&task=receipt',
'key' => 'receipt',
'icon' => 'fa-envelope-o',
'filters' => ['contribution_status_id' => [CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Completed')]],
'is_single_mode' => TRUE,
],
Expand Down Expand Up @@ -151,8 +152,8 @@ public static function getContextualLinks($row) {
}
}
}
$tasks[$key]['url'] = 'civicrm/contribute/task';
$tasks[$key]['qs'] = ['reset' => 1, 'id' => $row['contribution_id'], 'task' => $task['key']];
$tasks[$key]['url'] = $task['url'];
$tasks[$key]['qs'] = ['id' => $row['contribution_id']];
$tasks[$key]['title'] = $task['title_single_mode'] ?? $task['title'];
}
return $tasks;
Expand Down
20 changes: 18 additions & 2 deletions ext/search/Civi/Api4/Action/SearchDisplay/GetSearchTasks.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function _run(\Civi\Api4\Generic\Result $result) {
'icon' => 'fa-file-excel-o',
'crmPopup' => [
'path' => "'civicrm/export/standalone'",
'query' => "{entity: '{$entity['name']}', id: ids.join(',')}",
'query' => "{reset: 1, entity: '{$entity['name']}', id: ids.join(',')}",
],
];
}
Expand Down Expand Up @@ -78,7 +78,23 @@ public function _run(\Civi\Api4\Generic\Result $result) {
'icon' => $task['icon'] ?? 'fa-gear',
'crmPopup' => [
'path' => "'{$task['url']}'",
'query' => "{cids: ids.join(',')}",
'query' => "{reset: 1, cids: ids.join(',')}",
],
];
}
}
}

if ($entity['name'] === 'Contribution') {
foreach (\CRM_Contribute_Task::tasks() as $id => $task) {
if (!empty($task['url'])) {
$tasks[] = [
'name' => 'contribution.' . $id,
'title' => $task['title'],
'icon' => $task['icon'] ?? 'fa-gear',
'crmPopup' => [
'path' => "'{$task['url']}'",
'query' => "{id: ids.join(',')}",
],
];
}
Expand Down

0 comments on commit dd87478

Please sign in to comment.