From 47f5294896a139272d5e9832a37012aaa3bebdc2 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Wed, 22 Dec 2021 09:30:25 -0500 Subject: [PATCH] SearchKit - Allow more link actions --- .../Action/SearchDisplay/AbstractRunAction.php | 5 +++-- ext/search_kit/Civi/Search/Display.php | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/ext/search_kit/Civi/Api4/Action/SearchDisplay/AbstractRunAction.php b/ext/search_kit/Civi/Api4/Action/SearchDisplay/AbstractRunAction.php index d71beeddbf..895836ed5b 100644 --- a/ext/search_kit/Civi/Api4/Action/SearchDisplay/AbstractRunAction.php +++ b/ext/search_kit/Civi/Api4/Action/SearchDisplay/AbstractRunAction.php @@ -404,12 +404,13 @@ abstract class AbstractRunAction extends \Civi\Api4\Generic\AbstractAction { } // Check access for edit/update links // (presumably if a record is shown in SearchKit the user already has view access, and the check is expensive) - if ($path && isset($data) && $link['action'] !== 'view') { + if ($path && isset($data) && !in_array($link['action'], ['view', 'preview'], TRUE)) { $id = $data[$prefix . $idKey] ?? NULL; $id = is_array($id) ? $id[$index] ?? NULL : $id; if ($id) { $access = civicrm_api4($link['entity'], 'checkAccess', [ - 'action' => $link['action'], + // Fudge links with funny action names to check 'update' + 'action' => $link['action'] === 'delete' ? 'delete' : 'update', 'values' => [ $idField => $id, ], diff --git a/ext/search_kit/Civi/Search/Display.php b/ext/search_kit/Civi/Search/Display.php index 3268807f43..4f9e3cce22 100644 --- a/ext/search_kit/Civi/Search/Display.php +++ b/ext/search_kit/Civi/Search/Display.php @@ -78,6 +78,14 @@ class Display { // Contacts and cases are too cumbersome to view in a popup 'target' => in_array($entity, ['Contact', 'Case']) ? '_blank' : 'crm-popup', ], + 'preview' => [ + 'action' => 'preview', + 'entity' => $entity, + 'text' => E::ts('Preview %1', $label), + 'icon' => 'fa-eye', + 'style' => 'default', + 'target' => 'crm-popup', + ], 'update' => [ 'action' => 'update', 'entity' => $entity, @@ -87,6 +95,14 @@ class Display { // Contacts and cases are too cumbersome to edit in a popup 'target' => in_array($entity, ['Contact', 'Case']) ? '_blank' : 'crm-popup', ], + 'move' => [ + 'action' => 'move', + 'entity' => $entity, + 'text' => E::ts('Move %1', $label), + 'icon' => 'fa-random', + 'style' => 'default', + 'target' => 'crm-popup', + ], 'delete' => [ 'action' => 'delete', 'entity' => $entity, -- 2.25.1