Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
CiviCRM Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Development
CiviCRM Core
Commits
a5b51437
Unverified
Commit
a5b51437
authored
2 years ago
by
totten
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #25485 from colemanw/contributionAutocomplete
Fix
#4104
- APIv4 autocomplete for contributions
parents
d9920c52
5773bd73
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Civi/Api4/Service/Autocomplete/ContributionAutocompleteProvider.php
+84
-0
84 additions, 0 deletions
...Service/Autocomplete/ContributionAutocompleteProvider.php
with
84 additions
and
0 deletions
Civi/Api4/Service/Autocomplete/ContributionAutocompleteProvider.php
0 → 100644
+
84
−
0
View file @
a5b51437
<?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\Autocomplete
;
use
Civi\Core\Event\GenericHookEvent
;
use
Civi\Core\HookInterface
;
/**
* @service
* @internal
*/
class
ContributionAutocompleteProvider
extends
\Civi\Core\Service\AutoService
implements
HookInterface
{
/**
* Provide default SavedSearch for Contribution autocompletes
*
* @param \Civi\Core\Event\GenericHookEvent $e
*/
public
static
function
on_civi_search_autocompleteDefault
(
GenericHookEvent
$e
)
{
if
(
!
is_array
(
$e
->
savedSearch
)
||
$e
->
savedSearch
[
'api_entity'
]
!==
'Contribution'
)
{
return
;
}
$e
->
savedSearch
[
'api_params'
]
=
[
'version'
=>
4
,
'select'
=>
[
'id'
,
'contact_id.display_name'
,
'total_amount'
,
'receive_date'
,
'financial_type_id:label'
,
],
'orderBy'
=>
[],
'where'
=>
[],
'groupBy'
=>
[],
'join'
=>
[],
'having'
=>
[],
];
}
/**
* Provide default SearchDisplay for Contribution autocompletes
*
* @param \Civi\Core\Event\GenericHookEvent $e
*/
public
static
function
on_civi_search_defaultDisplay
(
GenericHookEvent
$e
)
{
if
(
$e
->
display
[
'settings'
]
||
$e
->
display
[
'type'
]
!==
'autocomplete'
||
$e
->
savedSearch
[
'api_entity'
]
!==
'Contribution'
)
{
return
;
}
$e
->
display
[
'settings'
]
=
[
'sort'
=>
[
[
'contact_id.sort_name'
,
'ASC'
],
[
'total_amount'
,
'ASC'
],
[
'receive_date'
,
'DESC'
],
],
'columns'
=>
[
[
'type'
=>
'field'
,
'key'
=>
'contact_id.display_name'
,
'rewrite'
=>
'[contact_id.display_name] - [total_amount]'
,
],
[
'type'
=>
'field'
,
'key'
=>
'financial_type_id:label'
,
'rewrite'
=>
'#[id] [financial_type_id:label]'
,
],
[
'type'
=>
'field'
,
'key'
=>
'receive_date'
,
],
],
];
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment