From 1cd76519840197268239e65fb33cee170ba73d54 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Sun, 9 Jan 2022 20:24:12 -0500 Subject: [PATCH] CiviGrant - Use SearchKit for contact summary tab --- ext/civigrant/ang/afsearchGrants.aff.html | 9 ++ ext/civigrant/ang/afsearchGrants.aff.json | 7 + ext/civigrant/civigrant.php | 20 --- ext/civigrant/info.xml | 4 + .../SavedSearch_CiviGrant_Summary.mgd.php | 153 ++++++++++++++++++ 5 files changed, 173 insertions(+), 20 deletions(-) create mode 100644 ext/civigrant/ang/afsearchGrants.aff.html create mode 100644 ext/civigrant/ang/afsearchGrants.aff.json create mode 100644 ext/civigrant/managed/SavedSearch_CiviGrant_Summary.mgd.php diff --git a/ext/civigrant/ang/afsearchGrants.aff.html b/ext/civigrant/ang/afsearchGrants.aff.html new file mode 100644 index 0000000000..afedc03b5e --- /dev/null +++ b/ext/civigrant/ang/afsearchGrants.aff.html @@ -0,0 +1,9 @@ +
+ + + {{:: ts('Add Grant') }} + +
+
+ +
diff --git a/ext/civigrant/ang/afsearchGrants.aff.json b/ext/civigrant/ang/afsearchGrants.aff.json new file mode 100644 index 0000000000..093d18d9f9 --- /dev/null +++ b/ext/civigrant/ang/afsearchGrants.aff.json @@ -0,0 +1,7 @@ +{ + "type": "search", + "title": "Grants", + "contact_summary": "tab", + "server_route": "", + "permission": "access CiviGrant" +} diff --git a/ext/civigrant/civigrant.php b/ext/civigrant/civigrant.php index 5a4e1fdf78..12b5bccbd3 100644 --- a/ext/civigrant/civigrant.php +++ b/ext/civigrant/civigrant.php @@ -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(). * diff --git a/ext/civigrant/info.xml b/ext/civigrant/info.xml index bdce94b6f6..351ecff925 100644 --- a/ext/civigrant/info.xml +++ b/ext/civigrant/info.xml @@ -19,6 +19,10 @@ 5.47 CiviGrant was originally a core component before migrating to an extension + + org.civicrm.afform + org.civicrm.search_kit + diff --git a/ext/civigrant/managed/SavedSearch_CiviGrant_Summary.mgd.php b/ext/civigrant/managed/SavedSearch_CiviGrant_Summary.mgd.php new file mode 100644 index 0000000000..1b71072ef1 --- /dev/null +++ b/ext/civigrant/managed/SavedSearch_CiviGrant_Summary.mgd.php @@ -0,0 +1,153 @@ + '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, + ], + ], + ], +]; -- 2.25.1