CiviGrant - Use SearchKit for contact summary tab
authorColeman Watts <coleman@civicrm.org>
Mon, 10 Jan 2022 01:24:12 +0000 (20:24 -0500)
committerColeman Watts <coleman@civicrm.org>
Tue, 11 Jan 2022 02:24:50 +0000 (21:24 -0500)
ext/civigrant/ang/afsearchGrants.aff.html [new file with mode: 0644]
ext/civigrant/ang/afsearchGrants.aff.json [new file with mode: 0644]
ext/civigrant/civigrant.php
ext/civigrant/info.xml
ext/civigrant/managed/SavedSearch_CiviGrant_Summary.mgd.php [new file with mode: 0644]

diff --git a/ext/civigrant/ang/afsearchGrants.aff.html b/ext/civigrant/ang/afsearchGrants.aff.html
new file mode 100644 (file)
index 0000000..afedc03
--- /dev/null
@@ -0,0 +1,9 @@
+<div class="btn-group">
+  <a class="btn btn-primary crm-popup" ng-href="{{ crmUrl('civicrm/grant/add', {reset: 1, action: 'add', context: 'grant', cid: options.contact_id}) }}">
+    <i class="crm-i fa-plus-circle"></i>
+    {{:: ts('Add Grant') }}
+  </a>
+</div>
+<div af-fieldset="">
+  <crm-search-display-table search-name="CiviGrant_Summary" display-name="Grant_Tab" filters="{'contact_id': options.contact_id}"></crm-search-display-table>
+</div>
diff --git a/ext/civigrant/ang/afsearchGrants.aff.json b/ext/civigrant/ang/afsearchGrants.aff.json
new file mode 100644 (file)
index 0000000..093d18d
--- /dev/null
@@ -0,0 +1,7 @@
+{
+    "type": "search",
+    "title": "Grants",
+    "contact_summary": "tab",
+    "server_route": "",
+    "permission": "access CiviGrant"
+}
index 5a4e1fdf7874d026ef55d139aab310cd0deb1f83..12b5bccbd32b7b7a00ca6b26454b872b27d6ea06 100644 (file)
@@ -68,26 +68,6 @@ function civigrant_civicrm_permission(&$permissions) {
   ];
 }
 
