Skip to content

Commit

Permalink
Merge pull request #29570 from guyiac/events-greenleaf
Browse files Browse the repository at this point in the history
Replace Contact Summary Events tab with Admin UI Search Display and Form
  • Loading branch information
colemanw authored Mar 3, 2024
2 parents be52927 + 9dc35dc commit 5a526df
Show file tree
Hide file tree
Showing 6 changed files with 336 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CRM/Event/DAO/Participant.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* Generated from xml/schema/CRM/Event/Participant.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
* (GenCodeChecksum:68158e9be20e798236ea9fb43036ebad)
* (GenCodeChecksum:020be0037929bdfd423d5bfcc6141601)
*/

/**
Expand Down Expand Up @@ -47,6 +47,7 @@ class CRM_Event_DAO_Participant extends CRM_Core_DAO {
'add' => 'civicrm/participant/add?action=add&context=standalone&reset=1',
'view' => 'civicrm/contact/view/participant?id=[id]&cid=[contact_id]&action=view&reset=1',
'update' => 'civicrm/contact/view/participant?id=[id]&cid=[contact_id]&action=update&reset=1',
'detach' => 'civicrm/event/selfsvcupdate?reset=1&pid=[id]&is_backoffice=1',
'delete' => 'civicrm/participant/delete?id=[id]&reset=1',
];

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php
/*
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC. All rights reserved. |
| |
| This work is published under the GNU AGPLv3 license with some |
| permitted exceptions and without any warranty. For full license |
| and copyright information, see https://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/

namespace Civi\Api4\Service\Links;

use Civi\API\Event\RespondEvent;

/**
* @service
* @internal
*/
class ParticipantLinksProvider extends \Civi\Core\Service\AutoSubscriber {
use LinksProviderTrait;

public static function getSubscribedEvents(): array {
return [
'civi.api.respond' => ['alterParticipantLinksResult', -50],
];
}

/**
* Customize event participant links
*
* @param \Civi\API\Event\RespondEvent $e
* @return void
* @throws \CRM_Core_Exception
*/
public static function alterParticipantLinksResult(RespondEvent $e): void {
$request = $e->getApiRequest();
if ($request['version'] == 4 && $request->getEntityName() === 'Participant' && is_a($request, '\Civi\Api4\Action\GetLinks')) {
$links = (array) $e->getResponse();
$addLinkIndex = self::getActionIndex($links, 'add');
$transferLinkIndex = self::getActionIndex($links, 'detach');
if (isset($transferLinkIndex)) {
if ($request->getCheckPermissions() && !\CRM_Core_Permission::check('edit event participants')) {
unset($links[$transferLinkIndex]);
}
}
if (isset($addLinkIndex)) {
$contactId = $request->getValue('contact_id');
if ($request->getCheckPermissions() && !\CRM_Core_Permission::check('edit event participants')) {
unset($links[$addLinkIndex]);
}
elseif ($contactId) {
// Update add link appropriate to the context of viewing a single contact
$links[$addLinkIndex]['icon'] = 'fa-ticket';
$links[$addLinkIndex]['text'] = ts('Register for Event');
$links[$addLinkIndex]['path'] = "civicrm/contact/view/participant?reset=1&action=add&cid=$contactId&context=participant";
if ($request->getExpandMultiple() && \CRM_Core_Config::isEnabledBackOfficeCreditCardPayments()) {
// 2nd add link for credit card registrations
$ccLink = $links[$addLinkIndex];
$ccLink['text'] = ts('Submit Credit Card Event Registration');
$ccLink['icon'] = 'fa-credit-card';
$ccLink['path'] = "civicrm/contact/view/participant?reset=1&action=add&cid=$contactId&context=participant&mode=live";
$links[] = $ccLink;
}
}
}

$e->getResponse()->exchangeArray(array_values($links));
}
}

}
3 changes: 3 additions & 0 deletions ext/civicrm_admin_ui/ang/afsearchTabParticipant.aff.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div af-fieldset="">
<crm-search-display-table search-name="Contact_Summary_Events" display-name="Contact_Summary_Events_Tab" filters="{contact_id: options.contact_id}"></crm-search-display-table>
</div>
16 changes: 16 additions & 0 deletions ext/civicrm_admin_ui/ang/afsearchTabParticipant.aff.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
use CRM_CivicrmAdminUi_ExtensionUtil as E;

