-
-
Notifications
You must be signed in to change notification settings - Fork 824
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29570 from guyiac/events-greenleaf
Replace Contact Summary Events tab with Admin UI Search Display and Form
- Loading branch information
Showing
6 changed files
with
336 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
ext/civi_event/Civi/Api4/Service/Links/ParticipantLinksProvider.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | ||
], | ||
]; |
242 changes: 242 additions & 0 deletions
242
ext/civicrm_admin_ui/managed/SavedSearch_Contact_Summary_Events.mgd.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | ||
], | ||
], | ||
], | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters