SearchKit - Allow more link actions
authorColeman Watts <coleman@civicrm.org>
Wed, 22 Dec 2021 14:30:25 +0000 (09:30 -0500)
committerColeman Watts <coleman@civicrm.org>
Wed, 22 Dec 2021 14:30:25 +0000 (09:30 -0500)
ext/search_kit/Civi/Api4/Action/SearchDisplay/AbstractRunAction.php
ext/search_kit/Civi/Search/Display.php

index d71beeddbf78ce4a147fa6d93248840782eb3bb2..895836ed5bf3f27badad9447bf0db5d13180c120 100644 (file)
@@ -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,
             ],
index 3268807f43dc072ffe630b847c5f275128ce98ed..4f9e3cce225b1e9ab76b2cef878caf50577e5cb7 100644 (file)
@@ -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,