return [
'type' => 'search',
'title' => E::ts('Events'),
'placement' => [
'contact_summary_tab',
],
'summary_weight' => 40,
'icon' => 'fa-calendar',
'permission' => [
'access CiviCRM',
'access CiviEvent',
],
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,242 @@
<?php
use CRM_CivicrmAdminUi_ExtensionUtil as E;

return [
[
'name' => 'SavedSearch_Contact_Summary_Events',
'entity' => 'SavedSearch',
'cleanup' => 'unused',
'update' => 'unmodified',
'params' => [
'version' => 4,
'values' => [
'name' => 'Contact_Summary_Events',
'label' => E::ts('Contact Summary Events'),
'api_entity' => 'Participant',
'api_params' => [
'version' => 4,
'select' => [
'event_id.title',
'fee_level',
'fee_amount',
'register_date',
'Participant_Event_event_id_01.start_date',
'Participant_Event_event_id_01.end_date',
'status_id:label',
'contact_id.sort_name',
'role_id:label',
],
'orderBy' => [],
'where' => [],
'groupBy' => [],
'join' => [
[
'Event AS Participant_Event_event_id_01',
'LEFT',
[
'event_id',
'=',
'Participant_Event_event_id_01.id',
],
],
[
'Contact AS Participant_Contact_contact_id_01',
'LEFT',
[
'contact_id',
'=',
'Participant_Contact_contact_id_01.id',
],
],
],
'having' => [],
],
],
'match' => [
'name',
],
],
],
[
'name' => 'SavedSearch_Contact_Summary_Events_SearchDisplay_Contact_Summary_Events_Tab',
'entity' => 'SearchDisplay',
'cleanup' => 'unused',
'update' => 'unmodified',
'params' => [
'version' => 4,
'values' => [
'name' => 'Contact_Summary_Events_Tab',
'label' => E::ts('Contact Summary Events Tab'),
'saved_search_id.name' => 'Contact_Summary_Events',
'type' => 'table',
'settings' => [
'description' => NULL,
'sort' => [],
'limit' => 50,
'pager' => [
'show_count' => TRUE,
'expose_limit' => TRUE,
'hide_single' => TRUE,
],
'placeholder' => 5,
'columns' => [
[
'type' => 'html',
'key' => 'event_id.title',
'dataType' => 'String',
'label' => E::ts('Event'),
'sortable' => TRUE,
'rewrite' => '[event_id.title]',
],
[
'type' => 'field',
'key' => 'fee_level',
'dataType' => 'Text',
'label' => E::ts('Fee level'),
'sortable' => TRUE,
],
[
'type' => 'field',
'key' => 'fee_amount',
'dataType' => 'Money',
'label' => E::ts('Amount'),
'sortable' => TRUE,
],
[
'type' => 'field',
'key' => 'register_date',
'dataType' => 'Timestamp',
'label' => E::ts('Registered'),
'sortable' => TRUE,
],
[
'type' => 'html',
'key' => 'Participant_Event_event_id_01.start_date',
'dataType' => 'Timestamp',
'label' => E::ts('Event Date(s)'),
'sortable' => TRUE,
'rewrite' => '[Participant_Event_event_id_01.start_date] -<br> [Participant_Event_event_id_01.end_date]',
],
[
'type' => 'field',
'key' => 'status_id:label',
'dataType' => 'Integer',
'label' => E::ts('Status'),
'sortable' => TRUE,
],
[
'type' => 'field',
'key' => 'role_id:label',
'dataType' => 'String',
'label' => E::ts('Participant Role'),
'sortable' => TRUE,
],
[
'text' => '',
'style' => 'default',
'size' => 'btn-xs',
'icon' => 'fa-bars',
'links' => [
[
'entity' => 'Participant',
'action' => 'view',
'join' => '',
'target' => 'crm-popup',
'icon' => 'fa-ticket',
'text' => E::ts('View'),
'style' => 'default',
'path' => '',
'task' => '',
'condition' => [],
],
[
'entity' => 'Participant',
'action' => 'update',
'join' => '',
'target' => 'crm-popup',
'icon' => 'fa-pencil',
'text' => E::ts('Edit'),
'style' => 'default',
'path' => '',
'task' => '',
'condition' => [],
],
[
'entity' => 'Participant',
'action' => 'detach',
'icon' => 'fa-random',
'text' => E::ts('Transfer or Cancel'),
'style' => 'default',
'condition' => [
'status_id:name',
'NOT IN',
['Cancelled', 'Transferred'],
],
'task' => '',
'join' => '',
'target' => 'crm-popup',
],
[
'entity' => 'Participant',
'action' => 'delete',
'join' => '',
'target' => 'crm-popup',
'icon' => 'fa-trash',
'text' => E::ts('Delete'),
'style' => 'danger',
'path' => '',
'task' => '',
'condition' => [],
],
[
'icon' => 'fa-calendar',
'text' => E::ts('View Event Info'),
'style' => 'default',
'condition' => [],
'task' => '',
'entity' => 'Event',
'action' => 'view',
'join' => 'Participant_Event_event_id_01',
],
[
'path' => 'civicrm/event/search?reset=1&force=1&event=[event_id]',
'icon' => 'fa-search',
'text' => E::ts('View Participants'),
'style' => 'default',
'condition' => [],
'task' => '',
'entity' => '',
'action' => '',
'join' => '',
],
],
'type' => 'menu',
'alignment' => 'text-right',
],
],
'actions' => FALSE,
'classes' => [
'table',
'table-striped',
],
'toolbar' => [
[
'entity' => 'Participant',
'text' => E::ts('Add Event Registration'),
'icon' => 'fa-plus',
'target' => 'crm-popup',
'action' => 'add',
'style' => 'default',
'join' => '',
'task' => '',
],
],
],
],
'match' => [
'saved_search_id',
'name',
],
],
],
];
1 change: 1 addition & 0 deletions xml/schema/Event/Participant.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<add>civicrm/participant/add?action=add&amp;context=standalone&amp;reset=1</add>
<view>civicrm/contact/view/participant?id=[id]&amp;cid=[contact_id]&amp;action=view&amp;reset=1</view>
<update>civicrm/contact/view/participant?id=[id]&amp;cid=[contact_id]&amp;action=update&amp;reset=1</update>
<detach>civicrm/event/selfsvcupdate?reset=1&amp;pid=[id]&amp;is_backoffice=1</detach>
<delete>civicrm/participant/delete?id=[id]&amp;reset=1</delete>
</paths>
<field>
Expand Down

0 comments on commit 5a526df

Please sign in to comment.