-/**
- * Implements hook_civicrm_tabSet().
- *
- * Add grants tab to contact summary screen.
- */
-function civigrant_civicrm_tabSet($tabSetName, &$tabs, $context) {
-  if ($tabSetName === 'civicrm/contact/view' && !empty($context['contact_id'])) {
-    $cid = $context['contact_id'];
-    $tabs[] = [
-      'id' => 'grant',
-      'url' => CRM_Utils_System::url("civicrm/contact/view/grant", ['reset' => 1, 'cid' => $cid]),
-      'title' => E::ts('Grants'),
-      'weight' => 60,
-      'count' => CRM_Grant_BAO_Grant::getContactGrantCount($cid),
-      'class' => 'livePage',
-      'icon' => 'crm-i fa-money',
-    ];
-  }
-}
-
 /**
  * Implements hook_civicrm_queryObjects().
  *
index bdce94b6f65a56f0c24f526e9ea4240184114d99..351ecff9253b283aa2cb6d25162ffb67236f31b9 100644 (file)
     <ver>5.47</ver>
   </compatibility>
   <comments>CiviGrant was originally a core component before migrating to an extension</comments>
+  <requires>
+    <ext>org.civicrm.afform</ext>
+    <ext>org.civicrm.search_kit</ext>
+  </requires>
   <classloader>
     <psr0 prefix="CRM_" path=""/>
     <psr4 prefix="Civi\" path="Civi"/>
diff --git a/ext/civigrant/managed/SavedSearch_CiviGrant_Summary.mgd.php b/ext/civigrant/managed/SavedSearch_CiviGrant_Summary.mgd.php
new file mode 100644 (file)
index 0000000..1b71072
--- /dev/null
@@ -0,0 +1,153 @@
+<?php
+return [
+  [
+    'name' => 'SavedSearch_CiviGrant_Summary',
+    'entity' => 'SavedSearch',
+    'cleanup' => 'unused',
+    'update' => 'unmodified',
+    'params' => [
+      'version' => 4,
+      'values' => [
+        'name' => 'CiviGrant_Summary',
+        'label' => 'CiviGrant Summary',
+        'form_values' => NULL,
+        'search_custom_id' => NULL,
+        'api_entity' => 'Grant',
+        'api_params' => [
+          'version' => 4,
+          'select' => [
+            'status_id:label',
+            'grant_type_id:label',
+            'amount_requested',
+            'amount_granted',
+            'application_received_date',
+            'grant_report_received',
+            'money_transfer_date',
+          ],
+          'orderBy' => [],
+          'where' => [],
+          'groupBy' => [],
+          'join' => [],
+          'having' => [],
+        ],
+        'expires_date' => NULL,
+        'description' => NULL,
+        'mapping_id' => NULL,
+      ],
+    ],
+  ],
+  [
+    'name' => 'SavedSearch_CiviGrant_Summary_SearchDisplay_Grant_Tab',
+    'entity' => 'SearchDisplay',
+    'cleanup' => 'unused',
+    'update' => 'unmodified',
+    'params' => [
+      'version' => 4,
+      'values' => [
+        'name' => 'Grant_Tab',
+        'label' => 'Grant Tab',
+        'saved_search_id.name' => 'CiviGrant_Summary',
+        'type' => 'table',
+        'settings' => [
+          'actions' => FALSE,
+          'limit' => 50,
+          'classes' => [
+            'table',
+            'table-striped',
+          ],
+          'pager' => [
+            'show_count' => TRUE,
+            'expose_limit' => TRUE,
+          ],
+          'sort' => [],
+          'columns' => [
+            [
+              'type' => 'field',
+              'key' => 'status_id:label',
+              'dataType' => 'Integer',
+              'label' => 'Status',
+              'sortable' => TRUE,
+            ],
+            [
+              'type' => 'field',
+              'key' => 'grant_type_id:label',
+              'dataType' => 'Integer',
+              'label' => 'Type',
+              'sortable' => TRUE,
+            ],
+            [
+              'type' => 'field',
+              'key' => 'amount_requested',
+              'dataType' => 'Money',
+              'label' => 'Requested',
+              'sortable' => TRUE,
+            ],
+            [
+              'type' => 'field',
+              'key' => 'amount_granted',
+              'dataType' => 'Money',
+              'label' => 'Granted',
+              'sortable' => TRUE,
+            ],
+            [
+              'type' => 'field',
+              'key' => 'application_received_date',
+              'dataType' => 'Date',
+              'label' => 'Application received',
+              'sortable' => TRUE,
+            ],
+            [
+              'type' => 'field',
+              'key' => 'grant_report_received',
+              'dataType' => 'Boolean',
+              'label' => 'Report received',
+              'sortable' => TRUE,
+            ],
+            [
+              'type' => 'field',
+              'key' => 'money_transfer_date',
+              'dataType' => 'Date',
+              'label' => 'Money transferred',
+              'sortable' => TRUE,
+            ],
+            [
+              'size' => 'btn-xs',
+              'links' => [
+                [
+                  'entity' => 'Grant',
+                  'action' => 'view',
+                  'join' => '',
+                  'target' => 'crm-popup',
+                  'icon' => 'fa-external-link',
+                  'text' => 'View',
+                  'style' => 'default',
+                ],
+                [
+                  'entity' => 'Grant',
+                  'action' => 'update',
+                  'join' => '',
+                  'target' => 'crm-popup',
+                  'icon' => 'fa-pencil',
+                  'text' => 'Edit',
+                  'style' => 'default',
+                ],
+                [
+                  'entity' => 'Grant',
+                  'action' => 'delete',
+                  'join' => '',
+                  'target' => 'crm-popup',
+                  'icon' => 'fa-trash',
+                  'text' => 'Delete',
+                  'style' => 'danger',
+                ],
+              ],
+              'type' => 'buttons',
+              'alignment' => 'text-right',
+            ],
+          ],
+        ],
+        'acl_bypass' => FALSE,
+      ],
+    ],
+  ],
+];